Creating a matrix calculated from a formula
You can create a Visum matrix that is calculated from other Visum matrices or zone, main zone or stop area attributes. This formula matrix is automatically recalculated if one of its operands changes.
You are supported by Visum in formal generation of the formula. The syntax is checked on entry and errors are highlighted in color.
The following formula matrices are special cases of matrices which you can calculate through the procedures provided:
- Total demand matrices
- Assignment matrix
- OD pair filter assignment matrices
- Flow bundle matrices
You can allow assignment and flow bundle matrices to be created automatically by selecting the relevant options in the general procedure settings (Saving flow bundle matrices and assignment matrices automatically as formula matrices)
Notes: You cannot change the values in formula matrices. If you delete matrices or attributes that are used to calculate a formula matrix, the formula matrix is also deleted. |
1. In the Matrices window, on the toolbar, click the Create matrices icon.
The Create matrices window opens.
Tip: Alternatively, in the Matrices window, you can right-click in the navigator and select Create matrices from the shortcut menu or select Create from menu Edit > Matrices. The symbol and the shortcut menu entry are both provided in the Matrices list (Opening a list). |
2. Select the Matrix attributes tab.
3. In the Data source type section, select the Formula matrix option.
4. Click the Edit formula button.
The Edit formula for matrix <number> window opens.
5. Into the text box, enter the desired formula for calculation, or click the buttons next to the text box to create a formula.
Notes: You can copy and paste the formula from another formula matrix to use it. Make sure that your formula does not contain a direct or indirect circular reference. You should also avoid references between output values and input values of the same procedure step in the procedure sequence because they can lead to undesired calculation results. |
Tip: There are several keyboard shortcuts that make it easier for you to work in the formula editor (Key combinations in the formula editor for formula attributes and formula matrices). |
Element |
Description |
|
Click the button to select operands for the formula matrix. The options available depend on the context in which you are creating a formula matrix. Select matrix directly If the option is selected you can select a matrix in the Navigator according to your number. Select matrix by properties If the option is selected, you can select a matrix according to specific attributes and their values, which you can define using the input fields (Selecting matrices) Simple attribute (network) If this option is selected, you can select a network attribute for the formula in the lower part of the window. Simple attribute (matrix) If this option is selected, you can select a matrix attribute for the formula in the lower part of the window. Origin/destination attribute (zone/main zone) By selecting this option, for each Network object reference type specified, you can apply an origin or destination attribute in the formula. Select the Origin or Target button; in the lower part of the window select the associated attribute. Variable attribute For formula matrices, it is possible to add variable attributes to the formula. If this option is selected, you can take up a variable attribute in the formula. Constant If this option is selected, you can enter a constant numeric value as an operand. |
|
Click this button to select an operator for the formula. The selection available depends on the operand type, of which the values are used in the formula. Available operators and their priority: The parenthesis operator has the highest priority. Click the icon to insert it. In the following, the other operator groups are listed in decreasing priority: 1. unary operator:
2. multiplicative binary operators:
3. additive binary operators:
Note You can also use this function to merge two texts.
4. relational binary operators:
5. binary equality operators:
When binary operators have the same priority, the order of evaluation is from left to right (left associative). Example 4/2/2 is evaluated as (4/2)/2 = 1, not as 4/(2/2) = 4 |
|
Click the button to select a function for the formula (Using matrix values for calculations).
Example 0.3 is rounded up to 1 with 30% probability and down to 0 with 70% probability.
Examples MODULO(5,2) = 1 MODULO(9,3) = 0
Examples DIV(5,2) = 2 DIV(9,3) = 3 DIV(7,−3) = −3 DIV(-7,−3) = 2
Note If under User preferences you selected a point as your decimal separator, a comma is used as separator between the elements. Otherwise, a semicolon is used (Selecting a decimal point). |
|
The button opens the Add ForEach window. Here, you can insert functions of the ForEach type in your formula (Fundamentals: Performing calculations for multiple matrices). You insert a loop function of the type ForEach in the formula. You can create and calculate a number of matrices in a single procedure step with this function. |
|
Click the button to open the Insert aggregation function window, in which you can select matrix conversion functions (Fundamentals: Using matrix conversion functions).
|
|
The button opens the Create TableLookup window. Here, you can insert a function of the type TableLookup in your formula (Fundamentals: Using the TableLookup function). With this function, you can extract a value from any Visum table and edit it in the formula. This is useful, for example, when managing parameter values which are used for the calculation of attributes. Alternatively, you can, for example, transfer data from one network object to another. Network object type From the drop-down list, select the network object type which represents the base of the function. All following conditions of the function refer to the selected network object type. Procedure variables can also be selected. Variable name Enter a variable name which starts with a letter. The first matching value in the table is used for further calculation. If no matching value is found, an empty value is used. |
|
Click this button to insert a bracket term without content into the formula. |
6. Select the Matrix quantity tab.
7. Make the desired changes.
Element |
Description |
Insert a fixed number of matrices |
If the option is selected, specify in the appropriate box the number of matrices you would like to insert. Note When creating more than one matrix, the matrix numbers will be continuously ascending. All created matrices have the same properties. |
Insert matrices via matrix reference |
Select this option to create one or more matrices. For new matrices, you can specify the values of the matrix attributes through references which you input as code (Selecting matrices). |
Edit new matrices after creating |
Select this option to open the created matrices in the Matrix editor and edit them. |
8. Confirm with OK.
9. Confirm again with OK.
The new formula matrix is created and calculated. It is displayed in the Matrices window, under Formula matrices. If you have developed formulas for matrices needed in the procedure, the respective formula matrices are created when you run the procedure sequence.
Note: If you save a formula matrix as a file, only the current values are saved, not the formula. |
Note: In the directory C:\Users\Public\Documents\PTV Vision\PTV Visum 2024/Examples, you can find an example of use on this topic. The example Formulas shows the use of formula attributes, formula matrices, and aggregation functions in lists. |