A variable is a resource that stores a numerical value and allows you to assign a name to that value. You can then use the variable name in place of the actual value in the equations that you create. You can also use variables in functions and/or as conditional output values in conditional blocks, logic gates and branch gates.
A variable starts with an assigned initial value, which may be fixed or varied during simulation in BlockSim. You can use variables:
In event analysis flowcharts, to act as a constant (i.e., maintain a fixed numerical value during simulation).
In event analysis flowcharts, to temporarily store the output value of a block during simulation. See the next section for more information.
In event analysis flowcharts, to perform a sensitivity analysis, which involves varying the value of one or two variables between runs (i.e., sets of simulations). For example, if you are analyzing potential investment strategies, you may wish to vary the number of years that you will be investing and/or the percentage of your income that will be invested to see how different inputs will affect the final results.
As the basis for a dynamic model, which represents a fixed probability, duration or cost. The variable can be programmatically varied during simulation, thereby changing the value of the model for successive simulation runs.
In process flow simulation diagrams, to define a throughput amount.
As inputs for certain fields in simulation RBDs via simulation worksheets, allowing programmatic variation of the field value during simulation.
You can use variables to hold numerical values passed to them during simulation. In event analysis flowcharts, the following blocks are able to store their output values in variables:
Standard blocks
Result storage blocks
Flag markers
Counter blocks
Depending on your choice in the When to Reset field of the variable's properties window, you can configure the variable to retain the value passed to it during simulation or reset the variable to its initial value at specific times. The options are:
Reset After Each Simulation (i.e., reset after a single pass through the flowchart)
Reset After Each Run (i.e., reset after each set of simulations)
Reset After Analysis (i.e., reset after each set of runs)
Never Reset
When the simulations end, the variable always returns to its initial starting value unless you have selected Never Reset. If you wish to keep the value used during simulation, you can use a result storage block to store it.
The following example demonstrates two things: a) how a variable may be used to store an output value and b) how a variable may be used in an equation.
In the following configuration, the first block calculates the gross profit from a sale, and then stores its output into a variable called "Profit." The conditional block determines whether the gross profit exceeds 500. If the output is true, the third block deducts the sale's commission from the profit, and overwrites the stored value with the new output.
The following picture shows the properties window of the variable called "Profit." The initial value of this variable is set to 0.
The following picture shows the Block Properties window of the first block in the example. The output of the equation is stored in the variable.
The following picture shows the Block Properties window of the third block in the flowchart. The equation shows that the commission is deducted from the existing value in the variable, and then the variable is overwritten with the new result. At the end of the simulation, the result storage block in the flowchart stores the final value of the variable, and then the variable resets to 0.