Building Discrete-Time Simulation Models

A discrete-time simulation model predicts a changing system by calculating its condition at separate, specified times. You might track water in a reservoir each day, material moving between tanks each cycle, or stored energy after each operating period. Instead of describing every instant between observations, you apply a rule repeatedly. The useful question is what the system contains now and how one interval changes it.

Choose the state and the clock

The state is the collection of quantities your model records to describe the system at a particular step. For a single water tank, one state variable might be its volume in litres. For two connected tanks, you may need both volumes because knowing only their combined volume does not describe how the water is distributed.


Write xnx_n for a recorded quantity at step nn. The initial value x0x_0 supplies the starting condition; x1x_1 is the value after one update. If each step represents one day, step nn occurs nn days after the start.


Specify whether you record the state before or after scheduled events. A daily delivery can belong to the current update or the next one depending on this choice. Neither convention is automatically preferable, but your description and calculations must agree.

Translate events into an update rule

For a stored quantity, the governing balance is


xn+1=xn+amount entering during step n−amount leaving during step n.x_{n+1}=x_n+\text{amount entering during step }n-\text{amount leaving during step }n.


Each term must have the same units. A flow given in litres per hour must be multiplied by the relevant number of hours before it can be added to a volume in litres.


A common model retains a fraction rr of the old amount and then receives an input uu:


xn+1=rxn+u.x_{n+1}=rx_n+u.


Here, rr is dimensionless and uu has the same units as xnx_n. This difference equation becomes a simulation when you start with x0x_0 and repeatedly calculate the next value.


Three boxes show a current state passing through an update rule to produce the next state.


The order of events is part of the model. Compare two possible descriptions of one interval:


Timing of input

Update rule

Meaning

Input arrives after the loss

xn+1=rxn+ux_{n+1}=rx_n+u

Only the old amount experiences this interval's loss.

Input arrives before the loss

xn+1=r(xn+u)x_{n+1}=r(x_n+u)

Both the old amount and the new input experience the loss.


Example: A container starts with 30 L, retains 80% during an interval, and receives 5 L. Adding the input after the loss gives 0.80(30)+5=290.80(30)+5=29 L. Adding it before the loss gives 0.80(30+5)=280.80(30+5)=28 L. The different results reflect different timing assumptions.



For several connected stores, calculate every transfer from the states specified by the model. If a fraction pp of store A moves to store B each step, with no other changes, simultaneous rules are


An+1=(1−p)An,Bn+1=Bn+pAn.A_{n+1}=(1-p)A_n,\qquad B_{n+1}=B_n+pA_n.


Calculate both new values before replacing either old value. Otherwise, the second calculation may accidentally use information from a different step.

Record and check the results

Store outputs in a table with one row per step. Include the initial state in row zero, label units, and distinguish a stored amount from a total accumulated over several steps. Water remaining today and water spilled across all days are different outputs.


Check whether your results obey the model's limits. A physical stored amount should not become negative. Transfers between stores should cancel when you total the whole system; external inputs and outputs change that total. A capacity limit also needs an explicit rule for what happens to excess material.



Finally, a simulation output is conditional on its assumptions. A daily percentage does not automatically become an hourly percentage when you change the step duration. Reconsider the interval rules whenever you change the clock or the system being represented.

What to remember

  • Specify the state, its units, the initial values, and the step duration.
  • Translate event timing into the update rule.
  • Use the correct old states for simultaneous updates.
  • Check totals, physical limits, and the meaning of each recorded output.

Example: Tracking Dye Through Two Tanks

A laboratory uses a cycle-based model to track dissolved dye in two connected tanks. Initially, upper tank A contains 50 g of dye and lower tank B contains 20 g. During each cycle, 20% of A's starting dye mass transfers to B, while treatment removes 25% of B's starting dye mass. At the end of the cycle, 6 g of fresh dye enters A. There are no other dye inputs or losses.


The model uses a simultaneous update: all proportional transfers and removals are calculated from the masses recorded at the start of the same cycle. In particular, dye arriving in B is not treated until a later cycle.


An external dye input enters tank A, a transfer carries dye to tank B, and treatment removes dye from tank B.


a) Let AnA_n and BnB_n be the dye masses in grams after nn complete cycles. Write the initial conditions and both update rules.


Tank A loses 20% of its old mass, leaving 80%, and then receives 6 g. Tank B retains 75% of its old mass and receives the material transferred from A. Therefore,


A0=50 g,B0=20 g,An+1=0.80An+6 g,Bn+1=0.75Bn+0.20An.\begin{aligned} A_0&=50\ \text{g},\qquad B_0=20\ \text{g},\\ A_{n+1}&=0.80A_n+6\ \text{g},\\ B_{n+1}&=0.75B_n+0.20A_n. \end{aligned}


The fractions are dimensionless, so every term in either update has units of grams. Use the old value of A in both equations; calculating B from the newly updated A would change the specified transfer.


b) Calculate the dye mass in each tank after two complete cycles. Give the final masses to two decimal places.


First calculate both states after cycle 1. Tank A retains 0.80(50)=400.80(50)=40 g and receives 6 g, giving ________. Tank B retains 0.75(20)=150.75(20)=15 g and receives 0.20(50)=100.20(50)=10 g, giving ________.


For cycle 2, the transfer from A is ________, calculated as 0.20(46)0.20(46). Treatment removes ________ from B, calculated as 0.25(25)0.25(25). Both calculations use the cycle 1 states.


Now complete the second update:


A2=46−9.2+6=42.80 g,B2=25−6.25+9.2=27.95 g.\begin{aligned} A_2&=46-9.2+6=42.80\ \text{g},\\ B_2&=25-6.25+9.2=27.95\ \text{g}. \end{aligned}


After two cycles, tank A contains 42.80 g and tank B contains 27.95 g. The newly transferred 9.2 g enters B without experiencing treatment during that same cycle.


c) Find the combined dye mass after two cycles and verify it using the external inputs and removals.


Adding the final tank masses gives


A2+B2=42.80+27.95=70.75 g.A_2+B_2=42.80+27.95=70.75\ \text{g}.


To check this independently, start from the initial combined mass of 50+20=7050+20=70 g. Two fresh inputs add 2(6)=122(6)=12 g. Treatment removes 0.25(20)=50.25(20)=5 g in cycle 1 and 0.25(25)=6.250.25(25)=6.25 g in cycle 2.


The transfers between tanks remain inside the combined system, so they do not enter its external balance:


Final combined mass=70+12−(5+6.25)=70.75 g.\begin{aligned} \text{Final combined mass} &=70+12-(5+6.25)\\ &=70.75\ \text{g}. \end{aligned}


The balance agrees with the individual updates. The combined final mass is 70.75 g, an increase of 0.75 g from the starting total.

A reserve tank initially contains 240 L. Each day, 10% of its starting volume is used, and then 18 L is delivered. Let VnV_n be the volume immediately after day nn ends, with V0=240V_0=240 L. Which rule correctly calculates Vn+1V_{n+1}?

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

A delivery simulation exports five predicted journey times: 12, -999, 15, 9 and -999 minutes. Its documentation states that -999 marks a failed run and does not represent a journey time. A valid run is a run that produces a usable journey time.


Complete the missing processing steps for calculating the average over valid runs. Exclude failed-run markers from both the sum and the count.


Add the valid journey times to obtain minutes. Divide this sum by , the number of valid runs, to calculate the average journey time.

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

A laboratory reservoir starts with 25 L. During each operating cycle, 80% of the starting water remains, and 10 L is then added. Its model is Vn+1=0.80Vn+10V_{n+1}=0.80V_n+10, with V0=25V_0=25 L. Complete the end-of-cycle volumes below in litres. Enter exact decimal values without rounding.

Completed cyclesVolume (L)
025
1
2
3
4

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

Extra Practice