Download Mosel user guide
Transcript
! Data file for ’blend.mos’ COST: [85 93] AVAIL: [60 45] GRADE: [2.1 6.3] The initializations from / end-initializations block is new here, telling Mosel where to get data from to initialize named arrays. The order of the data items in the file does not have to be the same as that in the initializations block; equally acceptable would have been the statements initializations from ’blend.dat’ AVAIL GRADE COST end-initializations Alternatively, since all data arrays have the same indices, they may be given in the form of a single record, such as BLENDDATA in the following data file blendb.dat: ! [COST AVAIL GRADE] BLENDDATA: [ [85 60 2.1] [93 45 6.3] ] In the initializations block we need to indicate the label of the data record and in which order the data of the three arrays is given: initializations from ’blendb.dat’ [COST,AVAIL,GRADE] as ’BLENDDATA’ end-initializations 2.2.3 Re-running the model with new data There is a problem with the model we have just presented — the name of the file containing the costs date is hard-wired into the model. If we wanted to use a different file, say blend2.dat, then we would have to edit the model, and recompile it. Mosel has parameters to help with this situation. A model parameter is a symbol, the value of which can be set just before running the model, often as an argument of the run command of the command line interpreter. model "Blend 2" uses "mmxprs" parameters DATAFILE="blend.dat" end-parameters declarations REV = 125 MINGRADE = 4 MAXGRADE = 5 ORES = 1..2 COST: array(ORES) of real AVAIL: array(ORES) of real GRADE: array(ORES) of real use: array(ORES) of mpvar end-declarations ! ! ! ! Unit revenue of product Minimum permitted grade of product Maximum permitted grade of product Range of ores ! Unit cost of ores ! Availability of ores ! Grade of ores (measured per unit of mass) ! Quantities of ores used ! Read data from file initializations from DATAFILE COST AVAIL Some illustrative examples 16 Mosel User Guide