forum.alglib.net

ALGLIB forum
It is currently Thu Mar 28, 2024 4:46 pm

All times are UTC


Forum rules


1. This forum can be used for discussion of both ALGLIB-related and general numerical analysis questions
2. This forum is English-only - postings in other languages will be removed.



Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: How to get the objective function value minbleic in 3.8.0?
PostPosted: Mon Nov 04, 2013 3:45 am 
Offline

Joined: Mon Feb 28, 2011 7:23 am
Posts: 9
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;
}


Top
 Profile  
 
 Post subject: Re: How to get the objective function value minbleic in 3.8.
PostPosted: Tue Nov 05, 2013 8:06 pm 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 903
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 62 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group