Can Fmincon recover from an error in evaluating the cost function?
이전 댓글 표시
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
채택된 답변
추가 답변 (2개)
Alan Weiss
2013년 6월 4일
0 개 추천
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
Amir Patel
2013년 6월 4일
Amir Patel
2013년 6월 4일
Amir Patel
2013년 6월 4일
Alan Weiss
2013년 6월 4일
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
2022년 9월 26일
Hi,
Could I require a question about optimization?
Steven Lord
2022년 9월 26일
@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
2022년 9월 26일
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
2022년 9월 26일
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.
카테고리
도움말 센터 및 File Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!