home *** CD-ROM | disk | FTP | other *** search
- function [lambda,GS]=goalfun(V,neqcstr,evalstr1,evalstr2,WEIGHT,GOAL,x,P1,P2,P3,P4,P5,P6,P7,P8,P9,P10);
- %GOALFUN Utility function to translate goal-attainment problem.
- %
- % Intermediate function used to translate goal attainment
- % problem into constrained optimization problem.
- % Used by ATTGOAL and CONSTR. See also, GOALGRA.
-
- % Copyright (c) 1990 by the MathWorks, Inc.
- % Andy Grace 7-9-90.
-
- g=[]; f=[]; % Tell parser that f and g are variables.
- nx=length(V)-1;
- x(:)=V(1:nx);
- lambda=V(nx+1);
- eval(evalstr1)
- ncstr=length(WEIGHT);
-
- GS = zeros(ncstr,1);
- for i=1:ncstr
- if WEIGHT(i)~=0
- diff=f(i)-GOAL(i);
- GS(i)=sign(real(diff))*norm(diff)/WEIGHT(i)-lambda;
- if i<=neqcstr, GS(i+ncstr)=-GS(i)-2*lambda; end
- else
- GS(i)=f(i)-GOAL(i);
- if i<=neqcstr, GS(i+ncstr)=-GS(i)-1e-10; end
- end
- end
- GS=[GS;g(:)];
-
-