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

run!(neuralFMU..) in batch.jl should also work for FMUs which are not able to get/set their state #119

Open
juguma opened this issue Dec 19, 2023 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@juguma
Copy link

juguma commented Dec 19, 2023

This is a feature request.
For FMUs which are not able to get/set their state, the proposed call sequence to batch the training (as in juliacon_2023.ipynb) does not work.
The first instance where it fails is when calling batchDataSolution. Then one receives the warning that the respective FMU is not able to set/get the state. Later, the function run! tries to set this state anyway, and this leads to the crash of the program.

My proposal is to:

  • keep the warning
  • modify the function
    run!(neuralFMU::ME_NeuralFMU, batchElement::FMU2SolutionBatchElement; lastBatchElement=nothing, kwargs...)
    and batchDataSolution
    as follows:
  • move the assert and warning (based on existence of fmi2CanGetSetState(neuralFMU.fmu) from batchDataSolution to run!,
  • call all the functions to get and set a state only if fmi2CanGetSetState(neuralFMU.fmu) is true.

Due to IP I can't share an MWE here, but @ThummeTo, I can share one with you, and of course discuss.

@ThummeTo
Copy link
Owner

Yep, the next patch includes this because I need to train on such an FMU :-)
Further, you can optionally pass a discrete state (this is not part of FMI, but sometimes you know it) to improve initialization of batch elements. If you know the continuous as well as the discrete state, you can initialize your FMU in the correct "FMU state" without having the fmiGet/SetState functions.

@ThummeTo ThummeTo self-assigned this Dec 19, 2023
@juguma
Copy link
Author

juguma commented Dec 19, 2023

Yippieyayeah.
I was just about to state a PR, but I guess you already have more modifications anyway, so I keep it locally.
For now I just hope that the discrete states are fine or immediately settle in. If I face this problems with more complex FMUs (and we still haven't added Get and Set in our FMUs), I'll get back to you.

juguma added a commit to juguma/FMIFlux.jl that referenced this issue Dec 19, 2023
…h can't get/set their state, this is not done (the warning is kept). Could fix ThummeTo#119 (FMIFlux).
@ThummeTo ThummeTo added the enhancement New feature or request label Feb 3, 2024
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

No branches or pull requests

2 participants