View Javadoc
1   package org.sim0mq.test;
2   
3   import java.rmi.RemoteException;
4   
5   import javax.naming.NamingException;
6   
7   import nl.tudelft.simulation.dsol.SimRuntimeException;
8   import nl.tudelft.simulation.dsol.experiment.Replication;
9   import nl.tudelft.simulation.dsol.experiment.ReplicationMode;
10  import nl.tudelft.simulation.dsol.simtime.SimTimeDouble;
11  import nl.tudelft.simulation.dsol.simulators.DEVSSimulator;
12  
13  /**
14   * <p>
15   * Copyright (c) 2002-2014 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved.
16   * <p>
17   * See for project information <a href="http://www.simulation.tudelft.nl/"> www.simulation.tudelft.nl</a>.
18   * <p>
19   * The DSOL project is distributed under a BSD-style license.<br>
20   * @version Aug 15, 2014 <br>
21   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
22   */
23  public class MM1Queue41Application
24  {
25      /** */
26      private DEVSSimulator.TimeDouble simulator;
27  
28      /** */
29      private MM1Queue41Model model;
30  
31      /**
32       * Construct a console application.
33       * @throws SimRuntimeException on error
34       * @throws RemoteException on error
35       * @throws NamingException on error
36       */
37      protected MM1Queue41Application() throws SimRuntimeException, RemoteException, NamingException
38      {
39          this.model = new MM1Queue41Model();
40          this.simulator = new DEVSSimulator.TimeDouble();
41          Replication<Double, Double, SimTimeDouble> replication =
42                  new Replication<>("rep1", new SimTimeDouble(0.0), 0.0, 100.0, this.model);
43          this.simulator.initialize(replication, ReplicationMode.TERMINATING);
44          this.simulator.scheduleEventAbs(100.0, this, this, "terminate", null);
45          this.simulator.start();
46      }
47  
48      /** stop the simulation. */
49      protected final void terminate()
50      {
51          System.out.println("average queue length = " + this.model.qN.getSampleMean());
52          System.out.println("average queue wait   = " + this.model.dN.getSampleMean());
53          System.out.println("average utilization  = " + this.model.uN.getSampleMean());
54          System.exit(0);
55      }
56  
57      /**
58       * @param args can be left empty
59       * @throws SimRuntimeException on error
60       * @throws RemoteException on error
61       * @throws NamingException on error
62       */
63      public static void main(final String[] args) throws SimRuntimeException, RemoteException, NamingException
64      {
65          new MM1Queue41Application();
66      }
67  
68  }