1
2
3
4
5
6
7
8
9
10 package nl.tudelft.simulation.dsol.tutorial.section43;
11
12 import java.rmi.RemoteException;
13
14 import nl.tudelft.simulation.dsol.ModelInterface;
15 import nl.tudelft.simulation.dsol.formalisms.dess.DifferentialEquationInterface;
16 import nl.tudelft.simulation.dsol.simulators.DESSSimulatorInterface;
17 import nl.tudelft.simulation.dsol.simulators.SimulatorInterface;
18 import nl.tudelft.simulation.dsol.statistics.Persistent;
19 import nl.tudelft.simulation.dsol.statistics.charts.XYChart;
20
21 /***
22 * A Life <br>
23 * (c) copyright 2003 <a href="http://www.simulation.tudelft.nl"> Delft
24 * University of Technology </a>, the Netherlands. <br>
25 * See for project information <a href="http://www.simulation.tudelft.nl">
26 * www.simulation.tudelft.nl </a> <br>
27 * License of use: <a href="http://www.gnu.org/copyleft/gpl.html">General Public
28 * License (GPL) </a>, no warranty <br>
29 *
30 * @version 1.0 Dec 9, 2003 <br>
31 * @author <a href="http://www.simulation.tudelft.nl/people/jacobs.html">Peter
32 * Jacobs </a>
33 */
34 public class Life implements ModelInterface
35 {
36
37 /***
38 * constructs a new Life
39 */
40 public Life()
41 {
42 super();
43 }
44
45 /***
46 * @see nl.tudelft.simulation.dsol.ModelInterface
47 * #constructModel(nl.tudelft.simulation.dsol.simulators.SimulatorInterface)
48 */
49 public void constructModel(final SimulatorInterface simulator)
50 throws RemoteException
51 {
52 DESSSimulatorInterface dessSimulator = (DESSSimulatorInterface) simulator;
53
54
55 Population population = new Population(dessSimulator, 0.1);
56
57 Persistent preyPopulation = new Persistent("prey population",
58 dessSimulator, population,
59 DifferentialEquationInterface.VALUE_CHANGED_EVENT[0]);
60
61 Persistent predatorPopulation = new Persistent("predator population",
62 dessSimulator, population,
63 DifferentialEquationInterface.VALUE_CHANGED_EVENT[1]);
64
65 XYChart chart = new XYChart(dessSimulator, "population");
66 chart.add(preyPopulation);
67 chart.add(predatorPopulation);
68 }
69 }