Accelerating the compilation time of optimisation problem

3 ビュー (過去 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 Center および File ExchangeGet Started with Optimization Toolbox についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by