import scalation.simulation._ import scalation.mathstat._ /**::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: A simple Bank simulation based on the process interaction world view that has several :: concurrent entities flowing through a model make up of multiple components. */ object Bank extends Application { /** The model contains components that are used by entities (SimActors). * It directs the simulation and maintains an agenda (priority queue) and a clock. */ val director = new Model ("bank") /** The source will generate 100 entities (customers) over time. */ val entry = new Source ("entry", director, Customer, 100, Array (100, 100, 30, 30), Uniform (4000, 6000)) /** The teller queue is a FCFS queue for waiting customers. */ val tellerQ = new WaitQueue ("tellerQ", Array (210, 100, 80, 30)) /** The bank teller is modeled as resource to be utilized by customers. */ val teller = new Resource ("teller", tellerQ, 1, Array (290, 100, 30, 30), Uniform (9000, 11000)) /** Once customers finish, they are terminated at the sink. */ val door = new Sink ("door", Array (400, 100, 30, 30)) /** Pathway from entry to teller queue. */ val entry2tellerQ = new Path ("entry2tellerQ", entry, tellerQ, Uniform (900, 1100)) /** Pathway from teller to door. */ val teller2door = new Path ("teller2door", teller, door, Uniform (900, 1100)) /** Add all of the components to the model. */ director.addComponents (List (entry, tellerQ, teller, door, entry2tellerQ, teller2door)) /**::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Bank customers are entities that follow the script given in the act method. */ case class Customer () extends SimActor ("c", director) { def act () { entry2tellerQ.move () if (teller.busy) tellerQ.waitIn () teller.utilize () teller.release () teller2door.move () door.leave () } // act } // Customer director.startSim () } // Bank