memilio icon indicating copy to clipboard operation
memilio copied to clipboard

Make models non-virtual to simplify python bindings and SimulationBase

Open reneSchm opened this issue 3 months ago • 0 comments

Motivation / Current Behaviour

Currently the python bindings bind a Simulation<CompartmentalModel>, making the user provide InfectionState, Population and Parameters. For that to work, CompartmentalModel::get_derivatives is virtual, and the Simulation(Base) holds a unique_ptr of the model.

Enhancement description

We can simplify this by using the type definitions inside the Model to obtain InfectionState etc. for the bindings. Since these are mostly model specific, this effectively reduces the number of template arguments by 2. Also, we then could drop the virtual from get_derivatives (and get_flows), as well as storing the model directly in the Simulation, removing the need for non-default copy ctor/assignment.

Additional context

  • pycode/memilio-simulation/memilio/simulation/bindings/compartments/compartmental_model.h
  • cpp/memilio/compartments/simulation_base.h

Checklist

  • [x] Attached labels, especially loc:: or model:: labels.
  • [x] Linked to project

reneSchm avatar Aug 25 '25 11:08 reneSchm