3import umontreal.ssj.simevents.*;
4import umontreal.ssj.rng.*;
5import umontreal.ssj.randvar.*;
6import umontreal.ssj.stat.*;
9 static final double minute = 1.0 / 60.0;
20 Tally statServed =
new Tally(
"Nb. served per day");
21 Tally avWait =
new Tally(
"Average wait per day (hours)");
25 public void actions() {
26 meanDelay = 2.0 * minute;
32 public void actions() {
33 double u = streamTeller.nextDouble();
40 while (nbWait > 0 && nbBusy < nbTellers) {
50 public void actions() {
57 public void actions() {
59 meanDelay = 2.0 * minute;
64 public void actions() {
69 private boolean balk() {
70 return (nbWait > 9) || (nbWait > 5 && (5.0 * streamBalk.nextDouble() < nbWait - 5));
76 if (nbBusy < nbTellers) {
98 public void simulOneDay() {
111 statServed.
add(nbServed);
116 public void simulateDays(
int numDays) {
117 for (
int i = 1; i <= numDays; i++)
119 System.out.println(statServed.
report());
120 System.out.println(avWait.
report());
123 public static void main(String[] args) {
124 new BankEv().simulateDays(100);
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 Erlang random variate generators using the convolution method.
This class implements random variate generators for the Erlang distribution with parameters and .
This class implements random variate generators for the exponential distribution.
static double nextDouble(RandomStream s, double lambda)
Uses inversion to generate a new exponential variate with parameter.
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...
double sum()
Returns the sum cumulated so far for this probe.
void update()
Updates the accumulator using the last value passed to update(double).
void init()
Initializes the statistical collector and puts the current value of the corresponding variable to 0.
This abstract class provides event scheduling tools.
boolean cancel()
Cancels this event before it occurs.
void reschedule(double delay)
Cancels this event and reschedules it to happen in delay time units.
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 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 add(double x)
Gives a new observation x to the statistical collector.
String report()
Returns a formatted string that contains a report on this probe.
This interface defines the basic structures to handle multiple streams of uniform (pseudo)random numb...