modelica / ModelicaSpecification

Specification of the Modelica Language
https://specification.modelica.org
Creative Commons Attribution Share Alike 4.0 International
101 stars 41 forks source link

Allow parameter values to be provided after translation #2952

Open henrikt-ma opened 3 years ago

henrikt-ma commented 3 years ago

In System Modeler we are currently trying to become strict about parameters with fixed = true and neither a declaration equation nor explicit start. Until now, this has only been treated with a warning, and the non-explicit value of start has been used.

What we find now is that some models can't be built, even though the parameters don't need to become evaluated. None of the alternatives for dealing with this appeals to us:

To remedy the situation, one could allow tools to delay the requirement that all parameters with fixed = true have values. For example,

model DeferredParameterValue
  parameter Real p;
end DeferredParameterValue;

would be legal as a simulation model, but it would be required that no value for p is assumed during translation, and tools must require that an explicit value for p is provided at initialization.

Can others also see how this would be useful, or am I missing a way to handle this within the constraints of the current specification?

HansOlsson commented 3 years ago

Can others also see how this would be useful, or am I missing a way to handle this within the constraints of the current specification?

I could see how it could be handled within the current specification. You cannot simulate the model without the parameter-values, but you could translate it as a step before that (and then change parameters).

henrikt-ma commented 3 years ago

Yes, that's the goal, but would all tools agree that such a model is valid given the current specification text?

HansOlsson commented 3 years ago

Separate issues: should only use start-value for parameter if explicitly set. And only for non-structural (and there can be no cycles for it).

Can then delay setting the parameter from translation until simulation. (No error.) Agreement. Quality of implementation to be able to translate.

henrikt-ma commented 1 year ago

Design meeting:

Alternative design:

model DeferredParameterValue
  parameter Real p = break; /* Explicit that there's no value until initialization */
end DeferredParameterValue;

Some tools translate all models to FMUs, and one can't have parameters without a value in an FMU.