FICO
FICO Xpress Optimization Examples Repository
FICO Optimization Community FICO Xpress Optimization Home
Back to examples browserPrevious exampleNext example

Reading and writing union types

Description
A union is a container capable of holding an object of one of a predefined set of types. Its declaration specifies the set of compatible types or the predefined union type 'any'. The examples display the resulting types when populating union type entities from external data sources. It is also shown how to convert the type of union entities from textual types to 'date' or 'time' types as defined by the Mosel module mmsystem.
  • The model version in unioninout1.mos shows how to work with Mosel's text data file format.
  • Databases can be accessed from Mosel through an ODBC connection using the odbc driver (unioninout.mos) or with SQL statements (unioninout2.mos).
  • For Oracle databases a software-specific connection is provided by the module mmoci (unioninout4.mos).
  • Microsoft Excel spreadsheets can be accessed via the software-specific driver excel (unioninout3.mos). Alternatively, models can use the dedicated I/O drivers xsl/xlsx (unioninout5.mos) from the mmsheet module that support manipulating spreadsheet files on various platforms without having to install Microsoft Excel.
  • Module mmsheet also provides an I/O driver for csv files (unioninout6.mos).
Further explanation of this example: Xpress Whitepaper 'Using ODBC and other database interfaces with Mosel', Section Examples - Working with union types.


Source Files

Data Files





uniondata.csv

IVal,RVal,BVal,SVal,DVal,TVal
5,1.75,true,some text,2021-03-20,11:25:30

Back to examples browserPrevious exampleNext example