stan-dev / stan-dev/stan

Generic Dosing Mechanism

Open
#1,454 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
C++
Stars
2.8k
Forks
388
Avg merge
2d 17h
Merged PRs (30d)
15

Description

For many practical pharmacometric models the integrate_ode function is pretty limiting as it only solves the ODE system at given times but cannot modify the system at those times. A more generic function would require events, which pair an event time and some used-defined function that modifies the state of the ODE at that time, for example

void event_action(real[] states, real[] params, real[] x).

These events would then be collected into a dynamically-sized vector of events,

event_table events;
event_table.add(1, increment_1);
...
event_table.add(493, multiply_2);

which would be passed into a new integrate function,

integrate_ode_with_events(ode, y0, t0, ts, events, theta, x_r, x_i).

This new function then concatenates the vector of observation times and the
event times, removes duplicates, and orders the unique times. The solver is
run to each time, with the resulting state saved if an observation if necessary
and then input to the event functor if necessary.

Thoughts? This would require introducing a type with a method which would
be new to the language. Maybe just having an add_event function with an
event_table and function as arguments?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the existing integrate_ode implementation and the surrounding ODE interface. Compare its handling of observation times with the proposed event_table and integrate_ode_with_events API; done would require a settled event representation and behavior for ordered, deduplicated observation and event times.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.