forum.alglib.net

ALGLIB forum
It is currently Sun Dec 22, 2024 11:43 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  [ 3 posts ] 
Author Message
 Post subject: using BLEIC optimizer
PostPosted: Wed Jan 04, 2012 8:36 am 
Offline

Joined: Wed Jan 04, 2012 8:08 am
Posts: 2
I currently use BLEIC for minimization solution. I implement a case from MSDN example in the following link http://msdn.microsoft.com/en-us/library ... 87(v=vs.93).aspx

The following is my source code.
void function1_grad(const real_1d_array &x, double &func, real_1d_array &grad, void *ptr)
{
//
// this callback calculates f(x0,x1) = 20*x0 + 15*x1
// and its derivatives df/d0 and df/dx1
// set goal (20 * sa + 15 * vz);

func = 20 * x[0] + 15 * x[1];
grad[0] = 20;
grad[1] = 15;
}

int main(int argc, char **argv)
{

// using BLEIC optimizer.

//set initial point, wild guess
real_1d_array x = "[3000.0,4500.0]";

//set scale
real_1d_array s = "[10.0,10.0]";

//set boundry
// 0 <= vz <= 9000,
// 0 <= sa <= 6000);

real_1d_array bndl = "[+0.0,+0.0]";
real_1d_array bndu = "[+6000.0,+9000.0]";

//set linear constrain
// 0.3 * sa + 0.4 * vz >= 2000,
// 0.4 * sa + 0.2 * vz >= 1500,
// 0.2 * sa + 0.3 * vz >= 500);

real_2d_array c = "[[0.3,0.4,2000.0],[0.4,0.2,1500.0],[0.2,0.3,500.0]]";

//set >= (1 ), = (0), <= (-1)
integer_1d_array ct = "[1,1,1]";

minbleicstate state;
minbleicreport rep;

//
// These variables define stopping conditions for the underlying CG algorithm.
// They should be stringent enough in order to guarantee overall stability
// of the outer iterations.
//
// We use very simple condition (gradian base) - |g|<=epsg
//
double epsg = 0.00001;
double epsf = 0;
double epsx = 0;

//
// These variables define stopping conditions for the outer iterations:
// * epso controls convergence of outer iterations; algorithm will stop
// when difference between solutions of subsequent unconstrained problems
// will be less than 0.0001
// * epsi controls amount of infeasibility allowed in the final solution
//
double epso = 0.0001;
double epsi = 0.0001;

//
// Now we are ready to actually optimize something:
// * first we create optimizer
// * we add boundary constraints
// * we add linear constraints
// * we set scale
// * we tune stopping conditions
// * and, finally, optimize and obtain results...
//
minbleiccreate(x, state);
minbleicsetbc(state, bndl, bndu);
minbleicsetlc(state, c, ct);
minbleicsetscale(state,s);
minbleicsetinnercond(state, epsg, epsf, epsx);
minbleicsetoutercond(state, epso, epsi);
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: [2,4]
//Sleep(5000);
return 0;
}

My question is when I set different initial points I get different answers, sometimes return "NAN"
case 1: set initial point, real_1d_array x = "[3000.0,4500.0]", return correct answer [2000, 3500]
case 2: set real_1d_array x = "[1000.0,1000.0]", return [NAN, NAN]

What is the problem resulted from? and how to fix it?


Top
 Profile  
 
 Post subject: Re: using BLEIC optimizer
PostPosted: Thu Jan 05, 2012 7:30 pm 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 927
Hello!

I working on your problem right now. It seems that part of optimizer which tries to find feasible point is working incorrectly on your set of constraints. It seems that the problem is triggered by the start from the infeasible point. It is not fully confirmed yet, but start from feasible point should solve issue. I plan to give more information on your issue tomorrow. You can be sure that it has top priority for us.


Top
 Profile  
 
 Post subject: Re: using BLEIC optimizer
PostPosted: Fri Jan 06, 2012 2:27 am 
Offline

Joined: Wed Jan 04, 2012 8:08 am
Posts: 2
Sergey.Bochkanov wrote:
Hello!

I working on your problem right now. It seems that part of optimizer which tries to find feasible point is working incorrectly on your set of constraints. It seems that the problem is triggered by the start from the infeasible point. It is not fully confirmed yet, but start from feasible point should solve issue. I plan to give more information on your issue tomorrow. You can be sure that it has top priority for us.


Thanks for kindly help.

And, the question would be how to define feasible point? In case 2 (x[0]=1000 x[1]=1000), both are within their own boundary. could be considered as feasible points?


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 35 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