|

Simulate Ships Entering Harbor Each With Containers

Description

This model simulates ships entering the harbor where each ship carries a random number of containers. Additionally, the number of ships entering the harbor each day is random. This model samples a Stochastic element multiple times each time step using a Timed Event generator. An alternative method is shown using a Script element.

Method 1:

We start by sampling the of probability of n number of ships entering the harbor which is stored in a stochastic element. Next we sample the m number of containers on each ship n times per day. We force GoldSim to sample the stochastic element multiple times per timestep by using the Timed Event element triggered n times per day. Finally we conclude by added a recorder element that records the number of containers and the time of occurrence.

Method 2:

In this second, much more compact, approach we use a script element that is triggered each day and contains a FOR loop of n size set by the number of ships entering that day with daily totals stored in an Expression element. It is important to note the script element itself is a vector type containing a number of array elements greater than or equal to the number of days of simulation.

 

Making Better Decisions In An Uncertain World