3import umontreal.ssj.simevents.*;
4import umontreal.ssj.rng.*;
5import umontreal.ssj.randvar.*;
6import umontreal.ssj.stat.*;
7import java.util.LinkedList;
12 LinkedList<Customer> waitList =
new LinkedList<Customer>();
13 LinkedList<Customer> servList =
new LinkedList<Customer>();
18 double arrivTime, servTime;
21 public QueueEv(
double lambda,
double mu) {
26 public void simulate(
double timeHorizon) {
32 new EndOfSim().schedule(timeHorizon);
42 cust.servTime = genServ.nextDouble();
43 if (servList.size() > 0) {
44 waitList.addLast(cust);
45 totWait.update(waitList.size());
48 servList.addLast(cust);
56 servList.removeFirst();
57 if (waitList.size() > 0) {
59 Customer cust = waitList.removeFirst();
60 totWait.update(waitList.size());
61 custWaits.add(
Sim.
time() - cust.arrivTime);
62 servList.addLast(cust);
74 public static void main(String[] args) {
75 double lambda = 1.0 / 10.0;
76 double mu = 1.0 / 9.0;
80 System.out.println(queue.custWaits.
report());
81 System.out.println(queue.totWait.
report());
void actions()
This is the method that is executed when this event occurs.
void actions()
This is the method that is executed when this event occurs.
void actions()
This is the method that is executed when this event occurs.
This class implements random variate generators for the exponential distribution.
This is the base class for all random variate generators over the real line.
double nextDouble()
Generates a random number from the continuous distribution contained in this object.
Extends the abstract class RandomStreamBase by using as a backbone (or main) generator the combined m...
A subclass of umontreal.ssj.stat.StatProbe, for collecting statistics on a variable that evolves in s...
String report()
Returns a string containing a report on this collector since its last initialization.
void init()
Initializes the statistical collector and puts the current value of the corresponding variable to 0.
Event()
Constructs a new event instance, which can be placed afterwards into the event list of the default si...
void schedule(double delay)
Schedules this event to happen in delay time units, i.e., at time sim.time() + delay,...
This static class contains the executive of a discrete-event simulation.
static void stop()
Tells the simulation executive to stop as soon as it takes control, and to return control to the prog...
static double time()
Returns the current value of the simulation clock.
static void start()
Starts the simulation executive.
static void init()
Reinitializes the simulation executive by clearing up the event list, and resetting the simulation cl...
void init()
Initializes the statistical collector.
String report()
Returns a formatted string that contains a report on this probe.