When users building a model, we calculate some values in one program, say NETWORK and we would like to use these values in other programs after this NETWORK, this can be achieved by logging the variables. Once logged, the variables can be retrieved and used for other calculation in a different Cube program.
Another frequent practice in model design is to provide user defined parameters and/or arrays. We can achieve it by catalog keys. In this sample catalog, we will show how to use a text file for user defined variables and read the file when necessary.
Cube provides flexibility in model setup. The attached sample catalog just demonstrate some basic approaches to deal with the user defined parameters and arrays. Hopefully, it gives you some ideas for your own model and again feel free to modify/change any of the scripts for practice!
- The first three programs demonstrate how to log and use logged variables. In NETWORK1, we first count the total number of links in a network and log this variable in the SUMMARY Phase. In Pilot 2, we retrieve the logged VAR and print its value to an external report file. Matrix 3 shows how to retrieve and use the logged VAR.
NOTE: the difference in Pilot and Matrix when retrieving the VAR. In Matrix, we need to use @...@ when retrieving the logged VAR.
- Matrix 4 shows how to read and use the user defined parameters. In the TXT file, we defined two parameters:
myPara1 = 2 -->multiplier for HOV trips
myPara2 = 3 -->multiplier for PC trips
Once we read in the parameters, we can then adjust our OD table.
The input OD matrix is the following:
After the adjustment, we get:
- The last NETWORK program gives an example how to read and use user defined array. So we are interested in the total path distance of the following path on the network:
myNode = 1
myNode = 101
myNode = 102
myNode = 104
myNode = 2
The script will read in the path node sequence and then in the LINKMERGE Phase, we output the link distance of each link in this path to an external file.
HAPPY NEW YEAR!
userDefVars.rar (18.3 KB)