Can Fmincon recover from an error in evaluating the cost function?
Ältere Kommentare anzeigen
Hi
I'm using fmincon to determine the optimal torque trajectory for a mutlibody simulation. I've approximated the input torque as piece-wise linear function.
I'm using fmincon as I would like to minimize the time it takes to bring the system to rest - this is my "cost function". This is determined by simulation of my model and then determining the cost. A similar approach is done to evaluate my nonlinear constraints.
Unfortunately, sometimes if the torque trajectory attempted by fmincon is too great, the simulation crashes with the message "Derivative input 1 of 'optimModel/Integrator1' at time 0.359 is Inf or NaN" and then the function stops. This is understandable as the body system spins around violently.
Is there a way for fmincon to recover from this? ie. to assign a cost to this value and move to the next attempt?
Or alternatively, does Global Optimization toolbox have functions with provision to do this? I realize that my cost function must obviously be non-smooth and some solutions cause instability in my simulation.
Any suggestions would be much appreciated.
Kind Regards
Amir
Akzeptierte Antwort
Weitere Antworten (2)
Alan Weiss
am 4 Jun. 2013
0 Stimmen
The sqp and interior-point algorithms are robust to evaluation failures, as long as the initial point x0 has a well-defined objective there. See the release notes for R2011a.
Alan Weiss
MATLAB mathematical toolbox documentation
9 Kommentare
Amir Patel
am 4 Jun. 2013
Amir Patel
am 4 Jun. 2013
Amir Patel
am 4 Jun. 2013
Alan Weiss
am 4 Jun. 2013
GlobalSearch and MultiStart use fmincon as their local solver. They simply start it from a variety of initial points.
It is possible that the initial point you have, x0, has a finite objective value, but the finite differencing steps that fmincon take to estimate the derivative of the objective function lead to NaN. If there is no finite derivative, fmincon cannot proceed.
So I suggest you try a different value of x0 yourself, and turn on iterative display. If you use interior-point fmincon, then once it has started it should be able to proceed.
Alan Weiss
MATLAB mathematical toolbox documentation
Farshid R
am 26 Sep. 2022
Hi,
Could I require a question about optimization?
Steven Lord
am 26 Sep. 2022
@Farshid R Yes you can ask questions about optimization, but unless it's related to the exact question asked nine years ago you should ask it as a new question rather than asking it in this old question's comments. Use the Ask link at the top of the page to ask it as a new question.
Farshid R
am 26 Sep. 2022
Thank you. Sorry, I replied late. The link to my question is:
https://www.mathworks.com/matlabcentral/answers/1812615-optimization-with-fmincon-command-in-simulink
Farshid R
am 26 Sep. 2022
https://www.mathworks.com/matlabcentral/answers/1812615-optimization-with-fmincon-command-in-simulink
I've approximated the input torque as piece-wise linear function.
A piece-wise linear input will obviously not have bounded derivatives. To achieve bounded derivatives in FMINCON, you could and probably should approximate the torque using a 2nd order smooth function instead, e.g. using the SPLINE command or with the 'cubic' option of any of MATLAB's interpolation commands.
Kategorien
Mehr zu Get Started with Optimization Toolbox finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!