Skip to content

WIP: Fix initial_state() and history()

Tjerk Vreeken requested to merge fix-initial-state-history into master
  • On top of !323 (merged)

  • After some more discussion, it actually seems better to just remove initial_state. There are so many things that can be very confusing when keeping both around.

Before we had the supposed default implementation in OptimizationProblem that history() also returned values in initial_state(), and vice versa. This would never actually work properly, as one would end up in an endless loop.

The reason this bug was not encountered until this point, is that ModelicaMixin did not call super() for initial_state(). Furthermore, PIMixin/IOMixin did not call super() either. So in practice we never got the behavior that history() referred to values in intial_state() and vice versa.

The "mother" method of the two is history(), as this is the only method actually called in CollocatedIntegratedOptimizationProblem. This means that when a user uses any IOMixin class, but implements their own initial_state() method, this method would never actually be called.

To fix this bug, we remove the supposed referral of initial_state() to history() (which was not there in practice), but we keep the call to initial_state() in OptimizationProblem's implementation of history(). We also make sure that all classes properly call their respective super() methods.

Closes #1123 (closed)

Edited by Tjerk Vreeken

Merge request reports