Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow parameter values to be provided after translation #2952

Open
henrikt-ma opened this issue Jun 9, 2021 · 4 comments · May be fixed by #3075
Open

Allow parameter values to be provided after translation #2952

henrikt-ma opened this issue Jun 9, 2021 · 4 comments · May be fixed by #3075
Milestone

Comments

@henrikt-ma
Copy link
Collaborator

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:

  • Providing start is just counter-acting the purpose of the rule that requires parameters to be defined. A warning will be issued, but there is a substantial risk that users won't pay attention. Also if the typical action to take would be to set start even though there's no good default to use, why not simply allow the non-explicit start to be used?
  • Providing a declaration equation instead of start has the same drawbacks, but is even worse as there won't even be a warning when translating the model without providing a sensible parameter value.
  • Requiring the parameter when it is time to simulate and creating a one-off model on the fly basically means that the model should be rebuilt each time a different parameter value is used. This can easily lead to lots of unnecessary rebuilding, and doesn't match intuitive understanding of what it means to simply change the value of a non-structural parameter.

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 HansOlsson added this to the Phone 2021-4 milestone Jun 12, 2021
@HansOlsson
Copy link
Collaborator

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
Copy link
Collaborator Author

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

@HansOlsson
Copy link
Collaborator

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.

HansOlsson added a commit to HansOlsson/ModelicaSpecification that referenced this issue Jun 23, 2021
henrikt-ma added a commit to henrikt-ma/ModelicaSpecification that referenced this issue Dec 11, 2021
@henrikt-ma
Copy link
Collaborator Author

henrikt-ma commented Mar 14, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants