Accelerating the compilation time of optimisation problem

조회 수: 5 (최근 30일)
Ranjith Prakash
Ranjith Prakash 2022년 7월 27일
편집: Andy Bartlett 2022년 7월 27일
I am running a optimization problem in simulink. Its a constrained non-linear optimization with fmincon solver. The issue i am facing is the larger runtime for the problem due to larger compilation time at each iteration. I have a model with large no of thermal masses. When i simplyfy the model with less number of thermal networks and elements, the model is running faster. I need to know what can be done to improve this compilation time when i have large thermal masses for a model.
  댓글 수: 1
Walter Roberson
Walter Roberson 2022년 7월 27일
fmincon() only "compiles" the function in any sense the first time the function is parsed. And technically speaking if you use something like
fmincon(@obj, ....)
then obj will be parsed before fmincon is even started.
If you have code that uses mcc to compile an .exe for each iteration, then you would need to have a very good reason to do that.
In some cases, it occasionally makes sense to build a Symbolic expression, and then have MATLAB convert the symbolic expression to matlab code using matlabFunction() or odeFunction() . There is a sense in which that could be called "compiling". That process can take a fair while for complicated expressions, especially if you told it to save the result to file and you did not remember to tell it to turn optimization off.
But... for most people, MATLAB parses the objective function once, usually before fmincon starts, and after that it is a matter of executing the function, not of "compiling" it.

댓글을 달려면 로그인하십시오.

답변 (1개)

Andy Bartlett
Andy Bartlett 2022년 7월 27일
편집: Andy Bartlett 2022년 7월 27일
You can get dramatic speed-ups across multiple simulation by using Simulink's Fast Restart and several related features. See this Youtube on Simulink Fast Restart. You may also wish to explore accelerator and rapid accelerator. The key thing for this to work is that your optimization search is only making "tunable" changes such as adjusting the value of tunable model parameters and possibly externally fed input signals.
If you are rewiring blocks, replacing blocks, changing data types, dimensions, complexity, ..., then a full re-compile of the Simulink model will be needed after each "structural" change. But between each "structural" change, you can still leverage all the speed-up opportunities to explore "tunable" changes.
There is also a product Simulink Design Optimization dedicated to this type of optimzation loops wrapped around a Simulink model. That product is aware of and designed to leverage speed-up opportunities. For example, watch Youtube on Fast Restart for Simulink Design Optimization.

카테고리

Help CenterFile Exchange에서 Manual Performance Optimization에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by