The following is a pseudo-spreadsheet intended to illustrate how to prepare the simulation of the flight process using spread sheets or other high level programs. You can also take a look at the java/C-like pseudo-code below.
mathematical model is in the Modeling page, where
you can see the simulation and the
Markov Chain formulation. The goal is to
estimate the long term profit per flight.
A FRIENDLY ADVICE: This page is an interactive one, intended to help you through the steps of programming a simulation. Rather than choosing a particular software, we give you here a "logical" spreadsheet that (we hope) will help you understand the basic concepts. Please plan on spending a good half hour going through the details and observing the results when you click the buttons.
Given our model, we must first determine the stratum indicating the type of flight and then generate the number of passengers according to the chosen type of flight. The next parragraph is thus devoted to the generation of a random variable ranging from 1 to 5 that indicates the strata. We shall divert a little to get you used to generating discrete random variables.
IF THE ABOVE DOESN'T WORK MAY BE YOU DID NOT PRESS "Done" OR "Reset" BEFORE, as you should have.
The following code generates the profit from one flight. This simulation is inserted into a loop that generates a series of flights to follow inventory levels as a dynamic process.
- 1. Initialize:
- P=0, p[j]= initial probabilities of strata.
- For j = 1, ..., 5 do
-   P[j] = P[j] + p[j]
- 2. Generate Stratum:
- U = random(), j = 0
- While (U> P[j]) j = j+1
- 3. Generate Uniform in chosen stratum:
- Pax = 10 * j + 10 * random();
- 4. Generate Demand per flight:
- For wine = 1,2,3 do D[wine] = 0
- For n = 1, ... , Pax
- U=random(), wine_type = 0
- While (U> PrWine[wine_type]) wine_type = wine_type+1
- U= random(), bottles = 0
- While (U> PrBottles[bottles]) bottles = bottles+1
- D[wine_type] = D[wine_type] +1
- 5. Update Inventory and Profit:
- For wine = 1,2,3 do
- Inventory[wine] = Inventory[wine] - D[wine]
- IF (Inventory[wine] < reorderlevel[wine] ) Order = True
- IF (Inventory[wine] < 0 )
- Penalty = Penalty - Inventory[wine]
- Inventory[wine] = 0
- Profit = Profit + CDollars * (D[wine] - Inventory[wine])
- ELSE Profit = Profit + D[wine]
- IF (Order = True) AND (Flight MOD 2 = 1)
- For wine = 1,2,3 do Inventory[wine] = Max[wine]
- Profit = Profit - ReorderCost - PenaltyCost * Penalty
SimSpiders Main Page