1
2
3
4
5
6
7
8
9
10 package nl.tudelft.simulation.sne.c1;
11
12 import java.rmi.RemoteException;
13 import java.util.logging.Level;
14
15 import nl.tudelft.simulation.dsol.ModelInterface;
16 import nl.tudelft.simulation.dsol.experiment.Experiment;
17 import nl.tudelft.simulation.dsol.simulators.DESSSimulator;
18 import nl.tudelft.simulation.dsol.simulators.DESSSimulatorInterface;
19 import nl.tudelft.simulation.dsol.simulators.SimulatorInterface;
20 import nl.tudelft.simulation.jstats.ode.integrators.NumericalIntegrator;
21 import nl.tudelft.simulation.language.io.URLResource;
22 import nl.tudelft.simulation.logger.Logger;
23 import nl.tudelft.simulation.xml.dsol.ExperimentParser;
24
25 /***
26 * The C1 Test Model. see for detailed specification <a
27 * href="http://www.argesim.org/comparisons/c1/definition/c1def.html">
28 * http://www.argesim.org/comparisons/c1/definition/c1def.html </a>
29 * <p>
30 * (c) copyright 2003 <a href="http://www.simulation.tudelft.nl">Delft
31 * University of Technology </a>, the Netherlands. <br>
32 * See for project information <a
33 * href="http://www.simulation.tudelft.nl">www.simulation.tudelft.nl </a> <br>
34 * License of use: <a href="http://www.gnu.org/copyleft/gpl.html">General Public
35 * License (GPL) </a>, no warranty <br>
36 *
37 * @author <a href="http://www.tbm.tudelft.nl/webstaf/peterja/index.htm">Peter
38 * Jacobs </a>
39 * @version 1.2 Apr 20, 2004
40 * @since 1.4
41 */
42 public class C1TaskA implements ModelInterface
43 {
44 /*** the numericalMethod */
45 private short numericalMethod;
46
47 /***
48 * the default constructor constructs a new C1
49 */
50 public C1TaskA()
51 {
52 this(NumericalIntegrator.MILNE);
53 }
54
55 /***
56 * constructs a new C1
57 *
58 * @param numericalMethod the numericalMethod to use
59 */
60 public C1TaskA(short numericalMethod)
61 {
62 super();
63 this.numericalMethod = numericalMethod;
64 }
65
66 /***
67 * @see nl.tudelft.simulation.dsol.ModelInterface
68 * #constructModel(nl.tudelft.simulation.dsol.simulators.SimulatorInterface)
69 */
70 public void constructModel(SimulatorInterface simulator)
71 throws RemoteException
72 {
73 DESSSimulatorInterface dessSimulator = (DESSSimulatorInterface) simulator;
74 FCenter fCenter = new FCenter(dessSimulator, 0.001,
75 this.numericalMethod);
76 long startTime = System.currentTimeMillis();
77 System.out.println(fCenter.y(10.0)[2]);
78 long duration = System.currentTimeMillis() - startTime;
79 System.out.println(duration);
80 }
81
82 /***
83 * executes C1
84 *
85 * @param args the commandline arguments
86 */
87 public static void main(String[] args)
88 {
89 Logger.setLogLevel(Level.WARNING);
90 if (args.length != 0)
91 {
92 System.out
93 .println("Usage: java nl.tudelft.simulation.sne.c1.tasks.C1");
94 System.exit(0);
95 }
96 try
97 {
98
99 Experiment experiment = ExperimentParser
100 .parseExperiment(URLResource
101 .getResource("/nl/tudelft/simulation/sne/c1/C1TaskA.xml"));
102
103
104 DESSSimulatorInterface simulator = new DESSSimulator();
105 experiment.setSimulator(simulator);
106
107 experiment.setModel(new C1TaskA(NumericalIntegrator.ADAMS));
108 experiment.start();
109 } catch (Exception exception)
110 {
111 exception.printStackTrace();
112 }
113 }
114 }