home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l455 / 2.ddi / MUTOOLS2.DI$ / MFFIXBAS.M < prev    next >
Encoding:
Text File  |  1993-03-11  |  779 b   |  29 lines

  1. % function [outbasic,err] = fmfixbas(a,augbasic,sol,nvar,ncon)
  2. %
  3. %  *****  UNTESTED  *****
  4. %
  5. % Fix a feasible basis when the slack variables are in the basis.
  6. % FMFIXBAS uses a QR decomposition to get a well-conditioned basis.
  7. %
  8. % See Also: MFLINP.
  9.  
  10. function [outbasic,err] = mffixbas(a,augbasic,sol,nvar,ncon)
  11.  
  12.  err = 0;
  13.  outbasic=augbasic;
  14.  trouble = find(outbasic>nvar);
  15.  if norm(sol(trouble))>1e-12
  16.    err = 1;
  17.  else
  18.    ok = find(outbasic<=nvar);
  19.    oknotused = comple(outbasic(ok),nvar);%keyboard
  20.    [q1,r1,e1]=qr(a(:,outbasic(ok)));
  21.    [q2,r2,e2]=qr(q1(:,length(ok)+1:ncon)'*a(:,oknotused));
  22.    for i=1:length(trouble)
  23.       outbasic(trouble(i))=oknotused(find(e2(:,i)));
  24.    end
  25.  end
  26. %keyboard
  27. %
  28. % Copyright MUSYN INC 1991,  All Rights Reserved
  29.