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" 44 fprintf(ff,
";Hessian matrix at the solution\n");
46 fprintf(ff,
";Gradient vector at the solution (should be zero if no active constraints)\n");
50 fprintf(ff,
";Lagrangian Vector at the solution (lower,upper,linear,non-linear)\n");
61 int i,
dim=vx.
sz(), nerror;
63 double *bbl=
bl, *bbu=
bu, *
x=vx,
t;
69 if ((t=bbl[i]-x[i])>
tolLC)
70 {
if (d) *d=
mmax(*d,t);
else return 0; feasible=0; }
73 if ((t=x[i]-bbu[i])>
tolLC)
74 {
if (d) *d=
mmax(*d,t);
else return 0; feasible=0; }
76 for (i=0; i<
A.
nLine(); i++)
78 {
if (d) *d=
mmax(*d,t);
else return 0; feasible=0; }
82 {
if (d) *d=
mmax(*d,t);
else return 0; feasible=0; }
92 double *bbl=
bl, *bbu=
bu;
95 for (i=0; i<mdim; i++)
112 for (i=0; i<
A.
nLine(); i++)
123 if (delta<
INF) maxNormNLC=
mmax(maxNormNLC,delta*delta);
131 if ((dfold==
INF)&&(nerror==0)) { dfref=(1+
condorAbs(df))*1e-8; dfold=df;
nfe2=
nfe;
return; }
132 if (dfold-df<dfref)
return;
145 if (saveFileName)
free(saveFileName);
148 strcpy(buffer,
name); strcat(buffer,
".dat"); s=
buffer;
150 saveFileName=(
char*)malloc(strlen(s)+1);
151 strcpy(saveFileName,s);
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; }
160 while ((*p!=
'\\')&&(*p!=
'/')&&(p!=s)) p--;
161 if (p==s) { strncpy(
name,s, 8);
name[8]=0;
return; }
168 printf(
"\n\nProblem Name: %s\n",
name);
169 printf(
"Dimension of the search space: %i\n",
dim());
171 printf(
"Number of function Evaluation: %i (%i)\n",
nfe,
nfe2);
181 printf(
"Solution Vector is : \n[%e",dd[0]);
182 for (
j=1;
j<idim;
j++) printf(
", %e",dd[
j]);
186 double *dbl=
bl,*dbu=
bu;
189 if (*(dbl++)>-
INF)
j++;
190 if (*(dbu++)<
INF)
j++;
192 printf(
"number of box constraints:%i\n" 193 "number of linear constraints:%i\n" 203 ((
double**)
data)[nl][mdim]=valueOF;
204 ((
double**)
data)[nl][mdim+1]=nerror;
221 void ObjectiveFunction::addClosestFeasiblePointInData(
Vector vX)
231 printf(
"Evaluation of the Obj. Funct. at the starting point as failed.\n");
244 printf(
"unable to start (violation=%e).\n",best);
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");
264 addClosestFeasiblePointInData(
xStart);
277 addClosestFeasiblePointInData(
xStart);
288 double v,best=
INF,best2=
INF;
291 if (((
double**)
data)[i][mdim+1])
continue;
292 v=((
double**)data)[
i][mdim];
293 if (v<best2) {
j=
i; best2=v; }
295 data.getLine(i,r,mdim);
312 addClosestFeasiblePointInData(r);
320 double *dbl=
bl,*dbu=
bu;
339 double *
x=X, *xr=xTemp, *re=rescaling;
340 while (i--) xr[
i]=re[
i]*x[
i];
348 double *
x=X, *xr=xTemp, *re=rescaling;
349 while (i--) xr[
i]=re[
i]*x[
i];
350 double r=of->
eval(xTemp,nerror);
358 double *
x=X, *xr=xTemp, *re=rescaling;
359 while (i--) xr[
i]=re[
i]*x[
i];
366 double *
x=X, *xr=xTemp, *re=rescaling;
367 while (i--) xr[
i]=re[
i]*x[
i];
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;
399 if ((
int)_rescaling.
sz()!=_of->
dim())
401 printf(
"Error in rescaling vector: dimension do not agree.\n");
407 void CorrectScaleOF::init()
411 *bls=of->
bl, *bus=of->
bu, *bld, *bud, **as=of->
A, **ad;
413 strcpy(
name,
"SCALING");
422 if (xos) xod[
i]=xos[
i]/r[
i];
425 while (j--) datad[
j][
i]=datas[
j][
i]/r[
i];
428 while (j--) { datad[
j][
n]=datas[
j][
n]; datad[
j][n+1]=datas[
j][n+1]; }
452 while (j--) ad[
j][
i]=as[
j][
i]*r[
i];
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)
double tolRelFeasibilityForNLC
double scalarProduct(int nl, Vector v)
void initTolNLC(Vector c, double delta)
virtual void finalize(Vector vG, Matrix mH, Vector vLambda)
void save(char *filename, char ascii)
void swapLines(int i, int j)
double LnftyDistance(Vector v)
void oneByOneMutiply(Vector r)
void setSize(int _nLine, int _nColumn)
void initTolLC(Vector vX)
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
virtual double eval(Vector v, int *nerror)=0
void projectionIntoFeasibleSpace(Vector vFrom, Vector vBase, ObjectiveFunction *of)
double tolRelFeasibilityForLC
int lineIndex(Vector r, int nn=0)
void setSaveFile(char *b=NULL)
virtual double evalNLConstraint(int j, Vector v, int *nerror=NULL)
void setNColumn(int _nColumn)
char isFeasible(Vector vx, double *d=NULL)
void saveValue(Vector X, double valueOF, int nerror)
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)
void save(char *filename, char ascii)
Vector getLine(int i, int n=0, int startCol=0)
static Vector emptyVector
double eval(Vector v, int *nerror=NULL)
virtual Vector evalGradNLConstraint(int j, Vector v, int *nerror)
fprintf(glob_prnt.io, "\)
void copyFrom(Vector r, int _n=0)
void updateSave(char *saveFileName)
virtual void printStats(char cc=1)
void multiplyByDiagonalMatrix(Vector v)
void updateCounter(double df, Vector vX, int nerror=0)