SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
Continuous.java
1/*
2 * Class: Continuous
3 * Description: provides the basic structures and tools for
4 continuous-time simulation
5 * Environment: Java
6 * Software: SSJ
7 * Copyright (C) 2001 Pierre L'Ecuyer and Universite de Montreal
8 * Organization: DIRO, Universite de Montreal
9 * @author
10 * @since
11 *
12 *
13 * Licensed under the Apache License, Version 2.0 (the "License");
14 * you may not use this file except in compliance with the License.
15 * You may obtain a copy of the License at
16 *
17 * http://www.apache.org/licenses/LICENSE-2.0
18 *
19 * Unless required by applicable law or agreed to in writing, software
20 * distributed under the License is distributed on an "AS IS" BASIS,
21 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 * See the License for the specific language governing permissions and
23 * limitations under the License.
24 *
25 */
26package umontreal.ssj.simevents;
27
57public abstract class Continuous {
58
59 // Private variables:
60
61 boolean active; // This variable is currently being integrated.
62 double value; // Current value of the variable.
63 Event ev; // Event to be executed after each integ. step,
64
65 // String name;
66 double phi;
67 double pi;
68 double buffer;
69 double sum;
70
71 private Simulator sim;
72
77 public Continuous() {
78 active = false;
79 this.sim = Simulator.getDefaultSimulator();
80 }
81
106 public Continuous(Simulator sim) {
107 if (sim == null)
108 throw new NullPointerException();
109 active = false;
110 this.sim = sim;
111 }
112
118 public void init(double val) {
119 value = val;
120 }
121
127 public double value() {
128 return value;
129 }
130
137 return sim;
138 }
139
146 public void setSimulator(Simulator sim) {
147 if (sim == null)
148 throw new NullPointerException();
149 this.sim = sim;
150 }
151
156 public void startInteg() {
157 sim.continuousState().startInteg(this);
158 }
159
165 public void startInteg(double val) {
166 init(val);
167 startInteg();
168 }
169
175 public void stopInteg() {
176 sim.continuousState().stopInteg(this);
177 }
178
188 public abstract double derivative(double t);
189
195 public void afterEachStep() {
196 }
197
208 public static void selectEuler(double h) {
209 Simulator.getDefaultSimulator().continuousState().selectEuler(h);
210 }
211
220 public static void selectRungeKutta4(double h) {
221 Simulator.getDefaultSimulator().continuousState().selectRungeKutta4(h);
222 }
223
232 public static void selectRungeKutta2(double h) {
233 Simulator.getDefaultSimulator().continuousState().selectRungeKutta2(h);
234 }
235
236}
void selectRungeKutta4(double h)
Selects a Runge-Kutta method of order 4 as the integration method to be used, with step size h.
void selectRungeKutta2(double h)
Selects a Runge-Kutta method of order 2 as the integration method to be used, with step size h.
void selectEuler(double h)
Selects the Euler method as the integration method, with the integration step size h,...
void startInteg(double val)
Same as startInteg, after initializing the variable to val.
void init(double val)
Initializes or reinitializes the continuous-time variable to val.
void setSimulator(Simulator sim)
Sets the simulator linked to this continuous-time variable.
static void selectRungeKutta2(double h)
Selects a Runge-Kutta method of order 2 as the integration method to be used, with step size h.
void startInteg()
Starts the integration process that will change the state of this variable at each integration step.
static void selectEuler(double h)
Selects the Euler method as the integration method, with the integration step size h,...
static void selectRungeKutta4(double h)
Selects a Runge-Kutta method of order 4 as the integration method to be used, with step size h.
Continuous()
Constructs a new continuous-time variable linked to the default simulator, without initializing it.
void afterEachStep()
This method is executed after each integration step for this Continuous variable.
void stopInteg()
Stops the integration process for this continuous variable.
double value()
Returns the current value of this continuous-time variable.
abstract double derivative(double t)
This method should return the derivative of this variable with respect to time, at time .
Simulator simulator()
Returns the simulator linked to this continuous-time variable.
Continuous(Simulator sim)
Constructs a new continuous-time variable linked to the given simulator, without initializing it.
This abstract class provides event scheduling tools.
Definition Event.java:53
Represents the executive of a discrete-event simulator.
static Simulator getDefaultSimulator()
Returns the default simulator instance used by the deprecated class.