# Difference between revisions of "STEM Solvers"

Line 15: | Line 15: | ||

[[Image:FiniteDifferenceFigure.png|800px]] | [[Image:FiniteDifferenceFigure.png|800px]] | ||

+ | |||

+ | (the figure assumes h = 1). The next value is thus calculated as: | ||

+ | |||

+ | y(t+h) = y(t) + x*y'(t)+(1-x)*y'(t+x) | ||

+ | |||

=== Runge Kutta Cash-Karp === | === Runge Kutta Cash-Karp === | ||

=== Dormand Prince === | === Dormand Prince === |

## Revision as of 18:38, 16 January 2012

When you create a new scenario in STEM, you need to specify which solver to use. A solver is simply the method used to determine how the state of a simulation changes from one time step to the next. Models for populations and diseases in STEM are all designed to carry out this change or derivative calculation given a current state. How the derivative is applied to determine the next state is where solvers differ.

## Available solvers

### Finite Difference

The finite difference solver is the most straightforward (and fastest) solver available. It's using Euler's method and simply estimates the next value from the current value plus the derivative:

y(t+h) = y(t) +h*y'(t)

where h is the step size (default 1 day in STEM as defined by the sequencer). Label values in STEM are often constrained to a positive value. For instance, the count of a population can never go negative, and this is also true for any population assigned to a particular compartment state. When a constrained value goes negative, the finite difference solvers rescales the time step to avoid this as illustrated in this figure:

(the figure assumes h = 1). The next value is thus calculated as:

y(t+h) = y(t) + x*y'(t)+(1-x)*y'(t+x)