Defining the Simulation Model
Since there are equal chances that the market will be Slow, OK, or Hot, we want to create an uncertain variable that selects among these three
possibilities, by drawing a random number - say 1, 2 or 3 - with equal probability. We can do this easily in the RASON modeling language using an
integer uniform probability distribution or PsiIntUniform(). We'll then base our Sales Volume and Selling Price on this uncertain
variable. See the marketType uncertain variable in our example code below. A sample drawn from a discrete distribution is always
one of a set of discrete values, such as integer values.
Next, we'll deal with Unit Cost. We have not just three, but many possible values for this variable: It can be anywhere from $4.50 to $8.50,
with a most likely cost of $6.50. A crude but effective way to model this is to use a triangular distribution. The RASON modeling language
provides a function called PsiTriangular() for this distribution (see the unitCost uncertain variable below).
When creating any RASON model, our model definition begins with a simple open bracket. When creating any RASON model, our model definition begins
with a simple open bracket. Next we see three optional, but strongly recommended, high level properties, modelName, modelDescription and modelType.
ModelName assigns a name to the model for easy retrieval later, modelDescription gives a short description of the problem and modelType informs the
RASON Server that this model is a simulation model.
Since we are creating a simulation model, rather than an optimization model, our first section will be uncertainVariables where we
will define our two uncertain variables using PsiIntUniform() and PsiTrangular() followed by uncertainFunctions where we will calculate the Net Profit.
{
modelName: "UGForecastSimExample",
modelType: "simulation",
uncertainVariables: {
marketType: { formula: "PsiIntUniform(1,3)"},
unitCost: {formula: "PsiTriangular(4.5, 6.5, 8.5)"}
},
The next section, formulas, calculates our Sales Volume (salesVolume), Selling Price (sellingPrice),
Gross Sales (grossSales) and Total Unit Cost (totalCosts). Our Sales Volume and Selling Price are based on the value of
the marketType uncertain variable. If marketType equals 1, the Sales Volume and Selling Price are 50,000 and $11, if
marketType equals 2, the Sales Volume and Selling Price are 75,000 and $10 and if marketType equals 3, the Sales
Volume and Selling Price are 100,000 and $8. Gross Sales is calculated by multiplying the Selling Price by the Sales Volume and
totalCosts is calculated by multiplying Sales Volume by Unit Cost. Note: All RASON arrays are 1-based.
formulas: {
salesVolume: { formula: "if(marketType = 1, 50000, if(marketType = 2, 75000, if(marketType = 3, 100000)))" },
sellingPrice: { formula: "if(marketType = 1, 11, if(marketType = 2, 10, if(marketType = 3, 8)))" },
grossSales: {formula: "sellingPrice * salesVolume" },
totalCosts: { formula: "salesVolume * unitCost" }
},
The data section holds the constant fixedCosts, which equals $120,000
data: { fixedCosts: { value: 120000 } },
Finally, the last section, uncertainFunctions, calculates the Net Profit by subtracting totalCosts and
fixedCosts from grossSales. Since we want to know the expected (or average) net profit, we ask for the mean in
our result.
uncertainFunctions: {
netProfit: { formula: "grossSales - totalCosts - fixedCosts", mean: [] }
}
Note that the result of the formula ("grossSales - totalCosts - fixedCosts") is 1,000 scenarios or trials, rather than a single value.
The mean that will be returned in the result will be the true average of Net Profit across 1,000 or more scenarios or trials -
not a single calculation from average values of the inputs. We could have asked for additional result measures for
netProfit such as the minimum function value, maximum function value, standard deviation, variance, median, mode, etc.
One, several, or all can be returned in a result. For a complete list of measures that may be returned, please see the chapter Rason Model
Components in the Rason Reference Guide.
See below for the complete RASON model.
{
modelName: "UGForecastSimExample",
modelType: "simulation",
uncertainVariables: {
marketType: {formula: "PsiIntUniform(1,3)"},
unitCost: {formula: "PsiTriangular(4.5, 6.5, 8.5)"}
},
formulas: {
salesVolume: { formula: "if(marketType = 1, 50000, if(marketType = 2, 75000, if(marketType = 3, 100000)))"},
sellingPrice: {formula: "if(marketType = 1, 11, if(marketType = 2, 10, if(marketType = 3, 8)))" },
grossSales: {formula: "sellingPrice * salesVolume"},
totalCosts: { formula: "salesVolume * unitCost" }
},
data: {
fixedCosts: { value: 120000}
},
uncertainFunctions: {
netProfit: { formula: "grossSales - totalCosts - fixedCosts", mean: []}
}
}
|