Something went wrong on our end
-
Brutzman, Don authoredBrutzman, Don authored
RunTwoCranesBerth.java 3.56 KiB
package SimkitOpenDis7Examples.run;
import SimkitOpenDis7Examples.ShipArrivalProcess;
import SimkitOpenDis7Examples.TwoCraneBerths;
import simkit.Schedule;
import simkit.random.RandomVariate;
import simkit.random.RandomVariateFactory;
import simkit.stat.CollectionSizeTimeVaryingStats;
import simkit.stat.SimpleStatsTally;
/**
* Run simple two-berth model for 10 years (3650 days).
* <h2>Output:</h2><pre>
ShipArrivalProcess.1
unloadTimeGenerator = Uniform (0.500, 1.500)
interarrivalTimeGenerator = Exponential (0.700)
TwoCraneBerths.2
Simulation ended at time 3,650.0
Number of ships arriving: 5,135
Number of ships unloaded: 5,129
Maximum # in queue: 11
Average # in queue: 0.6834
Average # busy berths: 1.1737
Average time in system: 1.3207
Average delay in queue: 0.4857
</pre>
*
* @author abuss@nps.edu
*/
public class RunTwoCranesBerth
{
/** Default constructor */
public RunTwoCranesBerth()
{
// default constructor
}
/**
* Run a simple program and compute statistical measurement of results.
* @param args the command line arguments
*/
public static void main(String[] args) {
RandomVariate interarrivalTimeGenerator =
RandomVariateFactory.getInstance("Exponential", 0.7);
RandomVariate unloadingTimeGenerator =
RandomVariateFactory.getInstance("Uniform", 0.5, 1.5);
ShipArrivalProcess shipArrivalProcess =
new ShipArrivalProcess(interarrivalTimeGenerator,
unloadingTimeGenerator);
TwoCraneBerths twoCraneBerths = new TwoCraneBerths();
shipArrivalProcess.addSimEventListener(twoCraneBerths);
SimpleStatsTally delayInQueueStat = new SimpleStatsTally("delayInQueue");
SimpleStatsTally timeInSystemStat = new SimpleStatsTally("timeInSystem");
CollectionSizeTimeVaryingStats numberInQueueStat =
new CollectionSizeTimeVaryingStats("queue");
CollectionSizeTimeVaryingStats numberInBerthStat =
new CollectionSizeTimeVaryingStats("berth");
// SimplePropertyDumper simplePropertyDumper = new SimplePropertyDumper();
// twoCraneBerths.addPropertyChangeListener(simplePropertyDumper);
twoCraneBerths.addPropertyChangeListener(delayInQueueStat);
twoCraneBerths.addPropertyChangeListener(timeInSystemStat);
twoCraneBerths.addPropertyChangeListener(numberInQueueStat);
twoCraneBerths.addPropertyChangeListener(numberInBerthStat);
System.out.println(shipArrivalProcess);
System.out.println(twoCraneBerths);
double stopTime = 10 * 365;
Schedule.stopAtTime(stopTime);
Schedule.setVerbose(false);
Schedule.reset();
Schedule.startSimulation();
System.out.printf("%nSimulation ended at time %,.1f%n%n",
Schedule.getSimTime());
System.out.printf("Number of ships arriving:\t%,d%n", shipArrivalProcess.getNumberArrivals());
System.out.printf("Number of ships unloaded:\t%,d%n", timeInSystemStat.getCount());
System.out.printf("Maximum # in queue:\t\t%.0f%n", numberInQueueStat.getMaxObs());
System.out.printf("Average # in queue:\t\t%.4f%n", numberInQueueStat.getMean());
System.out.printf("Average # busy berths:\t\t%.4f%n", numberInBerthStat.getMean());
System.out.printf("Average time in system:\t\t%.4f%n",
timeInSystemStat.getMean());
System.out.printf("Average delay in queue:\t\t%.4f%n",
delayInQueueStat.getMean()); }
}