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

Setting up optimization problem http://forum.alglib.net/viewtopic.php?f=2&t=4375 
Page 1 of 1 
Author:  dvallado [ Wed Mar 17, 2021 12:30 pm ] 
Post subject:  Setting up optimization problem 
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 2495 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! 
Author:  dvallado [ Thu Mar 18, 2021 3:06 pm ] 
Post subject:  Re: Setting up optimization problem 
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 08000, and 025000 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.0e6; 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); 
Author:  dvallado [ Tue Mar 23, 2021 12:38 pm ] 
Post subject:  Re: Setting up optimization problem 
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.0e6; 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); 
Author:  dvallado [ Tue Mar 23, 2021 4:36 pm ] 
Post subject:  Re: Setting up optimization problem 
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 "usersupplied callback" which is mentioned in the documentation, but never given as an example? 
Page 1 of 1  All times are UTC 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ 