# Difference between revisions of "STEM Solvers"

Line 20: | Line 20: | ||

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

− | + | The algorithm finds the smallest x among all differential equations solved and rescales all label values accordingly. The finite difference solver is able to take advance of multi-core CPUs and each CPU is assigned a sub-set of the graph to work on. | |

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

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

## Revision as of 18:47, 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)

The algorithm finds the smallest x among all differential equations solved and rescales all label values accordingly. The finite difference solver is able to take advance of multi-core CPUs and each CPU is assigned a sub-set of the graph to work on.