A task can have a prerequisite, but it can not be a prerequisite of itself. For the 3 tasks (design, prototype, build), we could write out a set of equations (3 for each of the 3 tasks, 9 equations total) that tell us which task is a prerequisite of another. For example, for the task prototype:
is a prerequisite[prototype,design] = 1
is a prerequisite[prototype,prototype] = 0
is a prerequisite[prototype,build] = 0
These three equations tell us that for the task prototype, design is prerequisite (value = 1) but prototype and build are not prerequisites (value = 0). These three equations for prototype can be combined into a more compact form:
is a prerequisite[prototype,prereqtask] = 1,0,0
Note that the order of prerequisite tasks is the same as tasks, so that the value 1 refers to design, 0 refers to prototype, etc. However, we need three equations in total (although you can write one equation with a 2 dimensional array to describe the prerequisites — see the Reference Guide).
Ø | Click on the variable "Name" text box: is a prerequisite. |
Ø | Click on the dropdown arrow for the list box on the Subscripts tab (currently says Range). Select the subscript range task - elements from the dropdown list. The three tasks appear in the list box below. |
Ø | Click on the subscript design appearing in the list box. This enters the subscript into the equation at the cursor placement. |
Ø | Click on the drop-down arrow for the list box (currently says task - elements). Select Range from the drop-down list. The list box now says Range and the two subscript ranges are listed in the box below. |
Ø | Click on the range prereqtask. |
Ø | Move the cursor to the equation editing box (after the equals sign) and type in the numbers and commas 0,0,0 and type in units, as below: |
is a prerequisite[design,prereqtask]= | 0,0,0 |
Units: Dmnl
This is the first of three equations describing which tasks are prerequisites of the others. To make the next two equations:
Ø | Click on the Add Eq button, which appears in the subscript row. |
A second equation is added for the variable is a prerequisite. If you have exited and reopened the Equation Editor Vensim will automatically add the subscripts [task,task]. This is of the same form as the previous equation, since design is a task, and prereqtask maps to task. If you are just following the steps above is a prerequisite will appear without any subscripts.
Ø | If there are any subscripts on is a prerequisite, remove them. |
Ø | Fill in the equation as below by either typing in the new subscripts, or selecting them from the subscript list box. |
is a prerequisite[prototype,prereqtask]= | 1,0,0 |
Note that the units will already be in place. There is only one units definition for a variable.
Ø | Press the AddEq button again and then fill in the equation as below, either typing in the new subscripts, or selecting them from the subscript list box: |
is a prerequisite[build,prereqtask]= | 1,1,0 |
Units: Dmnl
You can navigate between these three equations by clicking on the same drop down arrow number list or using the arrows that appear on either side. The arrows only appear if you are able to move in that direction. As you add equations, the equation number will be added to this list and the Title bar will display this as well. The Remove button may be used to delete an equation that you no longer want.
Ø | Click on OK to close the Equation Editor. |
NOTE There is a more compact way to write 2 dimensional arrays. The following single equation has the same meaning as the three equations you wrote for is a prerequisite.
is a prerequisite[task,prereqtask] = 0,0,0; | 1,0,0; 1,1,0; |
We did not use this equation because we wanted to demonstrate how to write multiple equations for one variable. For this example we could have used the 2 dimensional array, but in many models it is not possible to do so. The multiple equation concept applies not only to Constants but to all types of model variables.