Initializing help system before first use

Parameters

It is commonly considered a good modeling style to hard-code as little information as possible directly in a model. Instead, parameters and data should be specified and read from external sources during the execution of a model to make it more versatile and easily re-usable. With Mosel it is therefore possible to define, for example, file names and numerical constants in the form of parameters the values of which may be modified at an execution without changing the model itself.

In our example, we may define the input and output file as parameters and also the constant terms (`right hand side' values) of the constraints and bounds. These parameter definitions must be added to the beginning of the model file, immediately after the uses statement:

 parameters
  DATAFILE= "folio.dat"             ! File with problem data
  OUTFILE= "result.dat"             ! Output file
  MAXRISK = 1/3                     ! Max. investment into high-risk values
  MAXVAL = 0.3                      ! Max. investment per share
  MINAM = 0.5                       ! Min. investment into N.-American values
 end-parameters

and in the rest of the model the actual file names and data values are replaced by the parameters.

To modify the settings of these parameters when executing a model with Workbench, enter the new values for the parameters after the filename in the Command input box of the output pane. For instance to change the value of MINAM:

Chap45/wbdataprm.png

Figure 5.1: Changing model parameter settings

Notice that parameters really become important when the model is not just run in the development environment Workbench but rather used for testing and experimentation (batch mode, scripts using the command line interface) and for final deployment (see Chapter 8). For example, we may wish to write a batch file that runs our model foliodata.mos repeatedly with different parameter settings, and writes out the results each time to a different file. To do so, we simply need to add the following lines to a batch file (we then use the standalone version of Mosel to execute the model, which is invoked with the command mosel):

mosel exec foliodata MAXRISK=0.1 OUTFILE='result1.dat'
mosel exec foliodata MAXRISK=0.2 OUTFILE='result2.dat'
mosel exec foliodata MAXRISK=0.3 OUTFILE='result3.dat'
mosel exec foliodata MAXRISK=0.4 OUTFILE='result4.dat'

Another advantage of the use of parameters is that if models are distributed as BIM files (portable, compiled BInary Model files), then they remain parameterizable, without having to disclose the model itself and hence protecting your intellectual property.


© 2001-2025 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.