1 // Copyright (c) 2015-2016, Massachusetts Institute of Technology
2 // Copyright (c) 2016-2017 Sandia Corporation
3 
4 // This file is part of the Compressed Continuous Computation (C3) Library
5 // Author: Alex A. Gorodetsky
6 // Contact: alex@alexgorodetsky.com
7 
8 // All rights reserved.
9 
10 // Redistribution and use in source and binary forms, with or without modification,
11 // are permitted provided that the following conditions are met:
12 
13 // 1. Redistributions of source code must retain the above copyright notice,
14 //    this list of conditions and the following disclaimer.
15 
16 // 2. Redistributions in binary form must reproduce the above copyright notice,
17 //    this list of conditions and the following disclaimer in the documentation
18 //    and/or other materials provided with the distribution.
19 
20 // 3. Neither the name of the copyright holder nor the names of its contributors
21 //    may be used to endorse or promote products derived from this software
22 //    without specific prior written permission.
23 
24 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
28 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 
35 //Code
36 
37 
38 
39 #include <stdio.h>
40 #include <stdlib.h>
41 #include <string.h>
42 #include <math.h>
43 #include <assert.h>
44 
45 #include "array.h"
46 #include "linalg.h"
47 #include "lib_optimization.h"
48 
49 #include "unconstrained_functions.h"
50 
51 #ifndef M_PI
52 #define M_PI 3.14159265358979323846
53 #endif
54 
55 ////////////////////////////////////////////////
56 //Collection of test problems from More, Garbow and Hillstrom 1981
57 ////////////////////////////////////////////////
58 // Rosenbrock function
rosen_brock_func(size_t dim,const double * x,double * grad,void * arg)59 double rosen_brock_func(size_t dim, const double * x, double * grad, void * arg)
60 {
61     (void)(dim);
62     (void)(arg);
63     double f1 = 10.0 * (x[1] - pow(x[0],2));
64     double f2 = (1.0 - x[0]);
65 
66     double out = pow(f1,2) + pow(f2,2);
67 
68     if (grad != NULL){
69         grad[0] = 2.0*f1 * (-20.0 * x[0]) + 2.0 * f2 * (-1.0);
70         grad[1] = 2 * f1 * 10.0;
71     }
72 
73     return out;
74 }
75 
76 static double rosen_brock_start[2] = {-1.2, 1.0};
77 static double rosen_brock_sol[3] = {1.0, 1.0, 0.0};
78 
79 // Freudenstein and Roth
f1(size_t dim,const double * x,double * grad,void * arg)80 double f1(size_t dim, const double * x, double * grad, void * arg)
81 {
82     (void)(dim);
83     (void)(arg);
84     double f1 = -13.0 + x[0] + ( (5.0 - x[1]) * x[1] - 2.0)*x[1];
85     double f2 = -29.0 + x[0] + ( (x[1] + 1.0) * x[1] - 14.0) * x[1];
86 
87     double out = pow(f1,2) + pow(f2,2);
88 
89     if (grad != NULL){
90         grad[0] = 2.0*f1*1 + 2.0*f2*1;
91         grad[1] = 2.0*f1 * (-3.0*pow(x[1],2) + 10.0 * x[1] - 2.0)
92             + 2.0 * f2 * (3.0*pow(x[1],2) + 2.0*x[1] - 14.0);
93     }
94 
95     return out;
96 }
97 
98 static double f1start[2] = {0.5, -2.0};
99 static double f1sol[3] = {11.41, -0.8968, 48.9842};
100 // alternative
101 /* double f1sol[3] = {5.0, 4.0, 0.0}; */
102 
103 // Powell badly scaled
f2(size_t dim,const double * x,double * grad,void * arg)104 double f2(size_t dim, const double * x, double * grad, void * arg)
105 {
106     (void)(dim);
107     (void)(arg);
108     double f1 = pow(10.0,4)*x[0]*x[1] - 1.0;
109     double f2 = exp(-x[0]) + exp(-x[1]) - 1.001;
110 
111     double out = pow(f1,2) + pow(f2,2);
112 
113     if (grad != NULL){
114         grad[0] = 2.0*f1*pow(10.0,4)*x[1] + 2.0*f2*(-1.0)*exp(-x[0]);
115         grad[1] = 2.0*f1*pow(10.0,4)*x[0] + 2.0*f2*(-1.0)*exp(-x[1]);
116     }
117 
118     return out;
119 }
120 
121 static double f2start[2] = {0.0,1.0};
122 static double f2sol[3] = {1.098e-5, 9.106,0.0};
123 
124 // Brown badly scaled
ff3(size_t dim,const double * x,double * grad,void * arg)125 double ff3(size_t dim, const double * x, double * grad, void * arg)
126 {
127     (void)(dim);
128     (void)(arg);
129     double f1 = x[0] - pow(10,6);
130     double f2 = x[1] - 2 * pow(10,-6.0);
131     double f3 = x[0]*x[1] - 2.0;
132 
133     double out = pow(f1,2) + pow(f2,2) + pow(f3,2);
134 
135     if (grad != NULL){
136         grad[0] = 2.0*f1 + 2.0*f3*x[1];
137         grad[1] = 2.0*f2 + 2.0*f3*x[0];
138     }
139     return out;
140 }
141 
142 static double f3start[2] = {1.0,1.0};
143 static double f3sol[3] = {1e6, 2e-6, 0.0};
144 
145 // Beale function
ff4(size_t dim,const double * x,double * grad,void * arg)146 double ff4(size_t dim, const double * x, double * grad, void * arg)
147 {
148     (void)(dim);
149     (void)(arg);
150     double f1 = 1.5 - x[0] * (1 - pow(x[1],1));
151     double f2 = 2.25 - x[0] * (1 - pow(x[1],2));
152     double f3 = 2.625 - x[0] * (1 - pow(x[1],3));
153 
154     double out = pow(f1,2) + pow(f2,2) + pow(f3,2);
155 
156     if (grad != NULL){
157         grad[0] = 2 * f1 * (-1) * (1 - pow(x[1],1)) +
158                   2 * f2 * (-1) * (1 - pow(x[1],2)) +
159                   2 * f3 * (-1) * (1 - pow(x[1],3));
160 
161         grad[1] = 2 * f1 * x[0] +
162                   2 * f2 * 2*x[0]*x[1] + 2 * f3 * 3*x[0]*x[1]*x[1];
163 
164     }
165     return out;
166 }
167 
168 static double f4start[2] = {1.0,1.0};
169 static double f4sol[3] = {3.0, 0.5, 0.0};
170 
171 // Jennrich and Sampson function
ff5(size_t dim,const double * x,double * grad,void * arg)172 double ff5(size_t dim, const double * x, double * grad, void * arg)
173 {
174     (void)(dim);
175     (void)(arg);
176 
177     if (isnan(x[0])){
178         printf("stop\n");
179         exit(1);
180     }
181 
182     if (isnan(x[1])){
183         printf("stop\n");
184         exit(1);
185     }
186     double f[10];
187     double out = 0.0;
188     for (size_t ii = 0; ii < 10; ii++){
189         f[ii] = 2.0 + 2.0 * (double) (ii+1) -
190             (exp((double)(ii+1)*x[0]) + exp((double)(ii+1) * x[1]));
191         out += pow(f[ii],2);
192     }
193 
194     if (grad != NULL){
195         grad[0] = 0.0;
196         grad[1] = 0.0;
197         for (size_t ii = 0; ii < 10; ii++){
198             grad[0] += 2.0 * f[ii] * (-(double)(ii+1))*exp((double)(ii+1)*x[0]);
199             grad[1] += 2.0 * f[ii] * (-(double)(ii+1))*exp((double)(ii+1)*x[1]);
200         }
201     }
202 
203     if (isnan(out)){
204         dprint(2,x);
205         exit(1);
206     }
207     return out;
208 }
209 
210 static double f5start[2] = {0.3,0.4};
211 static double f5sol[3] = {0.2578, 0.2578, 124.362};
212 
213 // Helical valley function
ff6(size_t dim,const double * x,double * grad,void * arg)214 double ff6(size_t dim, const double * x, double * grad, void * arg)
215 {
216     (void)(dim);
217     (void)(arg);
218 
219 
220     double theta;
221     if (x[0] > 0){
222         theta = 1.0 / 2.0 / M_PI * atan(x[1]/x[0]);
223     }
224     else{
225         theta = 1.0 / 2.0 / M_PI * atan(x[1]/x[0])+0.5;
226     }
227 
228     double f1 = 10 * (x[2] - 10 * theta);
229     double f2 = 10 * (sqrt( x[0]*x[0] + x[1]*x[1]) - 1.0);
230     double f3 = x[2];
231 
232     double out = f1 * f1 + f2 * f2 + f3 * f3;
233 
234     if (grad != NULL){
235 
236         double dtheta1 = 1.0/2.0/M_PI * (-x[1] / (x[0]*x[0] + x[1]*x[1]));
237         double dtheta2 = 1.0/2.0/M_PI * (x[0] / (x[0]*x[0] + x[1]*x[1]));
238 
239         grad[0] = 0.0;
240         grad[0] += 2* f1 * (-100) * dtheta1;
241         grad[0] += 2 * f2 * 5 * 1.0/sqrt(x[0]*x[0] + x[1]*x[1]) * 2.0 * x[0];
242 
243         grad[1] = 0.0;
244         grad[1] += 2.0 * f1 *(-100) * dtheta2;
245         grad[1] += 2 * f2 * 5 * 1.0/sqrt(x[0]*x[0] + x[1]*x[1]) * 2.0 * x[1];
246 
247         grad[2] = 0.0;
248         grad[2] += 2.0 * f1 * 10.0;
249         grad[2] += 2.0 * f3;
250     }
251 
252 
253     return out;
254 }
255 
256 static double f6start[3] = {-1.0,0.0,0.0};
257 static double f6sol[4] = {1.0,0.0,0.0,0.0};
258 
259 // Bard function
ff7(size_t dim,const double * x,double * grad,void * arg)260 double ff7(size_t dim, const double * x, double * grad, void * arg)
261 {
262     (void)(dim);
263     (void)(arg);
264 
265     double y[15] = {0.14, 0.18, 0.22, 0.25, 0.29,
266                     0.32, 0.35, 0.39, 0.37, 0.58,
267                     0.73, 0.96, 1.34, 2.10, 4.39};
268 
269     double f[15];
270     double u[15];
271     double v[15];
272     double w[15];
273     double out = 0.0;
274     for (size_t ii = 0; ii < 15; ii++){
275         u[ii] = (double)(ii+1);
276         v[ii] = 16.0 - (double)(ii+1);
277         w[ii] = u[ii];
278         if (v[ii] < u[ii]) w[ii] = v[ii];
279 
280         f[ii] = y[ii] - (x[0] + u[ii]/(v[ii] * x[1] + w[ii] * x[2]));
281         out += f[ii] * f[ii];
282     }
283 
284     if (grad != NULL){
285 
286         grad[0] = 0.0;
287         grad[1] = 0.0;
288         grad[2] = 0.0;
289         for (size_t ii = 0; ii < 15; ii++){
290             grad[0] += 2*f[ii]*(-1.0);
291             grad[1] += 2*f[ii]*u[ii]*1.0/pow(v[ii]*x[1] + w[ii]*x[2],2)*v[ii];
292             grad[2] += 2*f[ii]*u[ii]*1.0/pow(v[ii]*x[1] + w[ii]*x[2],2)*w[ii];
293         }
294     }
295 
296 
297     return out;
298 }
299 static double f7start[3] = {1.0,1.0,1.0};
300 static double f7sol[4] = {0.0,0.0,0.0,8.21487e-3};// confused
301 
302 // Gaussian Function
ff8(size_t dim,const double * x,double * grad,void * arg)303 double ff8(size_t dim, const double * x, double * grad, void * arg)
304 {
305     (void)(dim);
306     (void)(arg);
307 
308     double y[15];
309     y[0] = 0.0009;
310     y[1] = 0.0044;
311     y[2] = 0.0175;
312     y[3] = 0.0540;
313     y[4] = 0.1295;
314     y[5] = 0.2420;
315     y[6] = 0.3521;
316     y[7] = 0.3989;
317     y[14] = 0.0009;
318     y[13] = 0.0044;
319     y[12] = 0.0175;
320     y[11] = 0.0540;
321     y[10] = 0.1295;
322     y[9] = 0.2420;
323     y[8] = 0.3521;
324 
325     double f[15];
326     double t[15];
327     double out = 0.0;
328     for (size_t ii = 0; ii < 15; ii++){
329         t[ii] = (8.0 - (double)(ii+1))/2.0;
330         f[ii] = x[0] * exp( -0.5 * x[1] * pow(t[ii] - x[2],2)) - y[ii];
331         out += f[ii] * f[ii];
332     }
333 
334     if (grad != NULL){
335         grad[0] = 0.0;
336         grad[1] = 0.0;
337         grad[2] = 0.0;
338         for (size_t ii = 0; ii < 15; ii++){
339             grad[0] += 2*f[ii]*exp( -0.5 * x[1] * pow(t[ii] - x[2],2));
340             grad[1] += 2*f[ii]*x[0]*exp( -0.5 * x[1] * pow(t[ii] - x[2],2)) *
341                        -0.5 * pow(t[ii]-x[2],2);
342             grad[2] += 2*f[ii]*x[0]*exp( -0.5 * x[1] * pow(t[ii] - x[2],2)) *
343                        -0.5 * x[1] * (t[ii] - x[2]) * (-1.0);
344         }
345     }
346 
347 
348     return out;
349 }
350 static double f8start[3] = {0.4, 1.0, 0.0};
351 static double f8sol[4] = {0.0,0.0,0.0,1.12793e-8};// confused
352 
353 
354 // Meyer function
ff9(size_t dim,const double * x,double * grad,void * arg)355 double ff9(size_t dim, const double * x, double * grad, void * arg)
356 {
357     (void)(dim);
358     (void)(arg);
359 
360     double y[16] = { 34780.0, 28610.0, 23650.0, 19630.0, 16370.0,
361                      13720.0, 11540.0,  9744.0,  8261.0,  7030.0,
362                       6005.0,  5147.0,  4427.0,  3820.0,  3307.0,
363                       2872.0};
364     double f[16];
365     double t[16];
366     double out = 0.0;
367     for (size_t ii = 0; ii < 16; ii++){
368         t[ii] = 45.0 + 5.0 * ii;
369         f[ii] = x[0] * exp( x[1] / (t[ii] + x[2])) - y[ii];
370         out += f[ii] * f[ii];
371     }
372 
373     if (grad != NULL){
374         grad[0] = 0.0;
375         grad[1] = 0.0;
376         grad[2] = 0.0;
377         for (size_t ii = 0; ii < 16; ii++){
378             grad[0] += 2*f[ii]*exp( x[1] / (t[ii] + x[2]));
379             grad[1] += 2*f[ii]*x[0] * exp( x[1] / (t[ii] + x[2])) *
380                           1.0/(t[ii] + x[2]);
381             grad[2] += 2*f[ii]*x[0] * exp( x[1] / (t[ii] + x[2])) *
382                 -x[1]/pow(t[ii]+x[2],2);
383         }
384     }
385 
386 
387     return out;
388 }
389 static double f9start[3] = {0.02, 4000.0, 250.0};
390 static double f9sol[4]   = {0.0,0.0,0.0,87.9458};// confused
391 
392 // Gulf research and development function
ff10(size_t dim,const double * x,double * grad,void * arg)393 double ff10(size_t dim, const double * x, double * grad, void * arg)
394 {
395     (void)(dim);
396     (void)(arg);
397 
398     double f[100];
399     double t[100];
400     double y[100];
401     double m = 100.0;
402     double out = 0.0;
403     for (size_t ii = 0; ii < 100; ii++){
404         t[ii] = (double)(ii+1)/100.0;
405         y[ii] = 25.0 + pow(-50.0 * log(t[ii]),2.0/3.0);
406         double g = y[ii]*m*(double)(ii+1)*x[1];
407         f[ii] = exp(-1.0/x[0] * pow(fabs(g),x[2]));
408         out += f[ii] * f[ii];
409     }
410 
411     if (grad != NULL){
412         grad[0] = 0.0;
413         grad[1] = 0.0;
414         grad[2] = 0.0;
415         for (size_t ii = 0; ii < 100; ii++){
416             double g = y[ii]*m*(double)(ii+1)*x[1];
417             double preexp = exp(-1.0/x[0] * pow( fabs(g) ,x[2]));
418             grad[0] += 2*f[ii]*preexp * 1.0/pow(x[0],2) * pow(fabs(g),x[2]);
419             double gp = y[ii]*m*(double)(ii+1);
420             grad[1] += 2*f[ii]*preexp * (-1.0/x[0]) * x[2] * g * gp * pow(fabs(g),x[2]-2);
421             grad[2] += 2*f[ii]*preexp * (-1.0/x[0]) * pow(g,x[2]) * log(fabs(g));
422         }
423     }
424 
425     return out;
426 }
427 static double f10start[3] = {5.0, 2.5, 0.15};
428 static double f10sol[4]   = {50.0,25.0,1.50,0.0};
429 
430 // Box three-dimensional
ff11(size_t dim,const double * x,double * grad,void * arg)431 double ff11(size_t dim, const double * x, double * grad, void * arg)
432 {
433     (void)(dim);
434     (void)(arg);
435 
436     double f[20];
437     double t[20];
438     size_t m = 20;
439     double out = 0.0;
440     for (size_t ii = 0; ii < m; ii++){
441         t[ii] = (double)(ii+1)/10.0;
442         f[ii] = exp(-t[ii]*x[0]) - exp(-t[ii]*x[1]) - x[2]*(exp(-t[ii]) - exp(-10.0*t[ii]));
443         out += f[ii] * f[ii];
444     }
445 
446     if (grad != NULL){
447         grad[0] = 0.0;
448         grad[1] = 0.0;
449         grad[2] = 0.0;
450         for (size_t ii = 0; ii < m; ii++){
451             grad[0] += 2*f[ii]*exp(-t[ii]*x[0])*(-t[ii]);
452             grad[1] += 2*f[ii]*exp(-t[ii]*x[1])*(t[ii]);
453             grad[2] += 2*f[ii]*-(exp(-t[ii]) - exp(-10.0*t[ii]));
454         }
455     }
456 
457     return out;
458 }
459 static double f11start[3] = {0.0, 10.0, 20.0};
460 static double f11sol[4]   = {1.0,10.0,1.0,0.0}; // multiple minimum exist
461 
462 // Powell singular function
ff12(size_t dim,const double * x,double * grad,void * arg)463 double ff12(size_t dim, const double * x, double * grad, void * arg)
464 {
465     (void)(dim);
466     (void)(arg);
467 
468     double f[20];
469     double out = 0.0;
470     f[0] = x[0] + 10.0 * x[1];
471     f[1] = pow(5,0.5) * (x[2]-x[3]);
472     f[2] = pow(x[1]-2*x[2],2.0);
473     f[3] = pow(10.0,0.5)*pow(x[0]-x[3],2);
474     out = f[0]*f[0] + f[1]*f[1] + f[2]*f[2] + f[3]*f[3];
475 
476     if (grad != NULL){
477         grad[0] = 2.0 * f[0] + 2.0 * f[3] * pow(10.0,0.5)*2.0 *(x[0]-x[3]);
478         grad[1] = 2.0 * f[0] * 10.0 + 2.0 * f[2] * 2.0 *(x[1] - 2*x[2]);
479         grad[2] = 2.0 * f[1] * pow(5.0,0.5) + 2.0 * f[2] * 2.0 *(x[1] - 2*x[2]) *-2.0;
480 
481         grad[3] = 2.0 * f[1] * pow(5.0,0.5)*-1.0 + 2.0 * f[3] * pow(10.0,0.5)*2.0 *(x[0]-x[3])*-1.0;
482     }
483 
484     return out;
485 }
486 static double f12start[4] = {3.0,-1.0,0.0,1.0};
487 static double f12sol[5]   = {0.0, 0.0, 0.0, 0.0, 0.0};
488 
489 // Wood function
ff13(size_t dim,const double * x,double * grad,void * arg)490 double ff13(size_t dim, const double * x, double * grad, void * arg)
491 {
492     (void)(dim);
493     (void)(arg);
494 
495     double f[20];
496     double out = 0.0;
497 
498     f[0] = 10.0 * (x[1] - pow(x[0],2));
499     f[1] = 1.0-x[0];
500     f[2] = pow(90.0,0.5)*(x[3]-pow(x[2],2));
501     f[3] = 1.0 - x[2];
502     f[4] = pow(10.0,0.5)*(x[1] + x[3] - 2.0);
503     f[5] = pow(10.0,-0.5) * (x[1]-x[3]);
504 
505     out = f[0]*f[0] + f[1]*f[1] + f[2]*f[2] + f[3]*f[3] + f[4]*f[4] + f[5]*f[5];
506 
507     if (grad != NULL){
508         grad[0] = 2.0 * f[0] * 10.0 * -2.0 * x[0] + 2.0 * f[1] * -1.0;
509         grad[1] = 2.0 * f[0] * 10.0  + 2.0 * f[4] * pow(10.0,0.5) + 2.0 * f[5] * pow(10,-0.5);
510         grad[2] = 2.0 * f[2] * pow(90.0,0.5) * -2.0 * x[2] + 2.0 * f[3] * -1.0;
511         grad[3] = 2.0 * f[2] * pow(90.0,0.5)  + 2.0 * f[4] * pow(10.0,0.5) + 2.0 * f[5] * pow(10,-0.5) * -1.0;
512     }
513 
514     /* printf("out=%G\n",out); */
515     return out;
516 }
517 static double f13start[4] = {-3.0,-1.0,-3.0,-1.0};
518 static double f13sol[5]   = {1.0, 1.0, 1.0, 1.0, 0.0};
519 
520 // Kowalic and Osborne function
ff14(size_t dim,const double * x,double * grad,void * arg)521 double ff14(size_t dim, const double * x, double * grad, void * arg)
522 {
523     (void)(dim);
524     (void)(arg);
525 
526     double f[11];
527     double y[11] = {0.1957,0.1947,0.1735,0.1600,0.0844,0.0627,
528                     0.0456,0.0342,0.0323,0.0235,0.0246};
529     double u[11] = {4.0,2.0,1.0,0.5,0.25,0.167,0.125,0.1,0.0833,0.0714,0.0625};
530     size_t m = 11;
531 
532     double out = 0.0;
533     for (size_t ii = 0; ii < m; ii++){
534         f[ii] = y[ii] - x[0]*(pow(u[ii],2) + u[ii]*x[1]) / (pow(u[ii],2) + u[ii]*x[2] + x[3]);
535         out += f[ii]*f[ii];
536     }
537 
538 
539     if (grad != NULL){
540         grad[0] = 0.0;
541         grad[1] = 0.0;
542         grad[2] = 0.0;
543         grad[3] = 0.0;
544         for (size_t ii = 0; ii < m; ii++){
545             grad[0] += 2.0 * f[ii] * (pow(u[ii],2) + u[ii]*x[1]) / (pow(u[ii],2) + u[ii]*x[2] + x[3]) * -1.0;
546             grad[1] += 2.0 * f[ii] * x[0]*u[ii] / (pow(u[ii],2) + u[ii]*x[2] + x[3]) * (-1.0);
547             grad[2] += 2.0 * f[ii] * x[0]*(pow(u[ii],2) + u[ii]*x[1]) / pow(pow(u[ii],2) + u[ii]*x[2] + x[3],2) * u[ii];
548             grad[3] += 2.0 * f[ii] * x[0]*(pow(u[ii],2) + u[ii]*x[1]) / pow(pow(u[ii],2) + u[ii]*x[2] + x[3],2);
549         }
550     }
551 
552     return out;
553 }
554 static double f14start[4] = {0.25,0.39,0.415,0.39};
555 static double f14sol[5]   = {0.0,0.0,0.0,0.0,3.07505e-4}; // unknown minimizer
556 
557 // Brown and Dennis
ff15(size_t dim,const double * x,double * grad,void * arg)558 double ff15(size_t dim, const double * x, double * grad, void * arg)
559 {
560     (void)(dim);
561     (void)(arg);
562 
563     double f[20];
564     double t[20];
565     size_t m = 20;
566 
567     double out = 0.0;
568     for (size_t ii = 0; ii < m; ii++){
569         t[ii] = (double)(ii+1)/5.0;
570         f[ii] = pow(x[0] + t[ii]*x[1] - exp(t[ii]),2) + pow(x[2] + x[3]*sin(t[ii]) - cos(t[ii]),2);
571         out += f[ii]*f[ii];
572     }
573 
574 
575     if (grad != NULL){
576         grad[0] = 0.0;
577         grad[1] = 0.0;
578         grad[2] = 0.0;
579         grad[3] = 0.0;
580         for (size_t ii = 0; ii < m; ii++){
581             grad[0] += 2.0 * f[ii] * 2.0 * (x[0] + t[ii]*x[1] - exp(t[ii]));
582             grad[1] += 2.0 * f[ii] * 2.0 * (x[0] + t[ii]*x[1] - exp(t[ii])) * t[ii];
583             grad[2] += 2.0 * f[ii] * 2.0 * (x[2] + x[3]*sin(t[ii]) - cos(t[ii]));
584             grad[3] += 2.0 * f[ii] * 2.0 * (x[2] + x[3]*sin(t[ii]) - cos(t[ii]))*sin(t[ii]);
585         }
586     }
587 
588     return out;
589 }
590 
591 static double f15start[4] = {25.0,5.0,-5.0,-1.0};
592 static double f15sol[5]   = {0.0,0.0,0.0,0.0,85822.2}; // unknown minimizer
593 
594 // Osborne 1
ff16(size_t dim,const double * x,double * grad,void * arg)595 double ff16(size_t dim, const double * x, double * grad, void * arg)
596 {
597     (void)(dim);
598     (void)(arg);
599 
600     double f[33];
601     double t[33];
602     size_t m = 33;
603 
604     double y[33] = {0.844,0.908,0.932,0.936,0.925,0.908,0.881,0.850,0.818,
605                     0.784,0.751,0.718,0.685,0.658,0.628,0.603,0.580,0.558,
606                     0.538,0.522,0.506,0.490,0.478,0.467,0.457,0.448,0.438,
607                     0.431,0.424,0.420,0.414,0.411,0.406};
608     double out = 0.0;
609     for (size_t ii = 0; ii < m; ii++){
610         t[ii] = (double)ii * 10.0;
611         f[ii] = y[ii] - (x[0] + x[1]*exp(-t[ii]*x[3]) + x[2] * exp(-t[ii]*x[4]));
612         out += f[ii]*f[ii];
613     }
614 
615 
616     if (grad != NULL){
617         grad[0] = 0.0;
618         grad[1] = 0.0;
619         grad[2] = 0.0;
620         grad[3] = 0.0;
621         grad[4] = 0.0;
622         for (size_t ii = 0; ii < m; ii++){
623             grad[0] += 2.0 * f[ii] * -1.0;
624             grad[1] += 2.0 * f[ii] * exp(-t[ii]*x[3])*-1.0;
625             grad[2] += 2.0 * f[ii] * exp(-t[ii]*x[4])*-1.0;
626             grad[3] += 2.0 * f[ii] * x[1] * -t[ii] * exp(-t[ii]*x[3])*-1.0;
627             grad[4] += 2.0 * f[ii] * x[2] * -t[ii] * exp(-t[ii]*x[4])*-1.0;
628         }
629     }
630 
631     return out;
632 }
633 
634 static double f16start[5] = {0.5,1.5,-1.0,0.01,0.02};
635 static double f16sol[6]   = {0.0,0.0,0.0,0.0,0.0,5.46489e-5}; // unknown minimizer
636 
637 // Biggs EXP6
ff17(size_t dim,const double * x,double * grad,void * arg)638 double ff17(size_t dim, const double * x, double * grad, void * arg)
639 {
640     (void)(dim);
641     (void)(arg);
642 
643     double f[13];
644     double y[13];
645     double t[13];
646     size_t m = 13;
647 
648     double out = 0.0;
649     for (size_t ii = 0; ii < m; ii++){
650         t[ii] = (double)(ii+1)/10.0;
651         y[ii] = exp(-t[ii]) - 5.0*exp(-10.0*t[ii]) + 3.0 * exp(-4.0*t[ii]);
652         f[ii] = x[2]*exp(-t[ii]*x[0]) - x[3]*exp(-t[ii]*x[1]) + x[5]*exp(-t[ii]*x[4]) - y[ii];
653         out += f[ii]*f[ii];
654     }
655 
656 
657     if (grad != NULL){
658 
659         grad[0] = 0.0;
660         grad[1] = 0.0;
661         grad[2] = 0.0;
662         grad[3] = 0.0;
663         grad[4] = 0.0;
664         grad[5] = 0.0;
665         for (size_t ii = 0; ii < m; ii++){
666             grad[0] += 2.0 * f[ii] * x[2] * -t[ii] * exp(-t[ii]*x[0]);
667             grad[1] += 2.0 * f[ii] * x[3] * -t[ii] * exp(-t[ii]*x[1])*-1.0;
668             grad[2] += 2.0 * f[ii] * exp(-t[ii]*x[0]);
669             grad[3] += 2.0 * f[ii] * exp(-t[ii]*x[1])*-1.0;
670             grad[4] += 2.0 * f[ii] * x[5] * exp(-t[ii]*x[4]) * -t[ii];
671             grad[5] += 2.0 * f[ii] * exp(-t[ii] * x[4]);
672         }
673     }
674 
675     return out;
676 }
677 
678 static double f17start[6] = {1.0,2.0,1.0,1.0,1.0,1.0};
679 static double f17sol[7]   = {0.0,0.0,0.0,0.0,0.0,0.0,5.65565e-3};
680 
681 // Osborne 2 function
ff18(size_t dim,const double * x,double * grad,void * arg)682 double ff18(size_t dim, const double * x, double * grad, void * arg)
683 {
684     (void)(dim);
685     (void)(arg);
686 
687     double f[65];
688     double y[65] = {1.366,1.191,1.112,1.013,0.991,0.885,0.831,0.847,0.786,0.725,
689                     0.746,0.679,0.608,0.655,0.616,0.606,0.602,0.626,0.651,0.724,
690                     0.649,0.649,0.694,0.644,0.624,0.661,0.612,0.558,0.533,0.495,
691                     0.500,0.423,0.395,0.375,0.372,0.391,0.396,0.405,0.428,0.429,
692                     0.523,0.562,0.607,0.653,0.672,0.708,0.633,0.668,0.645,0.632,
693                     0.591,0.559,0.597,0.625,0.739,0.710,0.729,0.720,0.636,0.581,
694                     0.428,0.292,0.162,0.098,0.054};
695     double t[65];
696     size_t m = 65;
697 
698     double out = 0.0;
699     for (size_t ii = 0; ii < m; ii++){
700         t[ii] = (double)(ii)/10.0;
701         f[ii] = y[ii] - (x[0] * exp(-t[ii]*x[4]) +
702                          x[1]*exp(-pow(t[ii]-x[8],2)*x[5]) +
703                          x[2]*exp(-pow(t[ii]-x[9],2)*x[6]) +
704                          x[3]*exp(-pow(t[ii]-x[10],2)*x[7]));
705         out += f[ii]*f[ii];
706     }
707 
708 
709     if (grad != NULL){
710 
711         for (size_t ii = 0; ii < 11; ii++){
712             grad[ii] = 0.0;
713         }
714 
715         for (size_t ii = 0; ii < m; ii++){
716             grad[0] -= 2.0 * f[ii] * exp(-t[ii]*x[4]);
717             grad[1] -= 2.0 * f[ii] * exp(-pow(t[ii]-x[8],2)*x[5]);
718             grad[2] -= 2.0 * f[ii] * exp(-pow(t[ii]-x[9],2)*x[6]);
719             grad[3] -= 2.0 * f[ii] * exp(-pow(t[ii]-x[10],2)*x[7]);
720             grad[4] -= 2.0 * f[ii] * x[0]*-t[ii]*exp(-t[ii]*x[4]);
721             grad[5] -= 2.0 * f[ii] * x[1]*exp(-pow(t[ii]-x[8],2)*x[5])*-pow(t[ii]-x[8],2);
722             grad[6] -= 2.0 * f[ii] * x[2]*exp(-pow(t[ii]-x[9],2)*x[6])*-pow(t[ii]-x[9],2);
723             grad[7] -= 2.0 * f[ii] * x[3]*exp(-pow(t[ii]-x[10],2)*x[7])*-pow(t[ii]-x[10],2);
724             grad[8] -= 2.0 * f[ii] * x[1]*exp(-pow(t[ii]-x[8],2)*x[5]) * -(t[ii]-x[8])*x[5] * -1.0;
725             grad[9] -= 2.0 * f[ii] * x[2]*exp(-pow(t[ii]-x[9],2)*x[6]) * -(t[ii]-x[9])*x[6] * -1.0;
726             grad[10] -= 2.0 * f[ii] * x[3]*exp(-pow(t[ii]-x[10],2)*x[7]) * -(t[ii]-x[10])*x[7] * -1.0;
727         }
728     }
729 
730     return out;
731 }
732 
733 static double f18start[11] = {1.3,0.65,0.65,0.7,0.6,3.0,5.0,7.0,2.0,4.5,5.5};
734 static double f18sol[12]   = {0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,4.01377e-2};
735 
736 // Watson function
ff19(size_t dim,const double * x,double * grad,void * arg)737 double ff19(size_t dim, const double * x, double * grad, void * arg)
738 {
739     (void)(dim);
740     (void)(arg);
741 
742     double f[31];
743     double t[31];
744     double summer[29];
745     size_t d = 9;
746 
747     double out = 0.0;
748     for (size_t ii = 0; ii < 29; ii++){
749         t[ii] = (double)(ii+1)/29.0;
750         f[ii] = 0.0;
751         for (size_t jj=2; jj < d+1;jj++){
752             f[ii] += (double)(jj-1)*x[jj-1] * pow(t[ii],jj-2);
753         }
754         summer[ii] = 0.0;
755         for (size_t jj = 1; jj < d+1; jj++){
756             summer[ii] += x[jj-1]*pow(t[ii],jj-1);
757         }
758         f[ii] -= pow(summer[ii],2);
759         f[ii] -= 1.0;
760         out += f[ii]*f[ii];
761     }
762     f[29] = x[0];
763     f[30] = x[1] - pow(x[0],2) - 1.0;
764     out += f[29]*f[29] + f[30]*f[30];
765 
766     if (grad != NULL){
767 
768         for (size_t ii = 0; ii < d; ii++){
769             grad[ii] = 0.0;
770         }
771 
772         for (size_t jj = 2; jj < d+1; jj++){
773             for (size_t ii = 0; ii < 29; ii++){
774                 grad[jj-1] += 2*f[ii]*(double)(jj-1) * pow(t[ii],jj-2);
775             }
776         }
777         for (size_t jj = 1; jj < d+1; jj++){
778             for (size_t ii = 0; ii < 29; ii++){
779                 grad[jj-1] -= 2*f[ii]*2 * summer[ii] * pow(t[ii],jj-1);
780             }
781         }
782         grad[0] += 2.0*f[29];
783         grad[0] -= 2.0*f[30]*2.0*x[0];
784         grad[1] += 2.0*f[30];
785     }
786 
787     return out;
788 }
789 
790 static double f19start[12] = {0.0,0.0,0.0,0.0,0.0,0.0,
791                               0.0,0.0,0.0,0.0,0.0,0.0};
792 static double f19sol[10]   = {0.0,0.0,0.0,
793                               0.0,0.0,0.0,0.0,0.0,0.0,1.39976e-6}; // minimizer unknown
794 
795 // Extended Rosenbrock function
ff20(size_t dim,const double * x,double * grad,void * arg)796 double ff20(size_t dim, const double * x, double * grad, void * arg)
797 {
798     (void)(dim);
799     (void)(arg);
800 
801     size_t m = 30;
802     double out = 0.0;
803     for (size_t ii = 1; ii <= 15; ii++){
804         double f1 = 10.0 * (x[2*ii-1] - pow(x[2*ii-2],2));
805         double f2 = 1.0 - x[2*ii-2];
806         out += f1*f1 + f2*f2;
807     }
808     if (grad != NULL){
809 
810         for (size_t ii = 0; ii < m; ii = ii+1){
811             grad[ii] = 0.0;
812         }
813         for (size_t ii = 1; ii <= 15; ii++){
814             grad[2*ii-2] += 2.0*(1.0 - x[2*ii-2]) * -1.0;
815             grad[2*ii-2] += 2.0 * 10.0 * (x[2*ii-1] - pow(x[2*ii-2],2)) * -10.0 * 2.0 * x[2*ii-2];
816             grad[2*ii-1] += 2.0 * 10.0 * (x[2*ii-1] - pow(x[2*ii-2],2))*10.0;
817         }
818 
819     }
820 
821     return out;
822 }
823 
824 // specified below
825 static double f20start[30];
826 static double f20sol[31];
827 
828 // Extended Powell singular function
ff21(size_t dim,const double * x,double * grad,void * arg)829 double ff21(size_t dim, const double * x, double * grad, void * arg)
830 {
831     (void)(dim);
832     (void)(arg);
833 
834     size_t m = 400;
835     double out = 0.0;
836     for (size_t ii = 1; ii <= m/4; ii++){
837         double f1 = x[4*ii-4] + 10.0*x[4*ii-3];
838         double f2 = pow(5.0,0.5)*(x[4*ii-2] - x[4*ii-1]);
839         double f3 = pow(x[4*ii-3]-2.0*x[4*ii-2],2);
840         double f4 = pow(10.0,0.5)*pow(x[4*ii-4] - x[4*ii-1],2);
841         out += f1*f1 + f2*f2 + f3*f3 + f4*f4;
842     }
843     if (grad != NULL){
844 
845         for (size_t ii = 0; ii < m; ii = ii+1){
846             grad[ii] = 0.0;
847         }
848         for (size_t ii = 1; ii <= m/4; ii++){
849             double f1 = x[4*ii-4] + 10.0*x[4*ii-3];
850             double f2 = pow(5.0,0.5)*(x[4*ii-2] - x[4*ii-1]);
851             double f3 = pow(x[4*ii-3]-2.0*x[4*ii-2],2);
852             double f4 = pow(10.0,0.5)*pow(x[4*ii-4] - x[4*ii-1],2);
853 
854             grad[4*ii-4] += 2.0*f1 + 2.0*f4 * 2.0*pow(10.0,0.5) *(x[4*ii-4] - x[4*ii-1]);
855             grad[4*ii-3] += 2.0*f1*10.0 + 2.0 * f3 * (x[4*ii-3]-2.0*x[4*ii-2])*2.0;
856             grad[4*ii-2] += 2.0*f2* pow(5.0,0.5) + 2.0*f3*2.0*(x[4*ii-3]-2.0*x[4*ii-2])*-2.0;
857             grad[4*ii-1] += 2.0*f2* pow(5.0,0.5)*-1 + 2.0*f4*pow(10.0,0.5)*-2.0*(x[4*ii-4] - x[4*ii-1]);
858         }
859 
860     }
861 
862     return out;
863 }
864 
865 // specified below
866 static double f21start[400];
867 static double f21sol[401];
868 
869 // Penalty I
ff22(size_t dim,const double * x,double * grad,void * arg)870 double ff22(size_t dim, const double * x, double * grad, void * arg)
871 {
872     (void)(dim);
873     (void)(arg);
874 
875     size_t d = 4;
876     double f[11];
877     double out = 0.0;
878 
879     double a = 1e-5;
880     for (size_t ii = 0; ii < d; ii++){
881         f[ii] = sqrt(a)*(x[ii]-1);
882         out += f[ii]*f[ii];
883     }
884     f[d] = 0.0;
885     for (size_t ii = 0; ii < d; ii++){
886         f[d] += pow(x[ii],2);
887     }
888     f[d] -= 0.25;
889     out += f[d]*f[d];
890 
891     if (grad != NULL){
892 
893         for (size_t ii = 0; ii < d; ii++){
894             grad[ii] = 2*f[ii]*sqrt(a) + 2.0 * f[d] * x[ii]*2.0;
895         }
896 
897     }
898 
899     return out;
900 }
901 
902 /* static double f22start[10] = {1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0}; */
903 /* static double f22sol[11]   = {0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,7.08765e-5}; */
904 static double f22start[4] = {1.0,2.0,3.0,4.0};
905 static double f22sol[5]   = {0.0,0.0,0.0,0.0,2.24997e-5};
906 
907 // Penalty II (DOESNT WORK)
ff23(size_t dim,const double * x,double * grad,void * arg)908 double ff23(size_t dim, const double * x, double * grad, void * arg)
909 {
910     (void)(dim);
911     (void)(arg);
912 
913     size_t d = 4;
914     double f[8] = {0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0};
915     double y[8];
916     double out = 0.0;
917 
918     double a = 1e-5;
919     /* double a = 1e-1; */
920 
921     f[0] = x[0]-0.2;
922     out += f[0]*f[0];
923     for (size_t ii = 1; ii < d; ii++){
924         y[ii] = exp((double)(ii+1)/10.0) + exp((double)(ii)/10.0);
925         f[ii] = pow(a,0.5)*(exp(x[ii]/10.0) + exp(x[ii-1]/10.0) - y[ii]);
926         out += f[ii]*f[ii];
927     }
928 
929     for (size_t ii = 4; ii < 7; ii++){
930     /* for (size_t ii = 4; ii < 5; ii++){ */
931         f[ii] += pow(a,0.5)*(exp(x[ii-d+1]/10.0) - exp(-1.0/10.0));
932         out += f[ii]*f[ii];
933     }
934 
935     f[7] = -1.0;
936     for (size_t jj = 0; jj < d; jj++){
937         f[2*d-1] += (double)(d-jj)*pow(x[jj],2);
938     }
939     out += f[2*d-1]*f[2*d-1];
940 
941     if (grad != NULL){
942 
943         for (size_t ii = 0; ii < d; ii++){
944             grad[ii] = 0.0;
945         }
946         grad[0] += 2.0*f[0];
947         for (size_t ii = 1; ii < d; ii++){
948             grad[ii]   += 2.0*f[ii]*sqrt(a)*exp(x[ii]/10.0)/10.0;
949             grad[ii-1] += 2.0*f[ii]*sqrt(a)*exp(x[ii-1]/10.0)/10.0;
950         }
951 
952         for (size_t ii = d; ii < 2*d-1; ii++){
953         /* for (size_t ii = 4; ii < 5; ii++){ */
954             grad[ii-d] += 2.0*f[ii]*pow(a,0.5)*exp(x[ii-d+1]/10.0)/10.0;
955         }
956 
957         for (size_t jj = 0; jj < d; jj++){
958             grad[jj] += 2.0 * f[2*d-1] * (double)(d-jj)*2.0*x[jj];
959         }
960     }
961 
962     return out;
963 }
964 
965 static double f23start[4] = {0.5,0.5,0.5,0.5};
966 static double f23sol[5]   = {0.0,0.0,0.0,0.0,9.37629e-6};
967 
968 
969 ///////////////////////////////////////////////////////////////////////////
970 //assign problems
971 
972 struct UncTestProblem tprobs[34];
create_unc_probs()973 void create_unc_probs(){
974 
975     tprobs[0].dim = 2;
976     tprobs[0].eval = rosen_brock_func;
977     tprobs[0].start = rosen_brock_start;
978     tprobs[0].sol = rosen_brock_sol;
979 
980     tprobs[1].dim   = 2;
981     tprobs[1].eval  = f1;
982     tprobs[1].start = f1start;
983     tprobs[1].sol   = f1sol;
984 
985     tprobs[2].dim   = 2;
986     tprobs[2].eval  = f2;
987     tprobs[2].start = f2start;
988     tprobs[2].sol   = f2sol;
989 
990     tprobs[3].dim   = 2;
991     tprobs[3].eval  = ff3;
992     tprobs[3].start = f3start;
993     tprobs[3].sol   = f3sol;
994 
995     tprobs[4].dim   = 2;
996     tprobs[4].eval  = ff4;
997     tprobs[4].start = f4start;
998     tprobs[4].sol   = f4sol;
999 
1000     tprobs[5].dim   = 2;
1001     tprobs[5].eval  = ff5;
1002     tprobs[5].start = f5start;
1003     tprobs[5].sol   = f5sol;
1004 
1005     tprobs[6].dim   = 3;
1006     tprobs[6].eval  = ff6;
1007     tprobs[6].start = f6start;
1008     tprobs[6].sol   = f6sol;
1009 
1010     tprobs[7].dim   = 3;
1011     tprobs[7].eval  = ff7;
1012     tprobs[7].start = f7start;
1013     tprobs[7].sol   = f7sol;
1014 
1015     tprobs[8].dim   = 3;
1016     tprobs[8].eval  = ff8;
1017     tprobs[8].start = f8start;
1018     tprobs[8].sol   = f8sol;
1019 
1020     tprobs[9].dim   = 3;
1021     tprobs[9].eval  = ff9;
1022     tprobs[9].start = f9start;
1023     tprobs[9].sol   = f9sol;
1024 
1025     tprobs[10].dim   = 3;
1026     tprobs[10].eval  = ff10;
1027     tprobs[10].start = f10start;
1028     tprobs[10].sol   = f10sol;
1029 
1030     tprobs[11].dim   = 3;
1031     tprobs[11].eval  = ff11;
1032     tprobs[11].start = f11start;
1033     tprobs[11].sol   = f11sol;
1034 
1035     tprobs[12].dim   = 4;
1036     tprobs[12].eval  = ff12;
1037     tprobs[12].start = f12start;
1038     tprobs[12].sol   = f12sol;
1039 
1040     tprobs[13].dim   = 4;
1041     tprobs[13].eval  = ff13;
1042     tprobs[13].start = f13start;
1043     tprobs[13].sol   = f13sol;
1044 
1045     tprobs[14].dim   = 4;
1046     tprobs[14].eval  = ff14;
1047     tprobs[14].start = f14start;
1048     tprobs[14].sol   = f14sol;
1049 
1050     tprobs[15].dim   = 4;
1051     tprobs[15].eval  = ff15;
1052     tprobs[15].start = f15start;
1053     tprobs[15].sol   = f15sol;
1054 
1055     tprobs[16].dim   = 5;
1056     tprobs[16].eval  = ff16;
1057     tprobs[16].start = f16start;
1058     tprobs[16].sol   = f16sol;
1059 
1060     tprobs[17].dim   = 6;
1061     tprobs[17].eval  = ff17;
1062     tprobs[17].start = f17start;
1063     tprobs[17].sol   = f17sol;
1064 
1065     tprobs[18].dim   = 11;
1066     tprobs[18].eval  = ff18;
1067     tprobs[18].start = f18start;
1068     tprobs[18].sol   = f18sol;
1069 
1070     tprobs[19].dim   = 9;
1071     tprobs[19].eval  = ff19;
1072     tprobs[19].start = f19start;
1073     tprobs[19].sol   = f19sol;
1074 
1075     for (size_t ii = 0; ii < 15; ii++){
1076         f20start[2*ii] = -1.2;
1077         f20start[2*ii+1] = 1;
1078         f20sol[2*ii] = 1.0;
1079         f20sol[2*ii+1] = 1.0;
1080     }
1081     f20sol[30] = 0.0;
1082 
1083     tprobs[20].dim   = 30;
1084     tprobs[20].eval  = ff20;
1085     tprobs[20].start = f20start;
1086     tprobs[20].sol   = f20sol;
1087 
1088     for (size_t ii = 1; ii <= 100; ii++){
1089         f21start[4*ii-4] = 3.0;
1090         f21start[4*ii-3] = -1.0;
1091         f21start[4*ii-2] = 0.0;
1092         f21start[4*ii-1] = 1.0;
1093     }
1094     for (size_t ii = 0; ii < 400; ii++ ){
1095         f21sol[ii] = 0.0;
1096     }
1097     f21sol[400] = 0.0;
1098 
1099     tprobs[21].dim   = 400;
1100     tprobs[21].eval  = ff21;
1101     tprobs[21].start = f21start;
1102     tprobs[21].sol   = f21sol;
1103 
1104     tprobs[22].dim   = 4;
1105     tprobs[22].eval  = ff22;
1106     tprobs[22].start = f22start;
1107     tprobs[22].sol   = f22sol;
1108 
1109     tprobs[23].dim   = 4;
1110     tprobs[23].eval  = ff23;
1111     tprobs[23].start = f23start;
1112     tprobs[23].sol   = f23sol;
1113 
1114 }
1115 
1116 
1117 // other functions
unc_test_problem_get_dim(void * arg)1118 size_t unc_test_problem_get_dim(void * arg)
1119 {
1120     struct UncTestProblem * p = arg;
1121     return p->dim;
1122 }
1123 
unc_test_problem_get_start(void * arg)1124 double * unc_test_problem_get_start(void * arg)
1125 {
1126     struct UncTestProblem * p = arg;
1127     return p->start;
1128 }
1129 
unc_test_problem_get_sol(void * arg)1130 double * unc_test_problem_get_sol(void * arg)
1131 {
1132     struct UncTestProblem * p = arg;
1133     return p->sol;
1134 }
1135 
unc_test_problem_eval(size_t dim,const double * x,double * grad,void * arg)1136 double unc_test_problem_eval(size_t dim, const double * x,double * grad,void *arg)
1137 {
1138     struct UncTestProblem * p = arg;
1139 
1140     return p->eval(dim,x,grad,arg);
1141 }
1142 
1143 
1144 
1145 
1146 
1147