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

Working with arrays

Description
  • arraydef.mos: Defining arrays: sparse and dense arrays; deleting array entries; multiple indices; array access functions
  • arrayinit.mos: Array initialization from a text file (requires arrayinit.dat)
  • autoarray.mos: Working with automatic arrays
  • chess2.mos: Indexing arrays by variables
Further explanation of this example: 'Mosel User Guide', Section 8.1 Arrays


Source Files
By clicking on a file name, a preview is opened at the bottom of this page.
arraydef.mos[download]
arrayinit.mos[download]
autoarray.mos[download]
chess2.mos[download]

Data Files





chess2.mos

(!******************************************************
   Mosel User Guide Example Problems
   ================================= 

   file chess2.mos
   ```````````````
   Indexing arrays by variables.
   
   (c) 2008 Fair Isaac Corporation
       author: S. Heipcke, 2001
*******************************************************!)

model Chess2
 uses "mmxprs"
 
 declarations
  Allvars: set of mpvar
  DescrV: array(Allvars) of string
  small, large: mpvar
 end-declarations

 DescrV(small):= "Number of small chess sets"
 DescrV(large):= "Number of large chess sets"

 Profit:=  5*small + 20*large
 Lathe:=   3*small + 2*large <= 160
 Boxwood:=   small + 3*large <= 200

 maximize(Profit)

 writeln("Solution:\n Objective: ", getobjval)
 writeln(DescrV(small), ": ", getsol(small))
 writeln(DescrV(large), ": ", getsol(large))
end-model

Back to examples browserPrevious exampleNext example