ThummeTo / FMIFlux.jl

FMIFlux.jl is a free-to-use software library for the Julia programming language, which offers the ability to place FMUs (fmi-standard.org) everywhere inside of your ML topologies and still keep the resulting model trainable with a standard (or custom) FluxML training process.
MIT License
57 stars 15 forks source link

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

Open juguma opened 11 months ago

juguma commented 11 months ago

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:

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

ThummeTo commented 11 months ago

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.

juguma commented 11 months ago

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.