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

  1. function [gfnew,gn] = goalgra(V,neqcstr,evalstr1,evalstr2,WEIGHT,GOAL,x,P1,P2,P3,P4,P5,P6);
  2. %GOALGRA Utility function to translate gradient in goal-attainment problem.
  3. %    Intermediate function used to translate goal attainment
  4. %    problem into constrained optimization problem.
  5. %    Used by ATTGOAL and CONSTR. See also, GOALFUN.
  6.  
  7. %    Copyright (c) 1990 by the MathWorks, Inc.
  8. %    Andy Grace 7-9-90.
  9.  
  10. nx=length(V)-1;
  11. x(:)=V(1:nx);
  12. lambda=V(nx+1);
  13. gg=[];
  14. eval(evalstr2)
  15. ncstr=length(WEIGHT);
  16. GL = -ones(1,ncstr+neqcstr);
  17. for i=1:ncstr
  18.   if WEIGHT(i)~=0
  19.     gf(:,i)=gf(:,i)/WEIGHT(i);
  20.     if i<=neqcstr,gf(:,i+ncstr)=-gf(:,i); end 
  21.   else
  22.     GL(1,i)=0;
  23.   end
  24. end
  25. gfnew=[zeros(nx,1);1];
  26. gn=[gf;GL];
  27. gs=size(gg);
  28. if gs(1)>0, gn=[gn,[gg;zeros(1,gs(2))]]; end
  29.