SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
umontreal.ssj.simevents.Continuous Class Referenceabstract

Represents a variable in a continuous-time simulation. More...

Inheritance diagram for umontreal.ssj.simevents.Continuous:
tutorial.PreyPred.Preds tutorial.PreyPred.Preys

Public Member Functions

 Continuous ()
 Constructs a new continuous-time variable linked to the default simulator, without initializing it.
 Continuous (Simulator sim)
 Constructs a new continuous-time variable linked to the given simulator, without initializing it.
void init (double val)
 Initializes or reinitializes the continuous-time variable to val.
double value ()
 Returns the current value of this continuous-time variable.
Simulator simulator ()
 Returns the simulator linked to this continuous-time variable.
void setSimulator (Simulator sim)
 Sets the simulator linked to this continuous-time variable.
void startInteg ()
 Starts the integration process that will change the state of this variable at each integration step.
void startInteg (double val)
 Same as startInteg, after initializing the variable to val.
void stopInteg ()
 Stops the integration process for this continuous variable.
abstract double derivative (double t)
 This method should return the derivative of this variable with respect to time, at time \(t\).
void afterEachStep ()
 This method is executed after each integration step for this Continuous variable.

Static Public Member Functions

static void selectEuler (double h)
 Selects the Euler method as the integration method, with the integration step size h, in time units, for the default simulator.
static void selectRungeKutta4 (double h)
 Selects a Runge-Kutta method of order 4 as the integration method to be used, with step size h.
static void selectRungeKutta2 (double h)
 Selects a Runge-Kutta method of order 2 as the integration method to be used, with step size h.

Detailed Description

Represents a variable in a continuous-time simulation.

This abstract class provides the basic structures and tools for continuous-time simulation, where certain variables evolve continuously in time, according to differential equations. Such continuous variables can be mixed with events and processes.

Each type of continuous-time variable should be defined as a subclass of Continuous. The instances of these subclasses are the actual continuous-time variables. Each subclass must implement the method derivative which returns its derivative with respect to time. The trajectory of this variable is determined by integrating this derivative. The subclass may also reimplement the method afterEachStep, which is executed immediately after each integration step. By default (in the class Continuous), this method does nothing. This method could, for example, verify if the variable has reached a given threshold, or update a graphical illustration of the variable trajectory.

When creating a class representing a continuous variable, the #toString method can be overridden to display information about the continuous variable. This information will be displayed when formating the event list as a string.

Each continuous variable has a linked simulator represented by an instance of the Simulator class. If no simulator is provided explicitly when constructing a variable, the default simulator returned by Simulator.getDefaultSimulator is used.

Definition at line 57 of file Continuous.java.

Constructor & Destructor Documentation

◆ Continuous() [1/2]

umontreal.ssj.simevents.Continuous.Continuous ( )

Constructs a new continuous-time variable linked to the default simulator, without initializing it.

Definition at line 77 of file Continuous.java.

◆ Continuous() [2/2]

umontreal.ssj.simevents.Continuous.Continuous ( Simulator sim)

Constructs a new continuous-time variable linked to the given simulator, without initializing it.

Parameters
simthe simulator associated to this variable.
public Continuous (String name) \begin{hide} { this(); this.name =
name; } \end{hide}
Continuous()
Constructs a new continuous-time variable linked to the default simulator, without initializing it.

Constructs a new continuous-time variable (same as Continuous()) with name name and linked to the default simulator. This name can be used to identify the Continuous variable in traces and reports.

public Continuous (Simulator sim, String name) \begin{hide} {
this(sim); this.name = name; } \end{hide}
Represents the executive of a discrete-event simulator.

Constructs a new continuous-time variable (same as Continuous(sim)) with name name. This name can be used to identify the Continuous variable in traces and reports.

Definition at line 106 of file Continuous.java.

Member Function Documentation

◆ afterEachStep()

void umontreal.ssj.simevents.Continuous.afterEachStep ( )

This method is executed after each integration step for this Continuous variable.

Here, it does nothing, but every subclass of Continuous may reimplement it.

Definition at line 195 of file Continuous.java.

◆ derivative()

abstract double umontreal.ssj.simevents.Continuous.derivative ( double t)
abstract

This method should return the derivative of this variable with respect to time, at time \(t\).

Every subclass of Continuous that is to be instantiated must implement it. If the derivative does not depend explicitly on time, \(t\) becomes a dummy parameter. Internally, the method is used with \(t\) not necessarily equal to the current simulation time.

Parameters
ttime at which the derivative must be computed

Reimplemented in tutorial.PreyPred.Preds, and tutorial.PreyPred.Preys.

◆ init()

void umontreal.ssj.simevents.Continuous.init ( double val)

Initializes or reinitializes the continuous-time variable to val.

Parameters
valinitial value of the variable

Definition at line 118 of file Continuous.java.

◆ selectEuler()

void umontreal.ssj.simevents.Continuous.selectEuler ( double h)
static

Selects the Euler method as the integration method, with the integration step size h, in time units, for the default simulator.

The non-static method selectEuler in ContinuousState can be used to set the integration method for any given simulator. This method appears here only to keep compatibility with older versions of SSJ; using a non-static Simulator instance rather than the default simulator is recommended.

Parameters
hintegration step, in simulation time units

Definition at line 208 of file Continuous.java.

◆ selectRungeKutta2()

void umontreal.ssj.simevents.Continuous.selectRungeKutta2 ( double h)
static

Selects a Runge-Kutta method of order 2 as the integration method to be used, with step size h.

The non-static method selectRungeKutta2 in ContinuousState can be used to set the integration method for any given simulator. This method appears here only to keep compatibility with older versions of SSJ; using a non-static Simulator instance rather than the default simulator is recommended.

Definition at line 232 of file Continuous.java.

◆ selectRungeKutta4()

void umontreal.ssj.simevents.Continuous.selectRungeKutta4 ( double h)
static

Selects a Runge-Kutta method of order 4 as the integration method to be used, with step size h.

The non-static method selectRungeKutta4 in ContinuousState can be used to set the integration method for any given simulator. This method appears here only to keep compatibility with older versions of SSJ; using a non-static Simulator instance rather than the default simulator is recommended.

Definition at line 220 of file Continuous.java.

◆ setSimulator()

void umontreal.ssj.simevents.Continuous.setSimulator ( Simulator sim)

Sets the simulator linked to this continuous-time variable.

This method should not be called while this variable is active.

Parameters
simthe simulator of the current variable

Definition at line 146 of file Continuous.java.

◆ simulator()

Simulator umontreal.ssj.simevents.Continuous.simulator ( )

Returns the simulator linked to this continuous-time variable.

Returns
the current simulator of the variable

Definition at line 136 of file Continuous.java.

◆ startInteg() [1/2]

void umontreal.ssj.simevents.Continuous.startInteg ( )

Starts the integration process that will change the state of this variable at each integration step.

Definition at line 156 of file Continuous.java.

◆ startInteg() [2/2]

void umontreal.ssj.simevents.Continuous.startInteg ( double val)

Same as startInteg, after initializing the variable to val.

Parameters
valinitial value to start integration from

Definition at line 165 of file Continuous.java.

◆ stopInteg()

void umontreal.ssj.simevents.Continuous.stopInteg ( )

Stops the integration process for this continuous variable.

The variable keeps the value it took at the last integration step before calling stopInteg.

Definition at line 175 of file Continuous.java.

◆ value()

double umontreal.ssj.simevents.Continuous.value ( )

Returns the current value of this continuous-time variable.

Returns
the current value of the variable

Definition at line 127 of file Continuous.java.


The documentation for this class was generated from the following file: