Building Simulations in the SimulationPkg.st

  1. Create a subclass of Simulation to schedule arrivals and set up resources.
  2. Create subclasses of SimulationObjects to actually DO things in the simulation.
  3. Tell the Simulation instance to proceed for awhile.
  4. Gather the statistics you need, perhaps using some of the statistics gathering routines to send things out to disk.
Simulation instances get sent these messages:

Message:                                              What you should do in that method:                         
initialize                                            * Initialize receiver's instance variables (don't forget   
                                                      to do a super initializefirst!)                            
defineArrivalSchedule                                 * Schedule simulation objects to enter the simulation at   
                                                      various times.                                             
defineResources                                       * Specify the resources that are initially in the          
                                                      simulation                                                 
enter: anObject                                       * If you want to record any information about object       
                                                      arrivals, do it here.                                      
exit: anObject                                        * If you want to record any information about object       
                                                      departures, do it here.                                    
proceed                                               (Let it go - makes the simulation take a step.)            
finishUp                                              (Let it go - ends the simulation.)                         

Simulation instances can create their models using these messages (sent to themselves):

Message:                                                 What it does:                                            
produce: amount of: resourceName                         * Creates the amount of (String) resourceName            
coordinate: resourceName                                 * Sets up resource as being coordinated by the           
                                                         simulation                                               
schedule: actionBlock after: timeDelayInteger            * Schedules the block to occur after a delay             
schedule: actionBlock at: timeInteger                    * Schedules the block to occur at a specific time        
scheduleArrivalOf: aSimulationObject at: timeInteger     * Schedules the object instance to arrive at a time.     
scheduleArrivalOf: aSimulationObjectClass accordingTo:   * Schedules the class (subclass of SimulationObject)     
aProbabilityDistribution                                 to create new instances according to a distribution.     

SimulationObjects are sent these messages:

Message:                                                 What you should do in that method:                       
initialize                                               * If you have any instance variables, initialize them    
                                                         here.                                                    
tasks                                                    * DO WHATEVER THE OBJECT SHOULD DO!                      

SimulationObjects can also send messages to their Simulation like this:

(Simulation active) scheduleArrivalOf: self at:

(Simulation active) time + 90

SimulationObjects use these messages (sent to themselves) to describe their tasks:

Messages:                                                What it does:                                            
holdFor: aTimeDelay                                      * Make the object wait (presumably doing something) in   
                                                         Simulation time.                                         
acquire: amount ofResource: resourceName                 * Ask for amountof resource (a string), and wait in a    
                                                         queue if it's not available.                             
produce: amount ofResource: resourceName                 * Produce amount of resource, releasing waiting people   
                                                         in queue.                                                
release: aStaticResource                                 * If you held something that other people want, let it   
                                                         go.                                                      
inquireFor: amount ofResource: resourceName              * Returns true if that amount of resource is available.  
acquireResource: resourceName                            * Ask for a static resource                              
produceResource: resourceName                            * Create the staticResource                              

For more information, see: