home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l455 / 4.ddi / OPTIM.DI$ / ATTGOAL.M next >
Encoding:
Text File  |  1993-03-11  |  3.9 KB  |  119 lines

  1. function [x, OPTIONS] = attgoal(FUN,x,GOAL,WEIGHT,OPTIONS,VLB,VUB,GRADFUN,P1,P2,P3,P4,P5,P6,P7,P8,P9,P10)
  2. %ATTGOAL Solves the multi-objective goal attainment optimization problem.
  3. %
  4. %    X = ATTGOAL('FUN',X0,GOAL,WEIGHT)
  5. %    tries to make the objective functions (F) supplied by FUN
  6. %    (usually an M-file: FUN.M)  attain the goals (GOAL) by varying X.
  7. %
  8. %    In doing so the following non-linear programming problem is solved:
  9. %            min { LAMBDA | F(X)-WEIGHT.LAMBDA<=GOAL } 
  10. %             K  
  11. %
  12. %    The function 'FUN' should return the values of the objectives, F.
  13. %    F=FUN(X).
  14. %
  15. %    X=ATTGOAL('FUN',X,OPTIONS) allows a vector of optional parameters to 
  16. %    be defined. For more information type HELP FOPTIONS.
  17. %    
  18. %    X=ATTGOAL('FUN',X,OPTIONS,VLB,VUB) defines a set of lower and upper
  19. %    bounds on the design variables, X, so that the solution is always in 
  20. %    the range VLB < X < VUB. 
  21. %     For details of other options see the M-file ATTGOAL.M.
  22.  
  23. %    Copyright (c) 1990 by the MathWorks, Inc.
  24. %    Andy Grace 7-9-90.
  25.  
  26.          
  27. % ---------------------More Details---------------------------
  28. % [x]=attgoal(x,F,GOAL,WEIGHT,OPTIONS)
  29. % Solves the goal attainment problem where:
  30. %
  31. %  X  Is a set of design parameters which can be varied.
  32. %  F  Is a set of objectives which are dependent on X.
  33. %  GOAL Set of design goals. The optimizer will try to make 
  34. %         F<GOAL, F=GOAL, or F>GOAL depending on the formulation.
  35. %  WEIGHT Set of weighting parameters which determine the 
  36. %         relative under or over achievement of the objectives.
  37. %         Notes:
  38. %           1.Setting WEIGHT=abs(GOAL)  will try to make the objectives
  39. %             less than the goals resulting  in roughly the same 
  40. %             percentage under or over achievement of the goals.
  41. %           2. Setting WEIGHT=-abs(GOAL) will try to make the objectives
  42. %              greater then the goals resulting in roughly the same percentage 
  43. %              under- or over-achievement in the goals.
  44. %           3. Setting WEIGHT(i)=0  indicates a hard constraint.
  45. %              i.e. F<GOAL.
  46. %  OPTIONS OPTIONS(15) indicates the number of objectives for which it is
  47. %       required for the objectives (F) to equal the goals (GOAL). 
  48. %          Such objectives should be partitioned into the first few 
  49. %       elements of F.
  50. %          The remaining parameters determine tolerance settings.
  51. %          For more information type HELP FOPTIONS.
  52. %
  53. %
  54. %    X=ATTGOAL('FUN',X,OPTIONS,VLB,VUB,'GRADFUN') allows a function 
  55. %    'GRADFUN' to be entered which returns the partial derivatives of the 
  56. %    function and the  constraints at X:  GRADS = GRADFUN(X).
  57. %
  58. %    X=ATTGOAL('FUN',X,OPTIONS,VLB,VUB,[],P1,P2,..) allows
  59. %    coefficients, P1, P2, P3 to be passed directly to FUN:
  60. %    [F,G]=FUN(X,P1,P2,...).
  61.  
  62.  
  63.         
  64. if nargin < 5, OPTIONS=[]; end
  65. if nargin < 6, VLB=[]; end
  66. if nargin < 7, VUB=[]; end
  67. if nargin < 8, GRADFUN=[]; end
  68.  
  69. lenopt = length(OPTIONS);
  70. if ~lenopt, OPTIONS=0; end
  71.  
  72. xnew=x(:);
  73. WEIGHT=WEIGHT(:);
  74. GOAL=GOAL(:);
  75. OPTIONS=foptions(OPTIONS);
  76. OPTIONS(7) = ~OPTIONS(7);
  77. neqcstr=OPTIONS(15); 
  78.  
  79. if ~any(FUN<48)
  80.     evalstr1 = ['f=',FUN,];
  81.         evalstr1=[evalstr1, '(x'];
  82.         for i=1:nargin - 8
  83.                 evalstr1 = [evalstr1,',P',int2str(i)];
  84.         end
  85.         evalstr1 = [evalstr1, ');'];
  86. else
  87.         evalstr1=['f=',FUN,';'];
  88. end
  89. evalstr1=[evalstr1, 'g=[];'];
  90.  
  91.  
  92. evalstr2='';
  93. if length(GRADFUN)
  94.     if ~any(GRADFUN<48) % Check alphanumeric
  95.         evalstr2 = ['gf=',GRADFUN,'(x'];
  96.         for i=1:nargin - 8
  97.             evalstr2 = [evalstr2,',P',int2str(i)];
  98.         end
  99.         evalstr2 = [evalstr2, ');'];
  100.         gfun  = 'goalgra';
  101.     else
  102.         evalstr2=['gf=', GRADFUN,';'];
  103.     end
  104. else
  105.     gfun = [];
  106. end
  107.  
  108. evalstr = ['[xnew, OPTIONS] = constr(''goalfun'',[xnew;0],OPTIONS,VLB,VUB,gfun,neqcstr,evalstr1,evalstr2,WEIGHT,GOAL,x'];
  109.  
  110.  
  111. for i=1:nargin - 8
  112.     evalstr = [evalstr,',P',int2str(i)];
  113. end
  114. evalstr = [evalstr, ');'];
  115.  
  116. eval(evalstr)
  117. OPTIONS(7) = ~OPTIONS(7);
  118. x(:) = xnew(1:length(xnew)-1);
  119.