header logo

Switches: Making a Switch out of a Slider

Another creative use of sliders involves restricting them to a value of either 0 or 1, effectively turning them into On/Off switches. Sliders implemented this way can be particularly effective at turning rates on and off. Turn a slider into a swtich by simply setting its range from 0 to 1 with increment 1.

Suppose you wanted to be able to turn the rate Get Sick on and off in your model (This would probably make more sense in a model with multiple rates, but it works for an example). As abbreviations, let k = Infection Fraction, S = Susceptible People, I = Infected People and o = Get Sick On/Off.

Expanded Model

Procedure

  • ICON Add an auxiliary variable to your model called Get Sick On/Off as illustrated above.
  • ICON Set the value of Get Sick On/Off to 1.

  • ICON Connect this nex auxiliary variable to the rate Get Sick.
  • ICON Change the formula for Get Sick to:

    GS = S * I * k * o


    where o represents the value of Get Sick On/Off.

  • ICON Add a slider associated with Get Sick On/Off. Let the slider range from 0 to 1 with increment 1.
  • In this example, 1 means on and 0 indicates off for Get Sick On/Off
  • When Get Sick On/Off = 0, the formula for Get Sick evaluates to 0:

    GS = S * I * k * 0 = 0

  • When Get Sick On/Off = 1, the formula for Get Sick is normal:

    GS = S * I * k * 1 = S * I * k

    In this fashion, you can easily turn certain rates on and off without having to drastically change your model. The implementation may seem a bit cumbersome at first, but the payoff can be well worth the effort.

    NOTICE: When using switches, only use the slider added with the Input/Output Object button ICON. The slider on the flow-chart that appears when SyntheSim is activated is not as easily restricted to 0 and 1. Use only the permanent slider to avoid confusion.


Previous Next

Vensim PLE is a product of Ventana Systems, Inc.