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

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