Appendix E: Examples of Simulation Studio Models
Updating an Input Distribution
In certain scenarios, you might want to change a particular input distribution at the start of a simulation run. Other times, you might want to change a distribution dynamically during the simulation run. This example demonstrates both of these possibilities. You can find the project files for this example in the folder \projects\examples\docUpdateDistribution in your Simulation Studio installation directory.
The easiest way to change the parameters for a distribution at the beginning of the run is to use the DataStreamDescription factor for the Numeric Source block, as demonstrated in the model in Figure E.49. In this example, two processing times are randomly sampled for each entity and are saved as its attributes. These processing times are used downstream in the model as service times in two different Server blocks.
To explore different processing time distributions, you first define two factors. One factor, called ExponentialMean, is anchored to the DataStreamDescription factor candidate for the block labeled Numeric Source1. Assume that the distribution type for the first processing time is fixed as Exponential and only the mean of the distribution will vary. The block Numeric Source1 has its distribution type defined as Exponential in its Block Properties dialog box. After including the ExponentialMean factor in the Experiment window, you can vary the mean of the Exponential distribution for the Numeric Source1 block for different runs of the model in the Experiment window.
Figure E.49: Using Factors to Change an Input Distribution

The second factor, called ProcessTime2, is anchored to the DataStreamDescription factor candidate for the block labeled Numeric Source2. For the second processing time, suppose you are interested in varying the type of its distribution. In this case, it does not matter what distribution type is currently specified in the Numeric Source2 Block Properties dialog box. The factor ProcessTime2 is used to set the distribution type and parameters in the Experiment window at the start of the run.
Figure E.50 shows the Anchors dialog box for the model, and Figure E.51 shows the Experiment window with the processing time factors included. Two responses have also been created for the average processing times. Each response is anchored to the MeanValue candidate of the corresponding Number Holder block. For the first design point in the Experiment window, the mean of the Exponential distribution for the block Numeric Source1 is set to 3, and the distribution for the block Numeric Source2 is set to Normal with a mean of 10 and a standard deviation of 1. The second design point specifies different values for each of these settings. The format for a DataStreamDescription factor is the same as for a value that is supplied to the InStreamPolicy port of the Numeric Source block. For more information about the format of the DataStreamDescription factor candidate, see the Numeric Source block overview in Appendix A: Templates.
Figure E.50: Anchors Dialog Box for Updating Distributions Using Factors

Figure E.51: Experiment Window for Updating Distributions Using Factors

The following example demonstrates how the InStreamPolicy port of a Numeric Source block can be used to dynamically change a distribution during a run rather than at the beginning. In the model in Figure E.52, each entity samples a processing time from a different normal distribution. To accomplish this, an entity first randomly samples mean and standard deviation values and assigns those values as its attributes. Because the InStreamPolicy port of a Numeric Source block requires a string input, a Formula block is used to concatenate the mean and standard deviation values into a single string that the InStreamPolicy port can process.
Figure E.52: Dynamically Updating a Distribution during the Simulation Run

Figure E.53 shows the format of the expression used in the Formula block to generate the string for the InStreamPolicy port. As shown in Figure E.52, a Gate block triggers the evaluation of the expression in the Formula block, and the resulting string is then passed to a String Holder block, where it is held until needed.
Figure E.53: Formula Block Properties Dialog Box for Generating the InStreamPolicy Port String

Next, the Gate block generates a true Boolean signal. This signal is passed to the InUpdate port of the Numeric Source block labeled Numeric Source3. When the Numeric Source block receives a true Boolean value in its InUpdate port, it pulls the value from its InStreamPolicy port, which in this example is connected to the OutData port of the String Holder block. The string that is held by the String Holder block is passed to the block labeled Numeric Source3, updating the parameters of the Normal distribution. Note that the order of actions in the Gate block is important because the string value that is pulled by the InStreamPolicy port must be available before the true Boolean value is passed to the InUpdate port of the Numeric Source block.