Book Contents
Book Contents
Previous
Previous
Next
Next
SAS/OR: The QSIM Application

Formulas

The Router, Switch, and Modifier components use formulas to control routing and set attributes. Formulas are specified in a Formula Manager window. Figure 6.6 shows one such window with the formula 5.0 + X, where X is a random variable with distribution E(1), exponentially distributed with mean 1.

cpformul.gif (9751 bytes)

Figure 4.1: Formula Manager Window

Formulas are built using an interface that is similar to that used when building models. The palette has a set of icons that can be dragged and dropped into the Formula Manager window. You use these to build expressions. The following table shows some of the elements that are used to build expressions:

IconDescription
formula.gif (990 bytes)another formula
formulat.gif (955 bytes)a transaction attribute
formulac.gif (1025 bytes)the simulation clock
formulm2.gif (988 bytes)a component in the model
formulad.gif (999 bytes)an observation of a variable in a SAS data set
formulan.gif (977 bytes)a number constant
formuls2.gif (968 bytes)a string constant

As with components, each of these elements has a pop-up menu associated with it. For example, the random variable icon formular.gif (952 bytes)shown in Figure 6.6 has a pop-up menu, shown in Figure 4.2.

popupfor.gif (4744 bytes)

Figure 4.2: Popup Menu on the Random Variable Formula Element

If you select Edit, the window shown in Figure 4.3 is displayed. From this window you select the distribution for the random variable. When the formula is evaluated (to set an attribute or determine transaction routing, for example), an observation of the random variable is made.

cpformur.gif (2956 bytes)

Figure 4.3: Control Panel for the Random Variable Formula Element

Another important formula element is the model element, formulm2.gif (988 bytes). Recall the example discussed in the "Switch Component" . There, the model in Figure 2.11 routes transactions to the shortest queue. The control panel on the Switch shown in Figure 2.10 has TRUE as a case for routing to component Queue 1. This means that you want the formula associated with this switch to return TRUE if Queue 1 is shorter than Queue 2. To accomplish this, you compare the sizes of the two queues and return TRUE if the size of Queue 1 is less than the size of Queue 2.

formulaq.gif (1217 bytes)

Figure 4.4: Formula for Comparing the Size of Two Queues

Figure 4.4 shows the formula for accomplishing this. The edit window for the left-hand model element is shown in Figure 4.5.

cpformum.gif (4550 bytes)

Figure 4.5: The Model Element Edit Window

The Model list box contains the simulation components. When you select one of these components the Query list box displays query messages for that component. When the formula is evaluated, the result of the query of the identified component will be used. For example, when the formula shown in Figure 4.4 is evaluated, the model element will query Queue 1 with the message size, which will return the number of elements in its queue. Similarly, if you edit the model element on the right-hand side of the > and set it to query size of Queue 2, the formula will evaluate to TRUE if Queue 1 has fewer elements than Queue 2. In this case, the switch will send the transaction to Queue 1.

You should be careful when validating your models that they are behaving as you want them. There is not a great amount of error-checking done when formulas are evaluated, particularly with regard to type, but every error will not be detected. For example, a Router may expect a TRUE or FALSE returned from a formula, but you could enter a valid formula that evaluates to a number or a string. The QSIM Application would not detect this type of error but would function as if a nonzero number were TRUE.

The formula syntax is standard with two exceptions. First, functions of one argument, such as the trigonometric functions, are specified in reverse polish style. Thus, an expression like log(X) would be displayed as in in Figure 4.6.

formulal.gif (1109 bytes)

Figure 4.6: A Formula for the Log of a Random Variable

Functions of two arguments, such as max and min, are specified between the arguments. So, an expression like max(X,\pi) would be displayed as in Figure 4.7.

formulam.gif (1421 bytes)

Figure 4.7: A Formula for the Maximum of a Random Variable and \pi

Book Contents
Book Contents
Previous
Previous
Next
Next
Top
Top