I am trying to implement a basic battery model, but the problem can be generalized.
The battery energy is stored in an additional state which evolves according to differential equations (implementing AdditionalEquations interface).
The battery energy decreases when a consumer is ON.
When the battery reached a limit, 70%, the consumer turns OFF. A detector is used for that. The consumer handles the event and notifies the battery model to stop consumption.
The problem is that the detector depends on the model which is updated when the detector detects an event… then the progator get lost and loop infinitely.
So far we found a workaround by setting the derivative to -1e-10 instead of 0 when there is no consumption, which break the infinite loop.
I think it’s an architecture problem in our implementation, and the solution might be to break the dependence loop. Have any of you got the same kind of problem ? Is there a proper way of implementing this kind of mechanism ?
I have isolated the code showing the problem in the following file.
DetectorClosedLoopControlTest.java (7.0 KB)