Simulation Programming with VBASim
This chapter shows how simulations of some of the examples in Chap. 3 can be programmed in VBASim. The goals of the chapter are to introduce VBASim, and to hint at the experiment design and analysis issues that will be covered in later chapters. A complet
- PDF / 431,580 Bytes
- 38 Pages / 439.36 x 666.15 pts Page_size
- 105 Downloads / 238 Views
Simulation Programming with VBASim
This chapter shows how simulations of some of the examples in Chap. 3 can be programmed in VBASim. The goals of the chapter are to introduce VBASim, and to hint at the experiment design and analysis issues that will be covered in later chapters. A complete listing of the VBASim source code can be found in Appendix A. This chapter can be skipped without loss of continuity; Java and Matlab versions of the source code and this chapter may be found at the book website.
4.1 VBASim Overview VBASim is a collection of VBA subs, functions and class modules that aid in developing discrete-event simulations. They are entirely open source and can be modified to suit the user. The random-number and random-variate generation routines are VBA translations of the corresponding routines in simlib (Law 2007) which is written in C. VBASim is designed to be easy to understand and use, but not necessarily efficient. Here is a brief description of the subs and functions in VBASim: Sub VBASimInit: Initializes VBASim for use, typically called before the start of each replication. Sub Schedule: Schedules future events. Sub SchedulePlus: Schedules future events and allows an object to be stored with the event. Sub Report: Writes a result to a specific row and column of an Excel worksheet. Sub ClearStats: Clears certain statistics being recorded by VBASim. Sub InitializeRNSeed: Initializes the random-number generator; typically called only once in a simulation. Function Expon: Generates exponentially distributed random variates. Function Uniform: Generates uniformly distributed random variates.
B.L. Nelson, Foundations and Methods of Stochastic Simulation: A First Course, International Series in Operations Research & Management Science 187, DOI 10.1007/978-1-4614-6160-9 4, © Springer Science+Business Media New York 2013
41
42
Function Function Function Function Function
4 Simulation Programming with VBASim
Random integer: Generates a random integer. Erlang: Generates Erlang distributed random variates. Normal: Generates normally distributed random variates. Lognormal: Generates lognormally distributed random variates. Triangular: Generates triangularly distributed random variates.
The random-variate generation functions take two types of arguments: parameters, and a random-number stream; the random-number stream is always the last argument. For instance X = Uniform(10, 45, 2) generates random-variates that are uniformly distributed between 10 and 45, using stream 2. As you already know, the pseudorandom numbers we use to generate random variates in simulations are essentially a long list. Random-number streams are just different starting places in this list, spaced far apart. The generator in VBASim (which is a translation of the generator in Law 2007) has 100 streams. Calling Sub InitializeRNSeed sets the initial position of each stream. Then each subsequent call to a variate-generation routine using stream # advances stream # to the next pseudorandom number. The need for streams is discussed in
Data Loading...