- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Long executable execution time
Long executable execution time
Long executable execution time
Hi,
I have a problem with execution of optimization problem in OMNotebook.
To begin with I'm working with a model in which I'm using ipopt in order to optimise two variables over time. It's a typical control problem with charging and discharging of energy storage.
I've got the model working but a strange thing happens after it's built with higher number of intervals.
In this situation the program executes very fast (5 s or less ) when it is done by optimize(model,....).
Code:
optimize(Mors_opt_src, stopTime=t_f, tolerance=1e-8, numberOfIntervals=500, simflags="-optimizerNP 1 -ipopt_max_iter 500 -s optimization");
After that when I call model.exe it takes ages to compute (5 min or so).
Code:
system("Mors_opt_src.exe");
In order to make the model.exe work at all i've had to add "C:\OpenModelica1.13.0-32bit\lib\omc" to path.
The model reads two variables from txt files by:
Code:
Modelica.Blocks.Sources.CombiTimeTable Zapotrzebowanie(columns = {2}, extrapolation = Modelica.Blocks.Types.Extrapolation.HoldLastPoint, fileName = "F:\xxx\xxx\xxx\xxx\xxx.txt", smoothness = Modelica.Blocks.Types.Smoothness.LinearSegments, tableName = "tab", tableOnFile = true);
Can anyone tell me what may cause the problem? I wanted to use the exe file in optimal control system In this process execution time is crucial and I would rather not have to build the model each time.
I'm using Win10 and I've tried OM 1.13 and 1.14 on both 32 and 64-bit versions. Also running the whole thing on Linux is not a bang for a buck for me. (At least not at this moment.)
The problem doesn't occur with small number of intervals. With
Code:
numberOfIntervals=50
but the thing is that i will be dealing with large number of those.
Also the process uses less than 13% of cpu time,
Thanks for any help
Re: Long executable execution time
So if anyone finds this topic one day. I've worked around the problem in maybe not the most elegant, but working way.
Instead of calling the model.exe file with modified Model_init.xml file I've written the optimization.mos script which loads models and runs optimization with overriden parameters.
Code:
setCommandLineOptions("+g=Modelica");
loadModel(Modelica,{"3.1"}); //Without older modelica library I get some errors
loadFile("model1_path");
loadFile("model2_path");
setCommandLineOptions("+gDynOpt");
t_f := 604800;
optimize(model_name, stopTime=t_f, tolerance=1e-9,numberOfIntervals=504, outputFormat="csv", simflags="-optimizerNP 1 -ipopt_max_iter 2000 -s optimization -lv=LOG_SOLVER -overrideFile=C:\path_path_path\parameters_mod.txt");
getErrorString();
//optimization -lv=LOG_SOLVER is for analysing the process
//override file has model parameters and input file paths in it
Than I've written a batch script caller.bat in which I change the directory to a path for the built/compiled files and output and from there I call the OM complier with the script as an argument.
Code:
cd C://output_path_output_path
C://OpenModelica1.13.0-64bit//bin//omc.exe C://pathpathpath//optimization.mos
pause // for taking a look at the console response
That way I can call multiple instances of the optimization with different input simultaneously in multiple threads from python or another batch file.
I still have to deal with compilation time but, I don't get the problem mentioned above.
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Long executable execution time