Xmipp  v3.23.11-Nereus
ObjectiveFunction.cpp
Go to the documentation of this file.
1 /*
2 
3 CONDOR 1.06 - COnstrained, Non-linear, Direct, parallel Optimization
4  using trust Region method for high-computing load,
5  noisy functions
6 Copyright (C) 2004 Frank Vanden Berghen
7 
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation version 2
11 of the License.
12 
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 
22 If you want to include this tools in any commercial product,
23 you can contact the author at fvandenb@iridia.ulb.ac.be
24 
25 */
26 
27 #ifdef WIN32
28 //#include <windows.h>
29 #else
30 #include <unistd.h>
31 #endif
32 
33 #include <string.h>
34 #include "ObjectiveFunction.h"
35 #include "tools.h"
36 
37 void ObjectiveFunction::saveStats(char *resultsFile, Vector vG, Matrix mH, Vector vLambda)
38 {
39  FILE *ff=fopen(resultsFile,"w");
40  fprintf(ff,";dimension of search-space, total NFE, NFE before best point found, value OF at solution\n"
41  "%i\t%i\t(%i)\t%e\n"
42  ";Solution vector\n", dim(), nfe, nfe2, valueBest);
43  xBest.save(ff,2);
44  fprintf(ff,";Hessian matrix at the solution\n");
45  mH.save(ff,3);
46  fprintf(ff,";Gradient vector at the solution (should be zero if no active constraints)\n");
47  vG.save(ff,2);
48  if (isConstrained)
49  {
50  fprintf(ff,";Lagrangian Vector at the solution (lower,upper,linear,non-linear)\n");
51  vLambda.save(ff,2);
52  }
53  fprintf(ff,"\n");
54  fclose(ff);
55 }
56 
58 {
59  if (vx==Vector::emptyVector) return 1;
60  if (!isConstrained) return 1;
61  int i, dim=vx.sz(), nerror;
62  char feasible=1;
63  double *bbl=bl, *bbu=bu, *x=vx, t;
64 
65  if (d) *d=0.0;
66  initTolLC(vx);
67 
68  for (i=0; i<dim; i++)
69  if ((t=bbl[i]-x[i])>tolLC)
70  { if (d) *d=mmax(*d,t); else return 0; feasible=0; }
71 
72  for (i=0; i<dim; i++)
73  if ((t=x[i]-bbu[i])>tolLC)
74  { if (d) *d=mmax(*d,t); else return 0; feasible=0; }
75 
76  for (i=0; i<A.nLine(); i++)
77  if ((t=b[i]-A.scalarProduct(i,vx))>tolLC)
78  { if (d) *d=mmax(*d,t); else return 0; feasible=0; }
79 
80  for (i=0; i<nNLConstraints; i++)
81  if ((t=-evalNLConstraint(i,vx,&nerror))>tolNLC )
82  { if (d) *d=mmax(*d,t); else return 0; feasible=0; }
83 
84 // printf("");
85  return feasible;
86 }
87 
89  // init linear tolerances and init variable "isConstrained"
90 {
91  int i,mdim=dim();
92  double *bbl=bl, *bbu=bu;
93 
94  isConstrained=0;
95  for (i=0; i<mdim; i++)
96  {
97  if (bbl[i]>-INF) {isConstrained=1; maxNormLC=mmax(maxNormLC, condorAbs(bbl[i])); }
98  if (bbu[i]< INF) {isConstrained=1; maxNormLC=mmax(maxNormLC, condorAbs(bbu[i])); }
99  }
100  if (b.sz()) { isConstrained=1; maxNormLC=mmax(maxNormLC,b.LnftyNorm()); }
101  tolLC=(1.0+maxNormLC)*tolRelFeasibilityForLC*(mdim*2+A.nLine());
102 
104 }
105 
107 {
108  if (!isConstrained) return;
109  int i;
110  double *ofb=b;
111 
112  for (i=0; i<A.nLine(); i++)
113  maxNormLC=mmax(maxNormLC, condorAbs(ofb[i]-A.scalarProduct(i,vX)));
114 
115  tolLC=(1.0+maxNormLC)*tolRelFeasibilityForLC*(dim()*2+A.nLine());
116 }
117 
119 {
120  int i;
121 
122  for (i=0; i<nNLConstraints; i++) maxNormNLC=mmax(maxNormNLC,condorAbs(c[i]));
123  if (delta<INF) maxNormNLC=mmax(maxNormNLC,delta*delta);
124 
125  tolNLC=(1.0+maxNormNLC)*tolRelFeasibilityForNLC*nNLConstraints;
126 }
127 
128 void ObjectiveFunction::updateCounter(double df, Vector vX, int nerror)
129 {
130  nfe++;
131  if ((dfold==INF)&&(nerror==0)) { dfref=(1+condorAbs(df))*1e-8; dfold=df; nfe2=nfe; return; }
132  if (dfold-df<dfref) return;
133  if (!isFeasible(vX)) return;
134 
135  if (nerror==0)
136  {
137  nfe2=nfe;
138  dfold=df;
139  }
140 }
141 
143 {
144  char buffer[300];
145  if (saveFileName) free(saveFileName);
146  if (s==NULL)
147  {
148  strcpy(buffer,name); strcat(buffer,".dat"); s=buffer;
149  }
150  saveFileName=(char*)malloc(strlen(s)+1);
151  strcpy(saveFileName,s);
152 }
153 
155 {
156  char *p=s+strlen(s)-1;
157  while ((*p!='.')&&(p!=s)) p--;
158  if (p==s) { strncpy(name,s, 8); name[8]=0; return; }
159  *p='\0';
160  while ((*p!='\\')&&(*p!='/')&&(p!=s)) p--;
161  if (p==s) { strncpy(name,s, 8); name[8]=0; return; }
162  p++;
163  strncpy(name,p, 8); name[8]=0;
164 }
165 
167 {
168  printf("\n\nProblem Name: %s\n",name);
169  printf("Dimension of the search space: %i\n",dim());
170  printf("best (lowest) value found: %e\n", valueBest+objectiveConst);
171  printf("Number of function Evaluation: %i (%i)\n",nfe,nfe2);
172  if (xOptimal.sz())
173  {
174  printf("Lnfty distance to the optimum: %e\n", xBest.LnftyDistance(xOptimal));
175  // printf("Euclidian distance to the optimum: %e\n", xBest.euclidianDistance(xOptimal));
176  }
177  int idim=xBest.sz(),j=0;
178  if (idim<20)
179  {
180  double *dd=xBest;
181  printf("Solution Vector is : \n[%e",dd[0]);
182  for (j=1; j<idim; j++) printf(", %e",dd[j]);
183  printf("]\n"); j=0;
184  }
185  if ((cc==0)||(!isConstrained)) return;
186  double *dbl=bl,*dbu=bu;
187  while (idim--)
188  {
189  if (*(dbl++)>-INF) j++;
190  if (*(dbu++)< INF) j++;
191  }
192  printf("number of box constraints:%i\n"
193  "number of linear constraints:%i\n"
194  "number of non-linear constraints:%i\n",j,A.nLine(),nNLConstraints);
195 
196 }
197 
198 void ObjectiveFunction::saveValue(Vector tmp,double valueOF, int nerror)
199 {
200  int nl=data.nLine(), mdim=tmp.sz();
201  data.setNColumn(mdim+2);
202  data.append(tmp);
203  ((double**)data)[nl][mdim]=valueOF;
204  ((double**)data)[nl][mdim+1]=nerror;
205  if (saveFileName) data.updateSave(saveFileName);
206 }
207 
209 {
210  int n=xStart.sz();
211  if (n>0) return n;
212  return data.nColumn()-2;
213 }
214 
215 #ifdef NO_OPTIMIZER
216 void projectionIntoFeasibleSpace(Vector vFrom, Vector vBase, ObjectiveFunction *of) { vBase=vFrom.clone(); }
217 #else
219 #endif
220 
221 void ObjectiveFunction::addClosestFeasiblePointInData(Vector vX)
222 {
223  double v;
224  int nerror=0;
225  // closest feasible point from vX
226  if (isFeasible(vX))
227  {
228  v=eval(vX,&nerror);
229  if (nerror)
230  {
231  printf("Evaluation of the Obj. Funct. at the starting point as failed.\n");
232  exit(255);
233  }
234  saveValue(vX, v, 0);
235  data.swapLines(0,data.nLine()-1);
236  return;
237  }
238 
239  double best;
240  Vector b(vX.sz());
242  if (!isFeasible(b,&best))
243  {
244  printf("unable to start (violation=%e).\n",best);
245  }
246  v=eval(b,&nerror);
247  if (nerror)
248  {
249  printf("Unable to start.\n"
250  "Evaluation of the Obj. Funct. at the feasible starting point as failed.\n"
251  "Feasible starting point is:\n");
252  b.print();
253  exit(255);
254  }
255  saveValue(b,v,0);
256  data.swapLines(0,data.nLine()-1);
257 }
258 
260 {
261  if (data.nLine()==0)
262  {
263  initTolLC(xStart);
264  addClosestFeasiblePointInData(xStart);
265  return;
266  }
267 
268  if (startPointIsGiven)
269  {
270  int i=data.lineIndex(xStart);
271  if (i!=-1)
272  {
273  data.swapLines(0,i);
274  return;
275  }
276  initTolLC(xStart);
277  addClosestFeasiblePointInData(xStart);
278  return;
279  }
280 
281  // find THE best point in the datas.
282  int mdim=dim();
283  Vector r(mdim);
284  data.getLine(0,r,mdim);
285  initTolLC(r);
286 
287  int k=-1,j,i=data.nLine();
288  double v,best=INF,best2=INF;
289  while (i--)
290  {
291  if (((double**)data)[i][mdim+1]) continue;
292  v=((double**)data)[i][mdim];
293  if (v<best2) { j=i; best2=v; }
294  if (!isConstrained) continue;
295  data.getLine(i,r,mdim);
296  if (isFeasible(r)&&(v<best)) { k=i; best=v; }
297  }
298 
299  if (!isConstrained)
300  {
301  data.swapLines(0,j);
302  return;
303  }
304 
305  if (k!=-1)
306  {
307  data.swapLines(0,k);
308  return;
309  }
310 
311  data.getLine(j,r,mdim);
312  addClosestFeasiblePointInData(r);
313 }
314 
316 {
317  int dim=this->dim();
318  bl.setSize(dim);
319  bu.setSize(dim);
320  double *dbl=bl,*dbu=bu;
321  while (dim--)
322  {
323  *(dbl++)=-INF;
324  *(dbu++)=INF;
325  }
326 }
327 
329 {
330  Vector R(dim());
331  evalGradNLConstraint(j, v, R, nerror);
332  return R;
333 }
334 
335 
336 void CorrectScaleOF::saveValue(Vector X,double valueOF, int nerror)
337 {
338  int i=dim();
339  double *x=X, *xr=xTemp, *re=rescaling;
340  while (i--) xr[i]=re[i]*x[i];
341  of->saveValue(xTemp,valueOF, nerror);
342  ObjectiveFunction::saveValue(X,valueOF, nerror);
343 }
344 
345 double CorrectScaleOF::eval(Vector X, int *nerror)
346 {
347  int i=dim();
348  double *x=X, *xr=xTemp, *re=rescaling;
349  while (i--) xr[i]=re[i]*x[i];
350  double r=of->eval(xTemp,nerror);
351  updateCounter(r,X,*nerror);
352  return r;
353 }
354 
355 double CorrectScaleOF::evalNLConstraint(int j, Vector X, int *nerror)
356 {
357  int i=dim();
358  double *x=X, *xr=xTemp, *re=rescaling;
359  while (i--) xr[i]=re[i]*x[i];
360  return of->evalNLConstraint(j,xTemp,nerror);
361 }
362 
363 void CorrectScaleOF::evalGradNLConstraint(int j, Vector X, Vector result, int *nerror)
364 {
365  int i=dim();
366  double *x=X, *xr=xTemp, *re=rescaling;
367  while (i--) xr[i]=re[i]*x[i];
368  of->evalGradNLConstraint(j,xTemp,result,nerror);
369 }
370 
372  of(_of)
373 {
374  t=_t;
375 
376  int i=of->dim();
377  rescaling.setSize(i);
378  double *xs=of->xStart,*r=rescaling;
379  while (i--) r[i]=condorAbs(xs[i])+1.0;
380 
381  if (of->isConstrained)
382  {
383  double *bl=of->bl, *bu=of->bu;
384  r=rescaling; i=of->dim();
385  while (i--)
386  {
387  if ((bl[i]>-INF)&&(bu[i]<INF)) { r[i]=bu[i]-bl[i]; continue; }
388  if ((r[i]==0.0 )&&(bu[i]<INF)) { r[i]=bu[i]; continue; }
389  if (r[i]==0.0) r[i]=1.0;
390  }
391  }
392  init();
393 }
394 
396  rescaling(_rescaling), of(_of)
397 {
398  t=_t;
399  if ((int)_rescaling.sz()!=_of->dim())
400  {
401  printf("Error in rescaling vector: dimension do not agree.\n");
402  exit(254);
403  }
404  init();
405 }
406 
407 void CorrectScaleOF::init()
408 {
409  double *xos=of->xOptimal, *xss=of->xStart, *xod, *xsd,
410  *r=rescaling, **datas=of->data, **datad,
411  *bls=of->bl, *bus=of->bu, *bld, *bud, **as=of->A, **ad;
412  int n=of->dim(), i=n,j;
413  strcpy(name,"SCALING");
414 
415  xTemp.setSize(n);
416  xOptimal.setSize(n); xod=xOptimal;
417  xStart.setSize(n); xsd=xStart;
418  data.setSize(of->data.nLine(),n+2); datad=data;
419 
420  while(i--)
421  {
422  if (xos) xod[i]=xos[i]/r[i];
423  xsd[i]=xss[i]/r[i];
424  j=data.nLine();
425  while (j--) datad[j][i]=datas[j][i]/r[i];
426  }
427  j=data.nLine();
428  while (j--) { datad[j][n]=datas[j][n]; datad[j][n+1]=datas[j][n+1]; }
429 
435 
436  if (of->isConstrained==0) { isConstrained=0; return; }
437 
438  // there are (box&linear) constraints: scale them !
441  bl.setSize(n); bld=bl;
442  bu.setSize(n); bud=bu;
443  A.setSize(of->A.nLine(),n); ad=A;
444  b=of->b;
445 
446  i=n;
447  while(i--)
448  {
449  bld[i]=bls[i]/r[i];
450  bud[i]=bus[i]/r[i];
451  j=A.nLine();
452  while (j--) ad[j][i]=as[j][i]*r[i];
453  }
454 }
455 
457 {
458  of->xBest.copyFrom(xBest);
460 
461  of->valueBest=valueBest;
462 
463  // rescale vG,mH,vLambda
465 
469  vLambda.oneByOneMutiply(rescaling);
470  of->finalize(vG,mH,vLambda);
471 }
472 
473 /*
474 #ifdef __INCLUDE_SIF__
475 
476 #include "sif/SIFFunction.h"
477 
478 // extern elfunType elfunPARKCH_; extern groupType groupPARKCH_;
479 extern elfunType elfunAkiva_; extern groupType groupAkiva_;
480 extern elfunType elfunRosen_; extern groupType groupRosen_;
481 extern elfunType elfunALLINITU_; extern groupType groupALLINITU_;
482 extern elfunType elfunSTRATEC_; extern groupType groupSTRATEC_;
483 extern elfunType elfunTOINTGOR_; extern groupType groupTOINTGOR_;
484 extern elfunType elfunTOINTPSP_; extern groupType groupTOINTPSP_;
485 extern elfunType elfun3PK_; extern groupType group3PK_;
486 extern elfunType elfunBIGGS6_; extern groupType groupBIGGS6_;
487 extern elfunType elfunBROWNDEN_; extern groupType groupBROWNDEN_;
488 extern elfunType elfunDECONVU_; extern groupType groupDECONVU_;
489 extern elfunType elfunHEART_; extern groupType groupHEART_;
490 extern elfunType elfunOSBORNEB_; extern groupType groupOSBORNEB_;
491 extern elfunType elfunVIBRBEAM_; extern groupType groupVIBRBEAM_;
492 extern elfunType elfunKOWOSB_; extern groupType groupKOWOSB_;
493 extern elfunType elfunHELIX_; extern groupType groupHELIX_;
494 
495 extern elfunType elfunCRAGGLVY_; extern groupType groupCRAGGLVY_;
496 extern elfunType elfunEIGENALS_; extern groupType groupEIGENALS_;
497 extern elfunType elfunHAIRY_; extern groupType groupHAIRY_;
498 extern elfunType elfunPFIT1LS_; extern groupType groupPFIT1LS_;
499 extern elfunType elfunVARDIM_; extern groupType groupVARDIM_;
500 extern elfunType elfunMANCINO_; extern groupType groupMANCINO_;
501 extern elfunType elfunPOWER_; extern groupType groupPOWER_;
502 extern elfunType elfunHATFLDE_; extern groupType groupHATFLDE_;
503 extern elfunType elfunWATSON_; extern groupType groupWATSON_;
504 extern elfunType elfunFMINSURF_; extern groupType groupFMINSURF_;
505 extern elfunType elfunDIXMAANK_; extern groupType groupDIXMAANK_;
506 extern elfunType elfunMOREBV_; extern groupType groupMOREBV_;
507 extern elfunType elfunBRYBND_; extern groupType groupBRYBND_;
508 extern elfunType elfunSCHMVETT_; extern groupType groupSCHMVETT_;
509 extern elfunType elfunHEART6LS_; extern groupType groupHEART6LS_;
510 extern elfunType elfunBROWNAL_; extern groupType groupBROWNAL_;
511 extern elfunType elfunDQDRTIC_; extern groupType groupDQDRTIC_;
512 extern elfunType elfunGROWTHLS_; extern groupType groupGROWTHLS_;
513 extern elfunType elfunSISSER_; extern groupType groupSISSER_;
514 extern elfunType elfunCLIFF_; extern groupType groupCLIFF_;
515 extern elfunType elfunGULF_; extern groupType groupGULF_;
516 extern elfunType elfunSNAIL_; extern groupType groupSNAIL_;
517 extern elfunType elfunHART6_; extern groupType groupHART6_;
518 
519 #endif
520 
521 #ifdef __INCLUDE_AMPL__
522 #include "ampl/AMPLof.h"
523 #endif
524 
525 #include "simpleObjFunctions.h"
526 
527 ObjectiveFunction *getObjectiveFunction(int i, double *rho)
528 {
529  int n=2;
530  ObjectiveFunction *of=NULL;
531  double rhoEnd=-1;
532 
533  switch (i)
534  {
535  // first choice: internally coded functions:
536  case 1: of=new Rosenbrock(i); break; // n=2;
537  case 2: of=new BADScaleRosenbrock(i); break; // n=2;
538  case 3: of=new FletcherTest(i); break; // n=2;
539  case 4: of=new SuperSimpleConstrainedObjectiveFunction(i); break; //n=2;
540  case 5: of=new FletcherTest2(i); break; // n=3;
541  case 6: of=new NoisyRosenbrock(i); break; //n=2;
542  case 7: of=new NoisyQuadratic(i); break; //n=2;
543  case 8: of=new SimpleQuadratic(i); break; //n=2;
544 // second choice: create new random objective function
545  case 20: of=new RandomOF(i+1,n); ((RandomOF *)of)->save("test.dat"); break;
546 
547  // third choice : reload from disk previous random objective function
548  case 21: of=new RandomOF(i,"test.dat"); break;
549 
550 #ifdef __INCLUDE_SIF__
551 
552  // fourth choice: use SIF file
553  case 104: of= new SIFFunction(i,"sif/examples/akiva.d" ,elfunAkiva_ ,groupAkiva_ ); break; // 2
554  case 105: of= new SIFFunction(i,"sif/examples/allinitu.d" ,elfunALLINITU_ ,groupALLINITU_); break; // 4
555  case 106: of= new SIFFunction(i,"sif/examples/stratec.d" ,elfunSTRATEC_ ,groupSTRATEC_ ); break; // 10
556  case 107: of= new SIFFunction(i,"sif/examples/heart.d" ,elfunHEART_ ,groupHEART_ ); break; // 8
557  case 108: of= new SIFFunction(i,"sif/examples/osborneb.d" ,elfunOSBORNEB_ ,groupOSBORNEB_); break; // 11
558  case 109: of= new SIFFunction(i,"sif/examples/vibrbeam.d" ,elfunVIBRBEAM_ ,groupVIBRBEAM_); break; // 8
559  case 110: of= new SIFFunction(i,"sif/examples/kowosb.d" ,elfunKOWOSB_ ,groupKOWOSB_ ); break; // 4
560  case 111: of= new SIFFunction(i,"sif/examples/helix.d" ,elfunHELIX_ ,groupHELIX_ ); break; // 3
561 
562  case 112: of= new SIFFunction(i,"sif/examples/rosenbrock.d",elfunRosen_ ,groupRosen_ ); rhoEnd= 5e-3; break; // 2
563  case 114: of= new SIFFunction(i,"sif/examples/sisser.d" ,elfunSISSER_ ,groupSISSER_ ); rhoEnd= 1e-2; break; // 2
564  case 115: of= new SIFFunction(i,"sif/examples/cliff.d" ,elfunCLIFF_ ,groupCLIFF_ ); rhoEnd= 1e-3; break; // 2
565  case 116: of= new SIFFunction(i,"sif/examples/hairy.d" ,elfunHAIRY_ ,groupHAIRY_ ); rhoEnd= 2e-3; break; // 2
566  case 117: of= new SIFFunction(i,"sif/examples/pfit1ls.d" ,elfunPFIT1LS_ ,groupPFIT1LS_ ); rhoEnd= 1e-2; break; // 3
567  case 118: of= new SIFFunction(i,"sif/examples/hatflde.d" ,elfunHATFLDE_ ,groupHATFLDE_ ); rhoEnd=12e-3; break; // 3
568  case 119: of= new SIFFunction(i,"sif/examples/schmvett.d" ,elfunSCHMVETT_ ,groupSCHMVETT_); rhoEnd= 1e-2; break; // 3
569  case 120: of= new SIFFunction(i,"sif/examples/growthls.d" ,elfunGROWTHLS_ ,groupGROWTHLS_); rhoEnd= 5e-3; break; // 3
570  case 121: of= new SIFFunction(i,"sif/examples/gulf.d" ,elfunGULF_ ,groupGULF_ ); rhoEnd= 5e-2; break; // 3
571  case 122: of= new SIFFunction(i,"sif/examples/brownden.d" ,elfunBROWNDEN_ ,groupBROWNDEN_); rhoEnd=57e-2; break; // 4
572  case 123: of= new SIFFunction(i,"sif/examples/eigenals.d" ,elfunEIGENALS_ ,groupEIGENALS_); rhoEnd= 1e-2; break; // 6
573  case 124: of= new SIFFunction(i,"sif/examples/heart6ls.d" ,elfunHEART6LS_ ,groupHEART6LS_); rhoEnd= 5e-2; break; // 6
574  case 125: of= new SIFFunction(i,"sif/examples/biggs6.d" ,elfunBIGGS6_ ,groupBIGGS6_ ); rhoEnd= 6e-2; break; // 6
575  case 126: of= new SIFFunction(i,"sif/examples/hart6.d" ,elfunHART6_ ,groupHART6_ ); rhoEnd= 2e-1; break; // 6
576  case 127: of= new SIFFunction(i,"sif/examples/cragglvy.d" ,elfunCRAGGLVY_ ,groupCRAGGLVY_); rhoEnd= 6e-2; break; // 10
577  case 128: of= new SIFFunction(i,"sif/examples/vardim.d" ,elfunVARDIM_ ,groupVARDIM_ ); rhoEnd= 1e-3; break; // 10
578  case 129: of= new SIFFunction(i,"sif/examples/mancino.d" ,elfunMANCINO_ ,groupMANCINO_ ); rhoEnd= 1e-6; break; // 10
579  case 130: of= new SIFFunction(i,"sif/examples/power.d" ,elfunPOWER_ ,groupPOWER_ ); rhoEnd= 2e-2; break; // 10
580  case 131: of= new SIFFunction(i,"sif/examples/morebv.d" ,elfunMOREBV_ ,groupMOREBV_ ); rhoEnd= 1e-1; break; // 10
581  case 132: of= new SIFFunction(i,"sif/examples/brybnd.d" ,elfunBRYBND_ ,groupBRYBND_ ); rhoEnd= 6e-3; break; // 10
582  case 133: of= new SIFFunction(i,"sif/examples/brownal.d" ,elfunBROWNAL_ ,groupBROWNAL_ ); rhoEnd= 8e-3; break; // 10
583  case 134: of= new SIFFunction(i,"sif/examples/dqdrtic.d" ,elfunDQDRTIC_ ,groupDQDRTIC_ ); rhoEnd= 1e-3; break; // 10
584  case 135: of= new SIFFunction(i,"sif/examples/watson.d" ,elfunWATSON_ ,groupWATSON_ ); rhoEnd= 4e-2; break; // 12
585  case 137: of= new SIFFunction(i,"sif/examples/fminsurf.d" ,elfunFMINSURF_ ,groupFMINSURF_); rhoEnd= 1e-1; break; // 16
586 
587  case 138: of= new SIFFunction(i,"sif/examples/tointgor.d" ,elfunTOINTGOR_ ,groupTOINTGOR_); break; // 50
588  case 139: of= new SIFFunction(i,"sif/examples/tointpsp.d" ,elfunTOINTPSP_ ,groupTOINTPSP_); break; // 50
589  case 140: of= new SIFFunction(i,"sif/examples/3pk.d" ,elfun3PK_ ,group3PK_ ); break; // 30
590  case 141: of= new SIFFunction(i,"sif/examples/deconvu.d" ,elfunDECONVU_ ,groupDECONVU_ ); break; // 61
591 // case 142: of= new SIFFunction(i,"sif/examples/parkch.d" ,elfunPARKCH_ ,groupPARKCH_ ); break; // 15
592 
593 #ifdef WIN32
594  case 113: of= new SIFFunction(i,"sif/examples/snail.d" ,elfunSNAIL_ ,groupSNAIL_ ); rhoEnd= 2e-4; break; // 2
595  case 136: of= new SIFFunction(i,"sif/examples/dixmaank.d" ,elfunDIXMAANK_ ,groupDIXMAANK_); rhoEnd= 3e-1; break; // 15
596 #else
597  case 113: of= new SIFFunction(i,"sif/examples/snail.d" ,elfunSNAIL_ ,groupSNAIL_ ); rhoEnd= 7e-4; break; // 2
598  case 136: of= new SIFFunction(i,"sif/examples/dixmaank.d" ,elfunDIXMAANK_ ,groupDIXMAANK_); rhoEnd= 4e-1; break; // 15
599 #endif
600 
601 #endif
602 #ifdef __INCLUDE_AMPL__
603 
604  case 200: of= new AMPLObjectiveFunction(i,"ampl/examples/hs022.nl",1.0); break;
605  case 201: of= new AMPLObjectiveFunction(i,"ampl/examples/hs023.nl"); break;
606  case 202: of= new AMPLObjectiveFunction(i,"ampl/examples/hs026.nl"); break;
607  case 203: of= new AMPLObjectiveFunction(i,"ampl/examples/hs034.nl"); break;
608  case 204: of= new AMPLObjectiveFunction(i,"ampl/examples/hs038.nl"); break;
609  case 205: of= new AMPLObjectiveFunction(i,"ampl/examples/hs044.nl"); break;
610  case 206: of= new AMPLObjectiveFunction(i,"ampl/examples/hs065.nl"); break;
611  case 207: of= new AMPLObjectiveFunction(i,"ampl/examples/hs076.nl"); break;
612  case 208: of= new AMPLObjectiveFunction(i,"ampl/examples/hs100.nl"); break;
613  case 209: of= new AMPLObjectiveFunction(i,"ampl/examples/hs106.nl"); break;
614  case 210: of= new AMPLObjectiveFunction(i,"ampl/examples/hs108.nl"); rhoEnd= 1e-5; break;
615  case 211: of= new AMPLObjectiveFunction(i,"ampl/examples/hs116.nl"); break;
616  case 212: of= new AMPLObjectiveFunction(i,"ampl/examples/hs268.nl"); break;
617 
618  case 250: of= new AMPLObjectiveFunction(i,"ampl/examples/rosenbr.nl" ); rhoEnd= 5e-3; break; // 2
619  case 251: of= new AMPLObjectiveFunction(i,"ampl/examples/sisser.nl" ); rhoEnd= 1e-2; break; // 2
620  case 252: of= new AMPLObjectiveFunction(i,"ampl/examples/cliff.nl" ); rhoEnd= 1e-3; break; // 2
621  case 253: of= new AMPLObjectiveFunction(i,"ampl/examples/hairy.nl" ); rhoEnd= 2e-2; break; // 2
622  case 254: of= new AMPLObjectiveFunction(i,"ampl/examples/pfit1ls.nl" ); rhoEnd= 1e-2; break; // 3
623  case 255: of= new AMPLObjectiveFunction(i,"ampl/examples/hatflde.nl" ); rhoEnd=12e-3; break; // 3
624  case 256: of= new AMPLObjectiveFunction(i,"ampl/examples/growthls.nl"); rhoEnd= 5e-3; break; // 3
625  case 257: of= new AMPLObjectiveFunction(i,"ampl/examples/gulf.nl" ); rhoEnd= 5e-2; break; // 3
626  case 258: of= new AMPLObjectiveFunction(i,"ampl/examples/brownden.nl"); rhoEnd=57e-2; break; // 4
627  case 259: of= new AMPLObjectiveFunction(i,"ampl/examples/eigenals.nl"); rhoEnd= 1e-2; break; // 6
628  case 260: of= new AMPLObjectiveFunction(i,"ampl/examples/heart6ls.nl"); rhoEnd= 1e-2; break; // 6
629  case 261: of= new AMPLObjectiveFunction(i,"ampl/examples/biggs6.nl" ); rhoEnd= 6e-2; break; // 6
630  case 262: of= new AMPLObjectiveFunction(i,"ampl/examples/hart6.nl" ); rhoEnd= 2e-1; break; // 6
631  case 263: of= new AMPLObjectiveFunction(i,"ampl/examples/cragglvy.nl"); rhoEnd= 1e-2; break; // 10
632  case 264: of= new AMPLObjectiveFunction(i,"ampl/examples/vardim.nl" ); rhoEnd= 1e-3; break; // 10
633  case 265: of= new AMPLObjectiveFunction(i,"ampl/examples/mancino.nl" ); rhoEnd= 1e-6; break; // 10
634  case 266: of= new AMPLObjectiveFunction(i,"ampl/examples/power.nl" ); rhoEnd= 2e-2; break; // 10
635  case 267: of= new AMPLObjectiveFunction(i,"ampl/examples/morebv.nl" ); rhoEnd= 1e-1; break; // 10
636  case 268: of= new AMPLObjectiveFunction(i,"ampl/examples/brybnd.nl" ); rhoEnd= 3e-3; break; // 10
637  case 269: of= new AMPLObjectiveFunction(i,"ampl/examples/brownal.nl" ); rhoEnd= 8e-3; break; // 10
638  case 270: of= new AMPLObjectiveFunction(i,"ampl/examples/dqdrtic.nl" ); rhoEnd= 1e-3; break; // 10
639  case 271: of= new AMPLObjectiveFunction(i,"ampl/examples/watson.nl" ); rhoEnd= 4e-2; break; // 12
640  case 272: of= new AMPLObjectiveFunction(i,"ampl/examples/dixmaank.nl"); rhoEnd= 3e-1; break; // 15
641  case 273: of= new AMPLObjectiveFunction(i,"ampl/examples/fminsurf.nl"); rhoEnd= 1e-1; break; // 16
642 
643 #endif
644 
645  }
646  if ((i>=250)&&(i<=273)) of->isConstrained=0;
647 
648  if ((rho)&&(rhoEnd!=-1)) *rho=rhoEnd;
649  if (of==NULL)
650  {
651  printf("No objective function defined under index %i\n",i);
652  exit(255);
653  }
654  return of;
655 }
656 */
657 
658 
virtual void saveValue(Vector tmp, double valueOF, int nerror)
virtual void finalize(Vector vG, Matrix mH, Vector vLambda)
CorrectScaleOF(int _t, ObjectiveFunction *_of, Vector _rescaling)
int * mmax
double scalarProduct(int nl, Vector v)
Definition: Matrix.cpp:695
void initTolNLC(Vector c, double delta)
double LnftyNorm()
Definition: Vector.cpp:264
doublereal * c
Definition: Vector.h:37
HBITMAP buffer
Definition: svm-toy.cpp:37
virtual void finalize(Vector vG, Matrix mH, Vector vLambda)
void save(char *filename, char ascii)
Definition: Vector.cpp:441
void swapLines(int i, int j)
Definition: Matrix.cpp:1155
double LnftyDistance(Vector v)
Definition: Vector.cpp:256
void print()
Definition: Vector.cpp:161
void oneByOneMutiply(Vector r)
Definition: Vector.cpp:376
void setSize(int _nLine, int _nColumn)
Definition: Matrix.cpp:205
void append(Vector tmp)
Definition: Matrix.cpp:1227
void initTolLC(Vector vX)
int nColumn()
Definition: Matrix.h:84
Vector clone()
Definition: Vector.cpp:207
doublereal * x
#define i
virtual double evalNLConstraint(int j, Vector v, int *nerror)=0
ql0001_ & k(htemp+1),(cvec+1),(atemp+1),(bj+1),(bl+1),(bu+1),(x+1),(clamda+1), &iout, infoqp, &zero,(w+1), &lenw,(iw+1), &leniw, &glob_grd.epsmac
doublereal * d
virtual double eval(Vector v, int *nerror)=0
void setSize(int _n)
Definition: Vector.cpp:112
unsigned sz()
Definition: Vector.h:79
void projectionIntoFeasibleSpace(Vector vFrom, Vector vBase, ObjectiveFunction *of)
Definition: CTRSSolver.cpp:74
int nLine()
Definition: Matrix.h:83
int lineIndex(Vector r, int nn=0)
Definition: Matrix.cpp:1168
void setSaveFile(char *b=NULL)
virtual double evalNLConstraint(int j, Vector v, int *nerror=NULL)
void setNColumn(int _nColumn)
Definition: Matrix.cpp:199
char isFeasible(Vector vx, double *d=NULL)
void saveValue(Vector X, double valueOF, int nerror)
double condorAbs(const double t1)
Definition: tools.h:47
free((char *) ob)
Definition: Matrix.h:38
void oneByOneInvert()
Definition: Vector.cpp:383
#define j
void saveStats(char *filename, Vector vG, Matrix mH, Vector vLambda)
virtual void evalGradNLConstraint(int j, Vector v, Vector result, int *nerror=NULL)
void diagonalizeAndMultiply(Matrix M)
Definition: Vector.cpp:316
void save(char *filename, char ascii)
Definition: Matrix.cpp:282
Vector getLine(int i, int n=0, int startCol=0)
Definition: Matrix.cpp:1094
static Vector emptyVector
Definition: Vector.h:119
double eval(Vector v, int *nerror=NULL)
virtual Vector evalGradNLConstraint(int j, Vector v, int *nerror)
fprintf(glob_prnt.io, "\)
#define INF
Definition: svm.cpp:43
void copyFrom(Vector r, int _n=0)
Definition: Vector.cpp:215
int * n
void updateSave(char *saveFileName)
Definition: Matrix.cpp:349
virtual void printStats(char cc=1)
void multiplyByDiagonalMatrix(Vector v)
Definition: Matrix.cpp:558
double * delta
void updateCounter(double df, Vector vX, int nerror=0)