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

Working with records

Description
  • defining records and arrays of records
  • accessing record fields
  • assigning values to record fields
  • initialization with data from file
  • defining records of records (recorddef2.mos)
  • selecting record fields in initializations (recorddef2.mos)
Further explanation of this example: 'Mosel User Guide', Section 8.6 Records


Source Files
By clicking on a file name, a preview is opened at the bottom of this page.
recorddef.mos[download]
recorddef2.mos[download]

Data Files





recorddef2.mos

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

   file recorddef2.mos 
   ``````````````````` 
   Defining and initializing records.
   - Records within records,
     selection of fields in initializations -
 
   (c) 2008 Fair Isaac Corporation
       author: S. Heipcke, Sep. 2007, rev. Sep. 2018
*******************************************************!)

model "Defining records"

 public declarations 
  R = 1..10

  mydata = public record                      ! Define a named record
   name: string
   values: array(R) of real
  end-record

  B: dynamic array(T:range) of public record  ! Define an unnamed record
   val: real
   rd: mydata                          ! Record field containing a record
  end-record
 end-declarations
 
 initializations from "recorddef2.dat"
  B(rd) as "B"
  B(val) as "C"
  B(rd(name)) as "D"
  B(rd(values)) as "E"
  B(rd(values)) as "F"
 end-initializations

 writeln(B)

end-model 

Back to examples browserPrevious exampleNext example