1function fvec = dfovec(m,n,x,nprob) 2% This is a MATLAB version of the subroutine dfovec.f 3% This subroutine specifies the nonlinear benchmark problems in 4% 5% Benchmarking Derivative-Free Optimization Algorithms 6% Jorge J. More' and Stefan M. Wild 7% SIAM J. Optimization, Vol. 20 (1), pp.172-191, 2009. 8% 9% The latest version of this subroutine is always available at 10% http://www.mcs.anl.gov/~more/dfo/ 11% The authors would appreciate feedback and experiences from numerical 12% studies conducted using this subroutine. 13% 14% The data file dfo.dat defines suitable values of m and n 15% for each problem number nprob. 16% 17% This subroutine defines the functions of 22 nonlinear 18% least squares problems. The allowable values of (m,n) for 19% functions 1,2 and 3 are variable but with m .ge. n. 20% For functions 4,5,6,7,8,9 and 10 the values of (m,n) are 21% (2,2),(3,3),(4,4),(2,2),(15,3),(11,4) and (16,3), respectively. 22% Function 11 (Watson) has m = 31 with n usually 6 or 9. 23% However, any n, n = 2,...,31, is permitted. 24% Functions 12,13 and 14 have n = 3,2 and 4, respectively, but 25% allow any m .ge. n, with the usual choices being 10,10 and 20. 26% Function 15 (Chebyquad) allows m and n variable with m .ge. n. 27% Function 16 (Brown) allows n variable with m = n. 28% For functions 17 and 18, the values of (m,n) are 29% (33,5) and (65,11), respectively. 30% 31% fvec = ssqfcn(m,n,x,nprob) 32% fvec is an output array of length m which contains the nprob 33% function evaluated at x. 34% m and n are positive integer input variables. n must not 35% exceed m. 36% x is an input array of length n. 37% nprob is a positive integer input variable which defines the 38% number of the problem. nprob must not exceed 22. 39% 40% Argonne National Laboratory 41% Jorge More' and Stefan Wild. January 2008. 42 43% Set lots of constants: 44c13 = 1.3d1; c14 = 1.4d1; c29 = 2.9d1; c45 = 4.5d1; 45v = [4.0d0,2.0d0,1.0d0,5.0d-1,2.5d-1,1.67d-1,1.25d-1,1.0d-1,8.33d-2,... 46 7.14d-2,6.25d-2]; 47y1 = [1.4d-1,1.8d-1,2.2d-1,2.5d-1,2.9d-1,3.2d-1,3.5d-1,3.9d-1,3.7d-1,... 48 5.8d-1,7.3d-1,9.6d-1,1.34d0,2.1d0,4.39d0]; 49y2 = [1.957d-1,1.947d-1,1.735d-1,1.6d-1,8.44d-2,6.27d-2,4.56d-2,3.42d-2,... 50 3.23d-2,2.35d-2,2.46d-2]; 51y3 = [3.478d4,2.861d4,2.365d4,1.963d4,1.637d4,1.372d4,1.154d4,9.744d3,... 52 8.261d3,7.03d3,6.005d3,5.147d3,4.427d3,3.82d3,3.307d3,2.872d3]; 53y4 = [8.44d-1,9.08d-1,9.32d-1,9.36d-1,9.25d-1,9.08d-1,8.81d-1,8.5d-1,... 54 8.18d-1,7.84d-1,7.51d-1,7.18d-1,6.85d-1,6.58d-1,6.28d-1,6.03d-1,... 55 5.8d-1,5.58d-1,5.38d-1,5.22d-1,5.06d-1,4.9d-1,4.78d-1,4.67d-1,... 56 4.57d-1,4.48d-1,4.38d-1,4.31d-1,4.24d-1,4.2d-1,4.14d-1,4.11d-1,... 57 4.06d-1]; 58y5 = [1.366d0,1.191d0,1.112d0,1.013d0,9.91d-1,8.85d-1,8.31d-1,8.47d-1,... 59 7.86d-1,7.25d-1,7.46d-1,6.79d-1,6.08d-1,6.55d-1,6.16d-1,6.06d-1,... 60 6.02d-1,6.26d-1,6.51d-1,7.24d-1,6.49d-1,6.49d-1,6.94d-1,6.44d-1,... 61 6.24d-1,6.61d-1,6.12d-1,5.58d-1,5.33d-1,4.95d-1,5.0d-1,4.23d-1,... 62 3.95d-1,3.75d-1,3.72d-1,3.91d-1,3.96d-1,4.05d-1,4.28d-1,4.29d-1,... 63 5.23d-1,5.62d-1,6.07d-1,6.53d-1,6.72d-1,7.08d-1,6.33d-1,6.68d-1,... 64 6.45d-1,6.32d-1,5.91d-1,5.59d-1,5.97d-1,6.25d-1,7.39d-1,7.1d-1,... 65 7.29d-1,7.2d-1,6.36d-1,5.81d-1,4.28d-1,2.92d-1,1.62d-1,9.8d-2,5.4d-2]; 66 67% Initialize things: 68fvec = zeros(m,1); 69sum = 0; 70 71switch nprob 72 case 1 % Linear function - full rank. 73 for j = 1:n 74 sum = sum + x(j); 75 end 76 temp = 2*sum/m + 1; 77 for i = 1:m 78 fvec(i) = -temp; 79 if (i <= n) 80 fvec(i) = fvec(i) + x(i); 81 end 82 end 83 case 2 % Linear function - rank 1. 84 for j = 1:n 85 sum = sum + j*x(j); 86 end 87 for i = 1:m 88 fvec(i) = i*sum - 1; 89 end 90 case 3 % Linear function - rank 1 with zero columns and rows. 91 for j = 2:n-1 92 sum = sum + j*x(j); 93 end 94 for i = 1:m-1 95 fvec(i) = (i-1)*sum - 1; 96 end 97 fvec(m) = -1; 98 case 4 % Rosenbrock function. 99 fvec(1) = 10*(x(2) - x(1)^2); 100 fvec(2) = 1 - x(1); 101 case 5 % Helical valley function. 102 if (x(1) > 0) 103 th = atan(x(2)/x(1))/(2*pi); 104 elseif (x(1) < 0) 105 th = atan(x(2)/x(1))/(2*pi) + .5; 106 else % x(1)=0 107 th = .25; 108 end 109 r = sqrt(x(1)^2+x(2)^2); 110 fvec(1) = 10*(x(3) - 10*th); 111 fvec(2) = 10*(r-1); 112 fvec(3) = x(3); 113 case 6 % Powell singular function. 114 fvec(1) = x(1) + 10*x(2); 115 fvec(2) = sqrt(5)*(x(3) - x(4)); 116 fvec(3) = (x(2) - 2*x(3))^2; 117 fvec(4) = sqrt(10)*(x(1) - x(4))^2; 118 case 7 % Freudenstein and Roth function. 119 fvec(1) = -c13 + x(1) + ((5 - x(2))*x(2) - 2)*x(2); 120 fvec(2) = -c29 + x(1) + ((1 + x(2))*x(2) - c14)*x(2); 121 case 8 % Bard function. 122 for i = 1:15 123 tmp1 = i; 124 tmp2 = 16-i; 125 tmp3 = tmp1; 126 if (i > 8) 127 tmp3 = tmp2; 128 end 129 fvec(i) = y1(i) - (x(1) + tmp1/(x(2)*tmp2 + x(3)*tmp3)); 130 end 131 case 9 % Kowalik and Osborne function. 132 for i = 1:11 133 tmp1 = v(i)*(v(i) + x(2)); 134 tmp2 = v(i)*(v(i) + x(3)) + x(4); 135 fvec(i) = y2(i) - x(1)*tmp1/tmp2; 136 end 137 case 10 % Meyer function. 138 for i = 1:16 139 temp = 5*i + c45 + x(3); 140 tmp1 = x(2)/temp; 141 tmp2 = exp(tmp1); 142 fvec(i) = x(1)*tmp2 - y3(i); 143 end 144 case 11 % Watson function. 145 for i = 1:29 146 div = i/c29; 147 s1 = 0; 148 dx = 1; 149 for j = 2:n 150 s1 = s1 + (j-1)*dx*x(j); 151 dx = div*dx; 152 end 153 s2 = 0; 154 dx = 1; 155 for j = 1:n 156 s2 = s2 + dx*x(j); 157 dx = div*dx; 158 end 159 fvec(i) = s1 - s2^2 - 1; 160 end 161 fvec(30) = x(1); 162 fvec(31) = x(2) - x(1)^2 - 1; 163 case 12 % Box 3-dimensional function. 164 for i = 1:m 165 temp = i; 166 tmp1 = temp/10; 167 fvec(i) = exp(-tmp1*x(1)) - exp(-tmp1*x(2))+ ... 168 (exp(-temp) - exp(-tmp1))*x(3); 169 end 170 case 13 % Jennrich and Sampson function. 171 for i = 1:m 172 temp = i; 173 fvec(i) = 2 + 2*temp - exp(temp*x(1)) - exp(temp*x(2)); 174 end 175 case 14 % Brown and Dennis function. 176 for i = 1:m 177 temp = i/5; 178 tmp1 = x(1) + temp*x(2) - exp(temp); 179 tmp2 = x(3) + sin(temp)*x(4) - cos(temp); 180 fvec(i) = tmp1^2 + tmp2^2; 181 end 182 case 15 % Chebyquad function. 183 for j = 1:n 184 t1 = 1; 185 t2 = 2*x(j) - 1; 186 t = 2*t2; 187 for i = 1:m 188 fvec(i) = fvec(i) + t2; 189 th = t*t2 - t1; 190 t1 = t2; 191 t2 = th; 192 end 193 end 194 iev = -1; 195 for i = 1:m 196 fvec(i) = fvec(i)/n; 197 if (iev > 0) 198 fvec(i) = fvec(i) + 1/(i^2 - 1); 199 end 200 iev = -iev; 201 end 202 case 16 % Brown almost-linear function. 203 sum1 = -(n+1); 204 prod1 = 1; 205 for j = 1:n 206 sum1 = sum1 + x(j); 207 prod1 = x(j)*prod1; 208 end 209 for i = 1:n-1 210 fvec(i) = x(i) + sum1; 211 end 212 fvec(n) = prod1 - 1; 213 case 17 % Osborne 1 function. 214 for i = 1:33 215 temp = 10*(i-1); 216 tmp1 = exp(-x(4)*temp); 217 tmp2 = exp(-x(5)*temp); 218 fvec(i) = y4(i) - (x(1) + x(2)*tmp1 + x(3)*tmp2); 219 end 220 case 18 % Osborne 2 function. 221 for i = 1:65 222 temp = (i-1)/10; 223 tmp1 = exp(-x(5)*temp); 224 tmp2 = exp(-x(6)*(temp-x(9))^2); 225 tmp3 = exp(-x(7)*(temp-x(10))^2); 226 tmp4 = exp(-x(8)*(temp-x(11))^2); 227 fvec(i) = y5(i) - (x(1)*tmp1 + x(2)*tmp2 + ... 228 x(3)*tmp3 + x(4)*tmp4); 229 end 230 case 19 % Bdqrtic 231 % n>=5, m = (n-4)*2 232 for i=1:n-4 233 fvec(i)=(-4*x(i)+3.0); 234 fvec(n-4+i)=(x(i)^2+2*x(i+1)^2+3*x(i+2)^2+4*x(i+3)^2+5*x(n)^2); 235 end 236 case 20 % Cube 237 % n=2; m=n; 238 fvec(1) = (x(1)-1.0); 239 for i=2:n 240 fvec(i) = 10*(x(i)-x(i-1)^3); 241 end 242 case 21 % Mancino 243 % n >=2; m=n 244 for i=1:n 245 ss=0; 246 for j=1:n 247 v2 = sqrt (x(i)^2 +i/j); 248 ss = ss+v2*((sin(log(v2)))^5 + (cos(log(v2)))^5); 249 end 250 fvec(i)=1400*x(i) + (i-50)^3 + ss; 251 end 252 case 22 % Heart8ls 253 % m=n=8 254 fvec(1) = x(1) + x(2) + 0.69; 255 fvec(2) = x(3) + x(4) + 0.044; 256 fvec(3) = x(5)*x(1) + x(6)*x(2) - x(7)*x(3) - x(8)*x(4) + 1.57; 257 fvec(4) = x(7)*x(1) + x(8)*x(2) + x(5)*x(3) + x(6)*x(4) + 1.31; 258 fvec(5) = x(1)*(x(5)^2-x(7)^2) - 2.0*x(3)*x(5)*x(7) + ... 259 x(2)*(x(6)^2-x(8)^2) - 2.0*x(4)*x(6)*x(8) + 2.65; 260 fvec(6) = x(3)*(x(5)^2-x(7)^2) + 2.0*x(1)*x(5)*x(7) + ... 261 x(4)*(x(6)^2-x(8)^2) + 2.0*x(2)*x(6)*x(8) - 2.0; 262 fvec(7) = x(1)*x(5)*(x(5)^2-3.0*x(7)^2) + ... 263 x(3)*x(7)*(x(7)^2-3.0*x(5)^2) + ... 264 x(2)*x(6)*(x(6)^2-3.0*x(8)^2) + ... 265 x(4)*x(8)*(x(8)^2-3.0*x(6)^2) + 12.6; 266 fvec(8) = x(3)*x(5)*(x(5)^2-3.0*x(7)^2) - ... 267 x(1)*x(7)*(x(7)^2-3.0*x(5)^2) + ... 268 x(4)*x(6)*(x(6)^2-3.0*x(8)^2) - ... 269 x(2)*x(8)*(x(8)^2-3.0*x(6)^2) - 9.48; 270 271end 272