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

  1. function [f, g, t1, t2, coeff1] = toptimf(X, coeff1, coeff2, coeff3)
  2. %TOPTIMF Test functions for optimization test-suite (TOPTIM).
  3. if (nargin > 2)
  4.     if coeff2 == 7 % 1D seminf
  5.         if isnan(coeff1(1,1)), coeff1 = [0.2  0; 0.2 0]; end
  6.         % Sample set
  7.         w1=1:coeff1(1,1):100;
  8.         w2=1:coeff1(2,1):100;
  9.         % Semi-infinite constraints
  10.         t1=sin(w1*X(1)).*cos(w1*X(2))-1/1000*(w1-50).^2-sin(w1*X(3))-1-X(3);
  11.         t2=sin(w2*X(2)).*cos(w2*X(1))-1/1000*(w2-50).^2-sin(w2*X(3))-1-X(2);
  12.         %plot(w1,t1,w1,t1,'o',w2,t2,w2,t2,'+')
  13.         g = []; % No constraints
  14.         % Objective function
  15.         f = sum((X-0.5).^2);
  16.     elseif coeff2 == 8 % 2D seminf
  17.         % Initial sampling intervals
  18.         if isnan(coeff1(1,1)), coeff1 = [2  2]; end
  19.         % Sampling sets
  20.         w1=1:coeff1(1,1):100;
  21.         w2=1:coeff1(1,2):100;
  22.         [wx, wy] = meshdom(w1, w2);
  23.         % Old meshdom:
  24.         wx = w1(ones(length(w2), 1),:);
  25.         w2t = w2(length(w2):-1:1)'; 
  26.         wy = w2t(:,ones(1, length(w1)));
  27.         % Semi-infinite  constraint
  28.         t1=sin(wx*X(1)).*cos(wy*X(2)) -1/1000*(wx-50).^2-sin(wx*X(3))-1-X(3) + ...
  29.               sin(wy*X(2)).*cos(wx*X(1))-1/1000*(wy-50).^2-sin(wy*X(3))-1-X(2);
  30.         % Objective function
  31.         f = sum((X-0.2).^2);
  32.         t2 = coeff1;
  33.     end
  34. elseif coeff1==1 % Unconstrained
  35.     f=100*(X(2)-X(1)^2)^2+(1-X(1))^2;
  36. elseif coeff1 ==2 % Constrained Pg 74 Schittkowski
  37.     f(1)=-X(1)*X(2)*X(3);               
  38.     g(1)=-X(1)-2*X(2)-2*X(3);
  39.     g(2)=X(1)+2*X(2)+2*X(3)-72;  
  40. elseif coeff1 ==3 % Goal attainment 
  41.     A=[-0.5 0 0    
  42.     0    -2 10
  43.     0   1  -2];
  44.     B=  [1 0
  45.     -2 2
  46.     0 1];
  47.     C = [1 0 0
  48.     0 0 1];
  49.     f=sort(eig(A+B*X*C));
  50. elseif coeff1 == 4 % Minimax
  51.     f(1)=2*X(1)^2+X(2)^2-48*X(1)-40*X(2)+304; 
  52.     f(2)=-X(1)-3*X(2);
  53.     f(3)=-18+X(1)+3*X(2);
  54.     f(4)=-X(1)-X(2);
  55.     f(5)=-8+X(1)+X(2);
  56. elseif coeff1 == 5 % Non-linear least squares problem
  57.     for i=1:10
  58.         f(i)=2+2*i-exp(X(1)*i)-exp(X(2)*i);
  59.     end
  60. elseif coeff1 == 6 % Solve  problem
  61.     x2=zeros(2);
  62.     x2(:)=X;
  63.     f=x2*x2*x2-[1,2;3,4];
  64.     f=f(:);
  65. elseif coeff1 == 9 % fmin  problem
  66.     f = sin(X);
  67. end
  68.