1
2
3
4
5
6
7
8
9
10 package nl.tudelft.simulation.dsol.tutorial.section43;
11
12 import java.rmi.RemoteException;
13 import java.util.Properties;
14
15 import nl.tudelft.simulation.dsol.formalisms.dess.DifferentialEquation;
16 import nl.tudelft.simulation.dsol.simulators.DESSSimulatorInterface;
17
18 /***
19 * The population differential equation.
20 * <p>
21 * (c) copyright 2003 <a href="http://www.simulation.tudelft.nl">Delft
22 * University of Technology </a>, the Netherlands. <br>
23 * See for project information <a
24 * href="http://www.simulation.tudelft.nl">www.simulation.tudelft.nl </a> <br>
25 * License of use: <a href="http://www.gnu.org/copyleft/gpl.html">General Public
26 * License (GPL) </a>, no warranty <br>
27 *
28 * @author <a href="http://www.tbm.tudelft.nl/webstaf/peterja/index.htm">Peter
29 * Jacobs </a>
30 * @version 1.2 Apr 22, 2004
31 * @since 1.4
32 */
33 public class Population extends DifferentialEquation
34 {
35 /*** Lotka-Volterra parameters */
36 private double a;
37
38 /*** Lotka-Volterra parameters */
39 private double b;
40
41 /*** Lotka-Volterra parameters */
42 private double c;
43
44 /*** Lotka-Volterra parameters */
45 private double d;
46
47 /***
48 * constructs a new Population
49 *
50 * @param simulator
51 * @param timeStep
52 * @throws RemoteException on network exception
53 */
54 public Population(DESSSimulatorInterface simulator, double timeStep)
55 throws RemoteException
56 {
57 super(simulator, timeStep);
58 Properties properties = simulator.getReplication().getRunControl()
59 .getTreatment().getProperties();
60
61 double predator = new Double(properties
62 .getProperty("predator.initialValue")).doubleValue();
63 double prey = new Double(properties.getProperty("prey.initialValue"))
64 .doubleValue();
65 this.initialize(0.0, new double[]{predator, prey});
66 this.a = new Double(properties.getProperty("a")).doubleValue();
67 this.b = new Double(properties.getProperty("b")).doubleValue();
68 this.c = new Double(properties.getProperty("c")).doubleValue();
69 this.d = new Double(properties.getProperty("d")).doubleValue();
70 }
71
72 /***
73 * @see nl.tudelft.simulation.dsol.formalisms.dess.DifferentialEquationInterface#dy(double,
74 * double[])
75 */
76 public double[] dy(double time, double[] y)
77 {
78 double[] dy = new double[2];
79 dy[0] = -this.a * y[0] + this.b * y[0] * y[1];
80 dy[1] = this.c * y[1] - this.d * y[1] * y[0];
81 return dy;
82 }
83 }