﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
6039	Allow to change parameters before resimulating when -iif is used to import start values	Francesco Casella	Andreas Heuermann	"The [https://openmodelica.org/doc/OpenModelicaUsersGuide/latest/simulationflags.html#simflag-iif -iif] flag allows to import start values for parameters and variables from the results of previous simulations. These can be used to ensure the convergence of the initialization equations, or possibly be used directly to start the simulation, if [https://openmodelica.org/doc/OpenModelicaUsersGuide/latest/simulationflags.html#simflag-iim -iim=none] is also set. 

These flags can be set in OMEdit from the Simulation Setup window, Simulation Flags, Equation System Initialization File/Time.

As far as I understand, when the simulation executable is run, it first reads in the start values from the {{{_init.xml}}} file, and then it overwrites whatever values are found in the {{{-iif}}} file before starting the simulation. @AnHeuermann, please correct me if I'm wrong here.

Unfortunately, this means that it is not possible to import all the start values and parameters of a previous simulation, ''change some parameter values'' in the Variables Browser, and then restart a simulation that will produce results different from the imported simulation, because the the changed parameter values will end up in the {{{_init.xml}}} file and will be overriden by the imported values. As a matter of fact, this makes the whole {{{-iif/-iim}}} thing not very useful in practice, if used from OMEdit, because it only allow to re-run an existing simulation, possibly only changing the solver or the solver parameters.

We need to find a way to make this possible, in an easy and intuitive way.

The most natural idea that comes to my mind is to have another runtime option, say {{{-iis}}}, which selects what start values should actually be imported from the file when the {{{-iif}}} option is activated. Possible values:
- {{{-iis=all}}} (default) import everything, as it happens today
- {{{-iis=nostates}}} import everything, except start values of state variables
- {{{-iis=noparams}}} import everything, except start values of {{{fixed = true}}} parameters
- {{{-iis=nostatesnoparams}}} combines the two previous options

Adding this option to the Simulation Setup | Translation Flag window will solve this issue, enabling a wide range of interesting use cases, without the need of further work in OMEdit. In particular, it will make possible to change parameters and/or initial state values before resimulating.

The {{{-iis=noparams}}} option should only affect {{{fixed = true}}} parameters, which are the ones that can be changed from the Variables Browser before resimulating. {{{fixed = false}}} parameters are determined by initial equations, so I think it makes more sense to keep the imported start values for them, to avoid convergence problems.

The only shortcoming I see of this solution is that the {{{-iis}}} flag will apply broadly to the entire set of parameters/initial states. This means, it won't be possible, e.g., to import all the parameter and initial states from the file ''except some'', that may be changed before resimulating. 

It would be nice if we could actually do that, but I'm afraid this can't be done easily with the current OMEdit workflow, which is based on the GUI updating the {{{_init.xml}}} file, which is always read before {{{-iif}}} is applied. Any suggestion about how to overcome this limitation in a simple way would be welcome, I have no idea how to do that."	enhancement	new	blocker	1.19.0	Run-time				Adeel Asghar Karim Adbdelhak Andrea Bartolini massimo ceraolo daniel.bouskela@… tobias.krenz@… Lennart Ochel
