forum.alglib.net

ALGLIB forum
It is currently Thu Mar 28, 2024 11:33 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  [ 4 posts ] 
Author Message
 Post subject: Setting up optimization problem
PostPosted: Wed Mar 17, 2021 12:30 pm 
Offline

Joined: Wed Mar 17, 2021 12:23 pm
Posts: 4
I am trying to find the minimum of a complex function that I cannot write in a single equation because each solution value requires a variable number of iterations. There are two vectors (for satellite positions), and two times that are required for each solution. I can calculate several values and end up with a surface like this. The times are on the horizontal plane. The change in velocity (vertical axis) is what I wish to find the minima for.

Attachment:
Fig720_dvSPlot.png
Fig720_dvSPlot.png [ 645.11 KiB | Viewed 2649 times ]



I “think” the BLEIC or one of the other optimizers might work, but I’m not quite sure which one would be best, and I am not quite in synch with how each variable (state, constraint, etc) aligns with my particular problem. Any suggestions would be appreciated. Thanks!


Top
 Profile  
 
 Post subject: Re: Setting up optimization problem
PostPosted: Thu Mar 18, 2021 3:06 pm 
Offline

Joined: Wed Mar 17, 2021 12:23 pm
Posts: 4
I have it set up, I think. But it doesn't appear to give the right answers? In the following, I "think" that my 2 variables are in x[]. I'd like them to vary from 0-8000, and 0-25000 respectively. I'm not sure if that's correct, or if s[] has to be set with the limits?

double[] x = new double[] { 8000, 25000 };
double epsg = 0.0000000001;
double epsf = 0;
epsx = 0;
double diffstep = 1.0e-6;
maxits = 0;
// the state is different here from above
alglib.minlbfgsstate state1;
// report the output data
alglib.minlbfgsreport rep1;

// create the state
// this version does NOT have a gradient (f)
alglib.minlbfgscreatef(1, x, diffstep, out state1);

// set stopping conditions
alglib.minlbfgssetcond(state1, epsg, epsf, epsx, maxits);

// set scale of variables
// double[] s = new double[] { 1, 1 };
s = new double[] { 20000, 25000 };
alglib.minlbfgssetscale(state1, s);

// optimize!!
//alglib.minlbfgsoptimize(state1, function1_func, null, null);
alglib.minlbfgsoptimize(state1, function_lamb, null, null);

// output results of optimization
alglib.minlbfgsresults(state1, out x, out rep1);


Top
 Profile  
 
 Post subject: Re: Setting up optimization problem
PostPosted: Tue Mar 23, 2021 12:38 pm 
Offline

Joined: Wed Mar 17, 2021 12:23 pm
Posts: 4
Yeah. We figured it out! function_lamb is a complicated (about 3000 lines of code) routine that produces the surface I showed earlier. The optimization seems to work for both bc and bleic approaches. A couple of refining questions.

1. Not sure if any one of the others might be better?
2. Is there a way to stop the optimization if it goes into an unbounded direction?
3. These all seem to find local minimia, but not global minima. Any suggestions on search patterns or other ways to help with this process?

double[] xin = new double[] { r.Next(0, 28800), r.Next(0, 12000) };
double[] xout = new double[2];
epsg = 0; // gradient difference
epsf = 0; // function difference
epsx = 0.0000000001; // state variable difference
double diffstep = 0.01; // 1.0e-6;
int maxits = 40;
//alglib.xparams _params;
double stpmax = 1.0; // Max func value step size (?)
//alglib.xparams _params;
double[] BndL = new double[] { 0.0, 0.0 }; // min values
double[] BndU = new double[] { 28800.0, 12000.0 }; // max values
double[] s = new double[] { 1, 1 }; // set scale of variables

alglib.minbccreatef(2, xin, diffstep, out minbcstate state1);
alglib.minbcsetbc(state1, BndL, BndU);
alglib.minbcsetcond(state1, epsg, epsf, epsx, maxits, new xparams(2));
alglib.minbcsetscale(state1, s);
alglib.minbcsetstpmax(state1, stpmax);
alglib.minbcoptimize(state1, function_lamb, null, null);
alglib.minbcresults(state1, out xout, out minbcreport rep1);


Top
 Profile  
 
 Post subject: Re: Setting up optimization problem
PostPosted: Tue Mar 23, 2021 4:36 pm 
Offline

Joined: Wed Mar 17, 2021 12:23 pm
Posts: 4
update on question #2. We can test x to see if the solution is going in the wrong direction (a possibility for some of our cases), and it looks like a user supplied algorithm can solve the problem. however, the function doesn't have the ability to input the state as an input variable, from which we could then terminate that particular optimization. Are there any ways to actually implement the "user-supplied callback" which is mentioned in the documentation, but never given as an example?


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

All times are UTC


Who is online

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