Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

issue with simulation flag -override OMEdit

issue with simulation flag -override OMEdit

Hello,

Being relatively new to openmodelica, I'm trying to use optionnal simulation flag -override and -overrideFile from OMEdit version 1.11.0 to change initial model value contained in model_init.xml.
Whereas it perfectly work in OMshell using command like this :
ie simflags="-overrideFile=path" :
simulate(testpipebreak, startTime=0, stopTime=1, numberOfIntervals=500, tolerance=1e-4, method="dassl", outputFormat="mat",simflags="-overrideFile=D:/pipe.txt")
It does not work when I add the following command at the very end of the simulationflag sheet of the simulation configuration window of OMEdit:
If i had -override var1=value, nothing is simulated, following appears in simulation window :

stdout | OMEditInfo | <p>C:/Users/pb07281s/AppData/Local/Temp/OpenModelica/OMEdit/flagtest.exe -port=49429 -logFormat=xmltcp -override=startTime=0,stopTime=1,stepSize=0.002,tolerance=1e-6,solver=dassl,outputFormat=mat,variableFilter=.* -r=flagtest_res.mat -jacobian=coloredNumerical -w -lv=LOG_STATS -override Heat.Q_flow=1000.0</p>
stdout | OMEditInfo | <p>Simulation process finished successfully.</p>

But when plotting the parameter Heat.Q_flow, nothing changed compared to init.xml file

if I use  from OMEdit the flag -output Heat.Q_flow it perfectly work and display the parameter value in the simulation output window

stdout | OMEditInfo | <p>C:/Users/pb07281s/AppData/Local/Temp/OpenModelica/OMEdit/flagtest.exe -port=49445 -logFormat=xmltcp -override=startTime=0,stopTime=1,stepSize=0.002,tolerance=1e-6,solver=dassl,outputFormat=mat,variableFilter=.* -r=flagtest_res.mat -jacobian=coloredNumerical -w -lv=LOG_STATS -output Heat.Q_flow</p>
stdout | unknown | <p>time=1,Heat.Q_flow=500<br>


if I use -overrideFile D:/file.txt, simulation failed :
stdout | OMEditInfo | <p>C:/Users/pb07281s/AppData/Local/Temp/OpenModelica/OMEdit/flagtest.exe -port=49438 -logFormat=xmltcp -override=startTime=0,stopTime=1,stepSize=0.002,tolerance=1e-6,solver=dassl,outputFormat=mat,variableFilter=.* -r=flagtest_res.mat -jacobian=coloredNumerical -w -lv=LOG_STATS -overrideFile E:/file.txt</p>
stdout | error | <p>Simulation process failed. Exited with code -1.</p>

thanks in advance for your help, I made several syntax trial but not managed to get changed this parameter with the flag -override.

Pascal

Re: issue with simulation flag -override OMEdit

Hi,
seems like we're trying to do a similar thing and I'm also struggling to understand the proper syntax and usage of -overrideFile.

What I'm trying to do is:
- create a simple text file that contains all relevant parameters of my system model.
- Keep multiple versions of this to capture different parameter sets for the same system model.
- Run a simulation through OMPython referring to one of the files.

In a first test I tried to use OMEdit/Simulation Setup/Simulation Flags/Additional Simulation Flags edit field:

Code:


-overrideFile=C:\Repos\ompython_tutorial\Modelica\InputData\override_params.txt

The compiler completes without warning. The simulation error message is:

Code:


C:/Work/OMEdit/OMPythonTutorial.Examples.ElectricDriveAxle/OMPythonTutorial.Examples.ElectricDriveAxle.exe -port=53851 -logFormat=xmltcp -override=startTime=0,stopTime=10,stepSize=0.02,tolerance=1e-06,solver=dassl,outputFormat=mat,variableFilter=.* -r=C:/Work/OMEdit/OMPythonTutorial.Examples.ElectricDriveAxle/OMPythonTutorial.Examples.ElectricDriveAxle_res.mat -noEventEmit -iim=symbolic -w -lv=LOG_STATS -overrideFile=C:\Repos\ompython_tutorial\Modelica\InputData\override_params.txt -inputPath=C:/Work/OMEdit/OMPythonTutorial.Examples.ElectricDriveAxle -outputPath=C:/Work/OMEdit/OMPythonTutorial.Examples.ElectricDriveAxle
Simulation process failed. Exited with code -1.

The txt file is empty, to avoid possible errors in the content of the file.
I also tried the following:

Code:


-overrideFile=C:/Repos/ompython_tutorial/Modelica/InputData/override_params.txt
-overrideFile="C:/Repos/ompython_tutorial/Modelica/InputData/override_params.txt"

leading to the same error message.

The simflags docusimflags documentation is saying:

Code:


-overrideFile=value or -overrideFile value

Is there a definition of the syntax of "value" that I have missed?

Would highly appreciate if someone could provide an example line of code for the case that "value" refers to a txt file in the file system. A sample line of the content of the file would also be helpful to avoid further problems.

A comment on how to generate this file from a model would also be helpful. Being able to write the return value of getParameters() in OMPython to a file would be fine, but maybe there is already another approach to this.

Hope someone can comment on this.

Re: issue with simulation flag -override OMEdit

It should just work with "/" alternatively with "\\" for the path separator and with or without quotes for the whole path.

The syntax of inside of the file is just:
variable_name1=variable_value1
variable_name2=variable_value2


You could run with -lv=LOG_ALL to see what error are you getting.

Note that there are structural parameters evaluated during compilation time and you cannot override those. In this case you should get a warning.

I will give it a try myself and see if i can find any issues. I implemented this, and last time i checked it it worked fine.

Re: issue with simulation flag -override OMEdit

The model:

Code:


model TestOverride
  parameter Real a = 1;
  parameter Real b = 2;
  parameter Real c = 3;
  parameter Real d = 3;
  Real x(start=a, fixed=true);
equation
  der(x) = b*c*d*x;
end TestOverride;

The script to build the model:

Code:


loadFile("TestOverride.mo"); getErrorString();
buildModel(TestOverride); getErrorString();

Building the model:

Code:


adrpo33@ida-0030 MINGW64 /c/home/adrpo33/dev/OMTesting/override
$ ~/dev/OpenModelica/build/bin/omc -d=initialization t.mos
true
""
{"C:/home/adrpo33/dev/OMTesting/override/TestOverride","TestOverride_init.xml"}
""

Running some override tests using command line -override or -overrideFile
from the mingw64 terminal:

Code:


adrpo33@ida-0030 MINGW64 /c/home/adrpo33/dev/OMTesting/override
$ ./TestOverride.exe -override=b=5 -lv=LOG_ALL | grep override
LOG_SOLVER        | info    | read override values: b=5
LOG_SOLVER        | info    | override b = 5
LOG_SOLVER        | info    | override done!

adrpo33@ida-0030 MINGW64 /c/home/adrpo33/dev/OMTesting/override
$ cat > override.txt
b=5
c=6

adrpo33@ida-0030 MINGW64 /c/home/adrpo33/dev/OMTesting/override
$ ./TestOverride.exe -overrideFile=override.txt -lv=LOG_ALL | grep override
LOG_SOLVER        | info    | read override values from file: override.txt
LOG_SOLVER        | info    | read override values: b=5,c=6
LOG_SOLVER        | info    | override b = 5
LOG_SOLVER        | info    | override c = 6
LOG_SOLVER        | info    | override done!

Trying from some other directory:

Code:


adrpo33@ida-0030 MINGW64 /c/home/adrpo33/dev/OMTesting/override
$ cp override.txt ../../.

adrpo33@ida-0030 MINGW64 /c/home/adrpo33/dev/OMTesting/override
$ ./TestOverride.exe -lv=LOG_ALL -overrideFile=C:/home/adrpo33/dev/override.txt  | grep override
LOG_SOLVER        | info    | read override values from file: C:/home/adrpo33/dev/override.txt
LOG_SOLVER        | info    | read override values: b=5,c=6
LOG_SOLVER        | info    | override b = 5
LOG_SOLVER        | info    | override c = 6
LOG_SOLVER        | info    | override done!

Trying from Windows Command Line: cmd.exe

Code:


C:\home\adrpo33\dev\OMTesting\override>.\TestOverride.exe -lv=LOG_ALL -overrideFile=C:/home/adrpo33/dev/override.txt | more
LOG_SOLVER        | info    | read override values from file: C:/home/adrpo33/dev/override.txt
LOG_SOLVER        | info    | read override values: b=5,c=6
LOG_SOLVER        | info    | override b = 5
LOG_SOLVER        | info    | override c = 6
LOG_SOLVER        | info    | override done!
LOG_SIMULATION    | info    | read all the DefaultExperiment values:
|                 | |       | | startTime = 0
|                 | |       | | stopTime = 1
|                 | |       | | stepSize = 0.002
|                 | |       | | tolerance = 1e-006
|                 | |       | | solver method: dassl
|                 | |       | | output format: mat
|                 | |       | | variable filter: .*
|                 | |       | | OPENMODELICAHOME: c:/home/adrpo33/dev/OpenModelica/build
LOG_DEBUG         | info    | read xml file for real states
|                 | |       | | Real x(start=0, fixed=true, {nominal=1}, min=-1.79769e+308, max=1.79769e+308)
LOG_DEBUG         | info    | read xml file for real state derivatives
|                 | |       | | Real der(x)(start=0, fixed=false, {nominal=1}, min=-1.79769e+308, max=1.79769e+308)
LOG_DEBUG         | info    | read xml file for real algebraics
LOG_DEBUG         | info    | read xml file for integer variables
LOG_DEBUG         | info    | read xml file for boolean variables
LOG_DEBUG         | info    | read xml file for string variables
LOG_DEBUG         | info    | read xml file for real parameters
|                 | |       | | Real a(start=1, fixed=true, {nominal=1}, min=-1.79769e+308, max=1.79769e+308)
|                 | |       | | Real b(start=5, fixed=true, {nominal=1}, min=-1.79769e+308, max=1.79769e+308)
|                 | |       | | Real c(start=6, fixed=true, {nominal=1}, min=-1.79769e+308, max=1.79769e+308)
|                 | |       | | Real d(start=3, fixed=true, {nominal=1}, min=-1.79769e+308, max=1.79769e+308)
LOG_DEBUG         | info    | read xml file for integer parameters
LOG_DEBUG         | info    | read xml file for boolean parameters
LOG_DEBUG         | info    | read xml file for string parameters
LOG_DEBUG         | info    | read xml file for real alias vars
LOG_DEBUG         | info    | read xml file for integer alias vars
LOG_DEBUG         | info    | read xml file for boolean alias vars
-- More  --

Trying with backwards slashes:

Code:


C:\home\adrpo33\dev\OMTesting\override>.\TestOverride.exe -lv=LOG_ALL -overrideFile=C:\home\adrpo33\dev\override.txt | more
LOG_SOLVER        | info    | read override values from file: C:\home\adrpo33\dev\override.txt
LOG_SOLVER        | info    | read override values: b=5,c=6
LOG_SOLVER        | info    | override b = 5
LOG_SOLVER        | info    | override c = 6
LOG_SOLVER        | info    | override done!
LOG_SIMULATION    | info    | read all the DefaultExperiment values:
|                 | |       | | startTime = 0
|                 | |       | | stopTime = 1
|                 | |       | | stepSize = 0.002
|                 | |       | | tolerance = 1e-006
|                 | |       | | solver method: dassl
|                 | |       | | output format: mat
|                 | |       | | variable filter: .*
|                 | |       | | OPENMODELICAHOME: c:/home/adrpo33/dev/OpenModelica/build
LOG_DEBUG         | info    | read xml file for real states
|                 | |       | | Real x(start=0, fixed=true, {nominal=1}, min=-1.79769e+308, max=1.79769e+308)
LOG_DEBUG         | info    | read xml file for real state derivatives
|                 | |       | | Real der(x)(start=0, fixed=false, {nominal=1}, min=-1.79769e+308, max=1.79769e+308)
LOG_DEBUG         | info    | read xml file for real algebraics
LOG_DEBUG         | info    | read xml file for integer variables
LOG_DEBUG         | info    | read xml file for boolean variables
LOG_DEBUG         | info    | read xml file for string variables
LOG_DEBUG         | info    | read xml file for real parameters
|                 | |       | | Real a(start=1, fixed=true, {nominal=1}, min=-1.79769e+308, max=1.79769e+308)
|                 | |       | | Real b(start=5, fixed=true, {nominal=1}, min=-1.79769e+308, max=1.79769e+308)
|                 | |       | | Real c(start=6, fixed=true, {nominal=1}, min=-1.79769e+308, max=1.79769e+308)
|                 | |       | | Real d(start=3, fixed=true, {nominal=1}, min=-1.79769e+308, max=1.79769e+308)
LOG_DEBUG         | info    | read xml file for integer parameters
LOG_DEBUG         | info    | read xml file for boolean parameters
LOG_DEBUG         | info    | read xml file for string parameters
LOG_DEBUG         | info    | read xml file for real alias vars
LOG_DEBUG         | info    | read xml file for integer alias vars
LOG_DEBUG         | info    | read xml file for boolean alias vars
-- More  --

All seems to work for me, but I haven't tried yet from OMEdit, I will do that later today.

Re: issue with simulation flag -override OMEdit

I tested with OMEdit and it doesn't work because OMEdit already uses -override and you cannot combine -override and -overideFile.

Code:


C:/temp/TestOverride/TestOverride.exe -port=51307 -logFormat=xmltcp -override=startTime=0,stopTime=1,stepSize=0.002,tolerance=1e-6,solver=dassl,outputFormat=mat,variableFilter=.* -r=C:/temp/TestOverride/TestOverride_res.mat -w -lv=LOG_SOLVER,LOG_STATS -overrideFile=c:/home/adrpo33/dev/override.txt -inputPath=C:/temp/TestOverride -outputPath=C:/temp/TestOverride

This is a bug, I think we should solve it by allowing -overrideFile even if -override is already present.
I opened a ticket about it: https://trac.openmodelica.org/OpenModelica/ticket/5696



Re: issue with simulation flag -override OMEdit

The question is which one will take the preference?

Adeel.

Re: issue with simulation flag -override OMEdit

I think it should be an error if they set the same variable. Then we do not need to think about precedence.

Re: issue with simulation flag -override OMEdit

Yeah that would be good.

Adeel.

Re: issue with simulation flag -override OMEdit

Thanks for your systematic testing to figure this out.

About your proposed solution:
Suppose one has setup his model to be initialized from a file.
Then he is running the simulation in OMEdit and want to fine tune the parameters by changing the values and running the simulation.

I'm not sure when and how OMEdit is using override to set values, but I'd assume that according to your proposal the user would get an error message, e.g. parameter xy is already overiden by a file.
Then the user would have to remove xy from the file until he has figured out a better value. Then he will have to restore previous condition of the file. As long he's only changing one parameter at a time this might work. But if he's performing a full blown parameter study or optimization then he's in trouble.

The proposed solution might be easy to implement but is for sure not user friendly.
Another question is, if it might collide with other parameter changing modules like OMOptim?

In the scenario above I'd propose that instead of an error, a warning is given saying: The modified parameter xy will overrule the value from the file abc.txt. It's easier for the user to remove an undesired modification, if he wants the file to dominate, than the other way round.

Re: issue with simulation flag -override OMEdit

Thanks for your input, I will implement it as you suggested, it sounds good. I will also put your text in the Trac so we can follow it up there as well.

Re: issue with simulation flag -override OMEdit

I implemented this now, you can use both -override and -overrideFile and you get a warning if the same variable is used again.

Code:


adrpo33@ida-0030 MINGW64 /c/home/adrpo33/dev/OMTesting/override
$ cat override.txt
b=5
c=6

adrpo33@ida-0030 MINGW64 /c/home/adrpo33/dev/OMTesting/override
$ ./TestOverride.exe -override=stopTime=1,b=1 -overrideFile=override.txt -lv=LOG_ALL | grep overrid
LOG_SOLVER        | info    | using -override=stopTime=1,b=1 and -overrideFile=override.txt
LOG_SOLVER        | info    | read override values from file: override.txt
LOG_SOLVER        | info    | -override=stopTime=1,b=1
LOG_SOLVER        | info    | -overrideFile=b=5,c=6
stdout            | warning | You are overriding variable: b=1 again with b=5.
LOG_SOLVER        | info    | override b = 5
LOG_SOLVER        | info    | override c = 6
LOG_SOLVER        | info    | override done!

Re: issue with simulation flag -override OMEdit

This is now in the nightly-builds (from tomorrow) and in the upcoming 1.14.0-dev.beta3 and the final 1.14.0.

Re: issue with simulation flag -override OMEdit

homotopy function / -override

best wishes for the NEW 2020 !!

I tried Ticket5696.mos  -> OK
BUT: in my model the  homotopy  function is used, and then the parameter values are not "overwritten"
This  I can solve by using the "-noHomotopyOnFirstTry"  option.  Then everything is fine.

The same observation when changing parameter values direct in Model_init.xml
* OMCompiler v1.16.0-dev.99+g1a4ceb3d0      git clone from 2019-12-27
* LINUX64   platform

thx / Johann

There are 0 guests and 0 other users also viewing this topic
You are here: