package nl.tudelft.simulation.dsol.tutorial.section41; import java.rmi.RemoteException; import javax.naming.NamingException; import org.djutils.logger.CategoryLogger; import org.pmw.tinylog.Level; import nl.tudelft.simulation.dsol.SimRuntimeException; import nl.tudelft.simulation.dsol.experiment.ReplicationInterface; import nl.tudelft.simulation.dsol.experiment.SingleReplication; import nl.tudelft.simulation.dsol.simulators.DEVSSimulator; /** *
* Copyright (c) 2002-2022 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See * for project information https://simulation.tudelft.nl. The DSOL * project is distributed under a three-clause BSD-style license, which can be found at * * https://simulation.tudelft.nl/dsol/3.0/license.html. *
* @author Alexander Verbraeck */ public class MM1Queue41Application { /** */ private DEVSSimulator.TimeDouble simulator; /** */ private MM1Queue41Model model; /** * Construct a console application. * @throws SimRuntimeException on error * @throws RemoteException on error * @throws NamingException on error */ protected MM1Queue41Application() throws SimRuntimeException, RemoteException, NamingException { this.simulator = new DEVSSimulator.TimeDouble("MM1Queue41Application"); this.model = new MM1Queue41Model(this.simulator); ReplicationInterface.TimeDouble replication = new SingleReplication.TimeDouble("rep1", 0.0, 0.0, 1000.0); this.simulator.initialize(this.model, replication); this.simulator.scheduleEventAbs(1000.0, this, this, "terminate", null); this.simulator.start(); } /** stop the simulation. */ public void terminate() { System.out.println("average queue length = " + this.model.qN.getWeightedSampleMean()); System.out.println("average queue wait = " + this.model.dN.getSampleMean()); System.out.println("average utilization = " + this.model.uN.getWeightedSampleMean()); System.exit(0); } /** * @param args String[]; can be left empty * @throws SimRuntimeException on error * @throws RemoteException on error * @throws NamingException on error */ public static void main(final String[] args) throws SimRuntimeException, RemoteException, NamingException { CategoryLogger.setAllLogLevel(Level.TRACE); new MM1Queue41Application(); } }