forum.alglib.net
http://forum.alglib.net/

How to get the objective function value minbleic in 3.8.0?
http://forum.alglib.net/viewtopic.php?f=2&t=1038
Page 1 of 1

Author:  frainbbs [ Mon Nov 04, 2013 3:45 am ]
Post subject:  How to get the objective function value minbleic in 3.8.0?

minbleic
In the previous version , I can get the objective function value and others.
But in 3.8.0,I Don't know how to get the objective function value with minbleic ?





void function1_grad(const real_1d_array &x, double &func, real_1d_array &grad, void *ptr)
{
//
// this callback calculates f(x0,x1) = 100*(x0+3)^4 + (x1-3)^4
// and its derivatives df/d0 and df/dx1
//
func = 100*pow(x[0]+3,4) + pow(x[1]-3,4);
grad[0] = 400*pow(x[0]+3,3);
grad[1] = 4*pow(x[1]-3,3);
}

int main(int argc, char **argv)
{
//
// This example demonstrates minimization of f(x,y) = 100*(x+3)^4+(y-3)^4
// subject to bound constraints -1<=x<=+1, -1<=y<=+1, using BLEIC optimizer.
//
real_1d_array x = "[0,0]";
real_1d_array bndl = "[-1,-1]";
real_1d_array bndu = "[+1,+1]";
minbleicstate state;
minbleicreport rep;

//
// These variables define stopping conditions for the optimizer.
//
// We use very simple condition - |g|<=epsg
//
double epsg = 0.000001;
double epsf = 0;
double epsx = 0;
ae_int_t maxits = 0;

//
// Now we are ready to actually optimize something:
// * first we create optimizer
// * we add boundary constraints
// * we tune stopping conditions
// * and, finally, optimize and obtain results...
//
minbleiccreate(x, state);
minbleicsetbc(state, bndl, bndu);
minbleicsetcond(state, epsg, epsf, epsx, maxits);
alglib::minbleicoptimize(state, function1_grad);
minbleicresults(state, x, rep);

//
// ...and evaluate these results
//
printf("%d\n", int(rep.terminationtype)); // EXPECTED: 4
printf("%s\n", x.tostring(2).c_str()); // EXPECTED: [-1,1]

cout<<"rep.iterationscount= "<<rep.iterationscount<<endl;
cout<<"rep.nfev= "<<rep.nfev<<endl;
cout<<"rep.debugdx= "<<rep.debugdx<<endl;
cout<<"rep.debugff= "<<rep.debugff<<endl;
cout<<"rep.debugfs= "<<rep.debugfs<<endl;

// rep.iterationscount= 3
// rep.nfev= 5
// rep.debugdx= nan
// rep.debugff= nan
// rep.debugfs= nan
return 0;
}

Author:  Sergey.Bochkanov [ Tue Nov 05, 2013 8:06 pm ]
Post subject:  Re: How to get the objective function value minbleic in 3.8.

The reason is that you use debug fields, which are not documented and not intended for external use. They may change in future versions without notice, no backward compatibility guarantee is provided.

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/