Mosel Model Development Requirements
Review the following information to understand how to define the format by which input and result records will appear within Application Studio.
- You should develop your Mosel model to get its input from a file named "input" located in the model's working directory. Should there be any results, the Mosel model will write them to a file named "result". Both the input and result files should be read and written using the 'helper' package named 'fssappstudio' which comes with FICO Xpress 7.8 (and later) versions.
- The helper package reads and writes the input and results using an XML record format. The top-level element is InputRecordList (for inputs) or ResultRecordList (for results), which always contains a single InputRecord or ResultRecord. Scalars are represented as values enclosed in a named element, as shown in the following example:
<?xml version="1.0"?> <InputRecordList xmlns="http://www.fico.com/input" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <InputRecord> <MyScalarValue>7.5</MyScalarValue> </InputRecord> </InputRecordList>
- Arrays are represented as a 'table' comprised of a named element which contains multiple 'rec' (_rec) elements that represent rows of the table. Each table row contains multiple elements representing individual cells. The following example has a table named 'Channels' with three columns: 'Channel', 'Cost', and 'Capacity'.
<?xml version="1.0"?> <InputRecordList xmlns="http://www.fico.com/input" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <InputRecord> <Channels> <Channels_rec> <Channel>1</Channel> <Cost>0.5</Cost> <Capacity>100</Capacity> </Channels_rec> <Channels_rec> <Channel>2</Channel> <Cost>1.2</Cost> <Capacity>50</Capacity> </Channels_rec> <Channels_rec> <Channel>3</Channel> <Cost>3</Cost> <Capacity>40</Capacity> </Channels_rec> </Channels> </InputRecord> </InputRecordList>
- Import this package by adding the following line to the top of your model:
uses "fssappstudio"
- Add the following line to register the inputs:
appsxml_import("input")
- If you have arrays named 'ChannelCost' and 'ChannelCapacity' that had a shared index set 'ChannelIDs', you could read them from the above XML example. To read an individual scalar value called 'MyScalarValue' into the variable 'myScalar', add the following lines:
initialisations from appsxml_in("MyScalarValue") myScalar as "[](MyScalarValue)" end-initialisations
- Refer to the following code:
initialisations to appsxml_out("MyResultScalarValue") myScalar as "[](MyResultScalarValue)" end-initialisations initialisations to appsxml_out("ResultChannels") [ChannelCost,ChannelCapacity] as "[](ResultChannel,ResultCost,ResultCapacity)" end-initialisations appsxml_export("result")
- The name in the brackets of appsxml_out refers to the 'table name', while the names in the "as' line refer to the 'column names'.
- The model results follow a similar format, except that it calls appsxml_out (rather than appsxml_in) and appsxml_export when all the data has been written, as shown in the preceding example.
- To test your model and run it locally, you will need to manually construct at least one input XML file. When running the model, two files are automatically created: input.xsd and result.xsd, which define the schemas of the input and result data-format respectively.
![]() |
Note It is important that there be no overlap in the table or scalar names used in the input and result files.
|