Tips on model design

Here some tips and best practices for models that are easier to build, understand, debug, and extend.

Use constants: Avoid numbers in expressions

In models by novice modelers, you often see variables with definitions that contain numbers like this:

Variable Energy_consumption := Gas_consumption * 239.2972


You may wonder what the number 239.2972 means -- unless you happen to know it is units conversion factor from million BTU to Kilowatt-hours. It's much clearer if you create a separate Constant for that number:

Constant KWH_per_MMBTU := 239.2972
Variable Energy_consumption := Gas_consumption * KWH_per_MMBTU


Using a named Constant like this makes it obvious what the number means. Plus you can use this Constant KWH_per_MMBTU wherever you need it -- without having to look up and retype the number each time.

Remembered to specify the units for each quantity:

Units OF Gas_consumption := 'MMBtu'
Units OF Energy_consumption := 'kWh'


If the number is a not a constant, but a model input value, like the population of the city, or a date, it's even more important to put it in its own variable, with a description explaining what it is and where it came from -- rather than embedding it into a definition.

Don't repeat expressions in cells of a table

If you find yourself entering the same or similar expressions into some or all the cells of an edit table -- there's almost certainly a simpler and clearer way to do what you want. Consider this table:

Variable