Runge-Kutta integration is a clever extension of Euler integration that allows substantially improved accuracy, without imposing a severe computational burden. The idea is to step into the interval and evaluate derivatives. This is similar to shortening TIME STEP in Euler integration, but provides more accuracy with less increase in computation. Second order Runge-Kutta integration has an error that is proportional to TIME STEP cubed for an integration step and proportional to TIME STEP squared for the whole simulation. Fourth order Runge-Kutta integration has an error that is proportional to TIME STEP to the fifth power for an integration step and proportional to TIME STEP to the fourth power for the whole simulation.
When Vensim performs Runge-Kutta integration, it holds all exogenous and test inputs (STEP,PULSE and RAMP) constant over the integration interval. This is done for computational efficiency, and because the discontinuities that might result from changing these inputs invalidate the premise on which the Runge-Kutta techniques are built. The pure delay functions (FIXED, MATERIAL and INFORMATION) do not change within a Runge Kutta computation and the MESSAGE function always returns zero.
Regardless of the integration technique you use, TIME STEP remains an important determinant of when to compute exogenous values, and when to compare the model to data.
Fixed Step Size
The fixed step size methods are much like Euler integration. Using the rates of change of Levels as computed at Time second order Runge-Kutta makes a half step (TIME STEP/2) , computes new rates of change, and uses those rates of change to go from Time to Time + TIME STEP. Fourth order Runge-Kutta integration does three intermediate evaluations of the rates of changes and then weights these to give the final result. In just doing computation, second order Runge-Kutta should take twice as long as Euler and fourth order Runge-Kutta four times as long for a given TIME STEP. The actual differences in speed are not this great because of a number of additional things being done during a simulation.
Automatically Adjusted Step Size
The automatic adjustment of step size uses a step halving approach. A second or fourth order Runge-Kutta step is made, and then repeated two times at half the step size. The results are then compared. If, for any Level, the difference between the two computations is greater than ABSOLUTE TOLERANCE and the implied difference over TIME STEP is bigger than the value of the Level (from the smaller step size) times RELATIVE TOLERANCE, the step is declared a failure. The initial step size is divided by two and the process repeated. If, on the other hand, the process does not detect any errors over an entire TIME STEP, the initial step size is doubled. The step size is never made bigger than TIME STEP.
You can set ABSOLUTE TOLERANCE and RELATIVE TOLERANCE by writing equations for them inside of your model as in
ABSOLUTE TOLERANCE=.001 ~Dmnl~Max acceptable error for RK4|
RELATIVE TOLERANCE=.001 ~Dmnl~Max acceptable relative error for RK4|
These should be constant equations since only the initial value will be used. If you do not write equations for them, the default value of .001 will be used for both.
Because of the way adjustment is implemented, you can use a variable TIME STEP with this integration technique and get good results. The internally computed step size is not reported or accessible. Vensim limits the step size to be bigger than or equal to TIME STEP/256. If Vensim cannot achieve the desired accuracy because of this limitation, a warning message is displayed at each TIME STEP in which it fails to achieve the desired accuracy.
NOTE The automatically adjusted step size algorithms always yield a result at least as accurate as the fixed step size algorithm with half the value of TIME STEP.
For more information on numerical integration techniques the book Numerical Recipes in C referenced in Information Resources is very good reading.