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

change boolean variable value from command line

change boolean variable value from command line

Hi,
I need to recall the simulation several times so I use the runnable generated file with the option -overrideFile initfile.txt.
With this solution I'm able to change the init values of all status variables but I'm not able to change the value of a boolean constant.
Is there a way in order to change a boolean variable (or close/open a switch) without recompile the model?

Thank you

Davide

Re: change boolean variable value from command line

No. Constants are replaced in the model with their value during compilation.
You have to make it a parameter. And even so, if is a structural parameter it might not be possible to change.

Re: change boolean variable value from command line

thank you Adrian for the quick reply.
Is there a workaround in order to change a parameter value using the init file values?
My idea is to place a capacitor without discharge and set the initial voltage.
The model reads the voltage. If it is under a threshold the state is "false", if it is over the threshold the state is "true"
I need "only" to change a state from 0 to 1 in order to switch on/off part of my model

regards

Davide

Re: change boolean variable value from command line

Well, if making it a parameter (with fixed=false) instead of a constant doesn't help then the
only way I can think of is to make 2 executables, one with the constant set to true and one
with it set to false and call them with -override for the other values.

Cheers,
Adrian Pop/

Re: change boolean variable value from command line

Thank you Adrian!
Your solution is effective and easier than mine.
I'll try it!

regards

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