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

Initialization of state in onnx fmu #22

Merged
merged 17 commits into from
Mar 12, 2024

Conversation

KristofferSkare
Copy link
Collaborator

@KristofferSkare KristofferSkare commented Mar 11, 2024

Fixes #5

This PR introduces the possibility to initialize the state of the generated mlfmu using automatically generated fmu parameters from the interface json.

The interface is changed by expanding the InternalState filed to include an optional start_value. If start_value is set then parameters for initialization is generated for all the states corresponding to the agent_output_indexes. If initialization is used name arg also has to be set to something. This will be the name of the automatically generated parameter.

This is done by generating a parameter for each state that should be possible to initialize with a name given by the interface.
The generated parameters (FmiInputVariable) are given a new argument (agent_state_init_indexes) that specify with index in the state array that should be initialized with this parameter. This arg is set automatically from the interface.json. Since this is a arg of FmiInputVariable, any FMU input or parameter could, in principle, be used to initialize state. But for now there is no way for a normal fmu input/parameter to have this argument set to something. So a future improvement could be to open up the possibility of normal fmu inputs and parameters to be used to initialize state.

@KristofferSkare KristofferSkare added the enhancement New feature or request label Mar 11, 2024
@KristofferSkare KristofferSkare self-assigned this Mar 11, 2024
@KristofferSkare KristofferSkare linked an issue Mar 11, 2024 that may be closed by this pull request
Copy link
Collaborator

@Jorgelmh Jorgelmh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great implementation! I like the possibility of implementing inputs as initializers for internal states, just need to evaluate how we can do this with the already existing implementation and logic behind FMU inputs (refer to my other comment).

src/mlfmu/types/fmu_component.py Outdated Show resolved Hide resolved
src/mlfmu/types/fmu_component.py Show resolved Hide resolved
@KristofferSkare KristofferSkare merged commit 9c4a858 into main Mar 12, 2024
11 checks passed
@KristofferSkare KristofferSkare deleted the feature/5-initialization-of-state branch March 12, 2024 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Initialization of State
2 participants