Accelerating the compilation time of optimisation problem
2 次查看(过去 30 天)
显示 更早的评论
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
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
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Get Started with Optimization Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!