FICO Xpress Optimization Examples Repository
 FICO Optimization Community FICO Xpress Optimization Home

Description
This example shows how to read a 3-dimensional array from an excel file (threedimarr.mos) and from a generic spreadsheet (threedimarr5.mos) where the last index is specifed 'across the columns', resulting in a pivot-style table format where the first N-1 columns contain index values (here: 2 index columns). Model versions (2) and (4) show the same example for databases, and model version (6) works with data in CSV format.

Note that standard use of the 'partndx' option for spreadsheets assumes that the last index is a set of type 'range', the example partidxstr.mos defines a utility routine 'makelabel' that makes it possible to work with a 'set of string' for the last index.

Source Files
By clicking on a file name, a preview is opened at the bottom of this page.

Data Files

threedimarr5.mos

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

file threedimarr5.mos

- Using 'initializations from' with the xls/xlsx driver -

(c) 2012 Fair Isaac Corporation
author: S. Heipcke, Dec. 2012, rev. Apr. 2014
*******************************************************!)

uses "mmsheet"

parameters
CSTR1= 'mmsheet.xls:threedim.xls'
CSTR2= 'mmsheet.xlsx:threedim.xlsx'
end-parameters

declarations
I: range
J: set of string
K = 1..5	              ! The last index set must be defined in the model
A,B,C: dynamic array(I,J,K) of real
end-declarations

initializations from CSTR1
A as 'partndx;Tab_23'
end-initializations

writeln("A: ")
forall(i in I, j in J, k in K | exists(A(i,j,k)))
writeln("A(", i, ",", j, ",", k, "): ", A(i,j,k))

initializations from CSTR2
B as 'partndx;Tab_23'
end-initializations

writeln("B: ")
forall(i in I, j in J, k in K | exists(B(i,j,k)))
writeln("B(", i, ",", j, ",", k, "): ", B(i,j,k))

`