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

  1. function [lambda,GS]=goalfun(V,neqcstr,evalstr1,evalstr2,WEIGHT,GOAL,x,P1,P2,P3,P4,P5,P6,P7,P8,P9,P10);
  2. %GOALFUN Utility function to translate goal-attainment problem.
  3. %
  4. %    Intermediate function used to translate goal attainment
  5. %    problem into constrained optimization problem.
  6. %    Used by ATTGOAL and CONSTR. See also, GOALGRA.
  7.  
  8. %    Copyright (c) 1990 by the MathWorks, Inc.
  9. %    Andy Grace 7-9-90.
  10.  
  11. g=[]; f=[];  % Tell parser that f and g are variables.
  12. nx=length(V)-1;
  13. x(:)=V(1:nx);
  14. lambda=V(nx+1);
  15. eval(evalstr1)
  16. ncstr=length(WEIGHT);
  17.  
  18. GS = zeros(ncstr,1);
  19. for i=1:ncstr
  20.      if WEIGHT(i)~=0
  21.        diff=f(i)-GOAL(i);
  22.        GS(i)=sign(real(diff))*norm(diff)/WEIGHT(i)-lambda;
  23.        if i<=neqcstr, GS(i+ncstr)=-GS(i)-2*lambda; end
  24.       else
  25.        GS(i)=f(i)-GOAL(i);
  26.        if i<=neqcstr, GS(i+ncstr)=-GS(i)-1e-10; end
  27.      end
  28. end
  29. GS=[GS;g(:)]; 
  30.  
  31.