forum.alglib.net

ALGLIB forum
 It is currently Thu Jun 08, 2023 6:27 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.

 Page 1 of 1 [ 4 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: Setting up optimization problemPosted: Wed Mar 17, 2021 12:30 pm

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 [ 645.11 KiB | Viewed 1803 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

 Post subject: Re: Setting up optimization problemPosted: Thu Mar 18, 2021 3:06 pm

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

 Post subject: Re: Setting up optimization problemPosted: Tue Mar 23, 2021 12:38 pm

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

 Post subject: Re: Setting up optimization problemPosted: Tue Mar 23, 2021 4:36 pm

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

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 4 posts ]

 All times are UTC

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

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

Search for:
 Jump to:  Select a forum ------------------ ALGLIB forum    ALGLIB-discuss
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group