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

Spreadsheets and databases: working with multiple data tables and arrays

Description
A database table (or a spreadsheet range) may contain in its different fields (columns) the data for several Mosel arrays and inversely, a Mosel array may correspond to several data tables (ranges). We have here examples of various different cases:

  1. using the odbc driver,
  2. formulated with SQL statements,
  3. using the excel driver,
  4. using the oci driver,
  5. using the xls driver, and
  6. using the csv driver.
for three sets of examples:
  • Reading several arrays from a single database table/spreadsheet range (multicol.mos)
  • Outputting several arrays into a single database table/spreadsheet range (multiout.mos)
  • Reading an array from several tables/ranges (multitab.mos)
Further explanation of this example: Xpress Whitepaper 'Using ODBC and other database interfaces with Mosel', Section 'Examples'.


Source Files

Data Files





multicol5.mos

(!*******************************************************
   Mosel Example Problems 
   ======================

   file multicol5.mos
   ``````````````````
   Reading several data arrays from a single table.
   - Using 'initializations from' with xls IO driver -
       
   (c) 2012 Fair Isaac Corporation
       author: S. Heipcke, Dec. 2012
*******************************************************!)

model "Multiple data columns (generic spreadsheet)"
 uses "mmsheet"

 parameters
!  CSTR= 'mmsheet.xls:multicol.xls'
  CSTR= 'mmsheet.xlsx:multicol.xlsx'
 end-parameters

 declarations
  PRODUCTS: set of string
  MACH: range
  COST2: dynamic array(PRODUCTS,MACH) of real
  DUR2: dynamic array(PRODUCTS,MACH) of integer
 end-declarations
 
! **** Reading data from a spreadheet ****
! This assumes the spreadsheet contains a table "ProdData" in
! sparse format (i.e., with indices) with the columns "COST" and "DUR"

 initializations from CSTR
  [COST2,DUR2] as 'skiph;ProdData'
 end-initializations

 writeln("XLS:"); writeln(COST2); writeln(DUR2)
 
end-model

Back to examples browserPrevious exampleNext example