Class EventHandlingSimulator

Class Documentation

class EventHandlingSimulator

The EventHandlingSimulator class runs a forward simulation and processes events, measurements or output timepoints in general.

Public Functions

inline EventHandlingSimulator(gsl::not_null<Model*> model, gsl::not_null<Solver const*> solver, gsl::not_null<FwdSimWorkspace*> ws, std::vector<realtype> *dJzdx)

EventHandlingSimulator.

Parameters:
  • model – The model to simulate.

  • solver – The solver to use for the simulation.

  • ws – The workspace to use for the simulation.

  • dJzdx – State-derivative of event likelihood (dimension nJ x nx x nMaxEvent, ordering =?)

void run(realtype t, ExpData const *edata, std::vector<realtype> const &timepoints, bool store_diagnosis)

run Run the simulation.

It will run the simulation from the initial time of this period to the final timepoint of this period, handling events and data points as they occur.

Expects the model and the solver to be set up, and ws to be initialized for this period.

Parameters:
  • t – The initial time of this period.

  • edata – Any experimental data associated with this simulation. nullptr if no experimental data is associated with this period.

  • timepoints – The output timepoints or measurement timepoints of this period. This must contain at least the final timepoint of this period.

  • store_diagnosis – Whether to store diagnosis in the solver at each timepoint in timepoints.

void run_steady_state(std::function<bool(bool)> check_convergence, int convergence_check_frequency, int &sim_steps)

Simulate until steady state and handle events along the way.

This will run the simulation until the steady state is reached. Events will be handled as they occur. No data points will be handled during this simulation (not for event-resolved nor for time-resolved observables).

Parameters:
  • check_convergence – Function to check convergence based on the current values in ws_. Input: whether xdot has to be recomputed. Output: whether convergence has been reached.

  • convergence_check_frequency – Frequency of convergence checks.

  • sim_steps – Number of simulation steps taken until convergence or error.

inline int get_root_counter() const

Returns maximal event index for which the timepoint is available.

Returns:

index

inline int get_event_counter() const

Returns maximal event index for which simulations are available.

Returns:

index

SimulationState get_simulation_state()

Creates a carbon copy of the current simulation state variables.

Returns:

state

void handle_events(bool initial_event, ExpData const *edata)

Execute everything necessary for the handling of events.

Assumes that at least one event triggered.

Parameters:
  • initial_event – initial event flag

  • edata – experimental data

void handle_initial_events(ExpData const *edata)

Handle initial events.

Check if there are any initial events that need to be handled and execute the necessary steps.

Parameters:

edata – experimental data

Public Members

PeriodResult result

Results for the current simulation period.

int it_ = -1

Time index in the current list of timepoints