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

Writing packages: definition of constant symbols, subroutines, types, and parameters

Description
Packages are libraries written in the Mosel language that extend the language with
  • constant symbols (myconstants.mos)
  • subroutines (definition of several overloaded versions of a procedure in solarraypkg.mos, generic implementation using union types and iterator in solarrayanypkg.mos)
  • types (definition of a structure 'arc' to represent arcs in a network with a function to access information: arcpkg.mos)
  • parameters (definition of real/integer/string/boolean valued package parameters: parpkg.mos)
Further explanation of this example: 'Mosel User Guide', Chapter 16 Packages


Source Files

Data Files





arc_test.mos

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

   file arc_test.mos
   `````````````````
   Using the package 'arcpkg'.

   *** Compile arcpkg.mos before running this model ****
   
   (c) 2008 Fair Isaac Corporation
       author: S. Heipcke, Jan. 2007, rev. June 2018
*******************************************************!)

model "Arcs"
 uses "arcpkg"

 declarations
  NODES: set of string                  ! Set of nodes
  ARC: array(ARCSET:range) of arc       ! Arcs
 end-declarations

 initializations from 'arcs.dat'
  ARC
 end-initializations

! Calculate the set of nodes
 NODES:=union(a in ARCSET) {ARC(a).Source, ARC(a).Sink}
 writeln(NODES)

 writeln("Average arc cost: ", sum(a in ARCSET) ARC(a).Cost / getsize(ARCSET) )

 writeln("Neighbors A and F: ", is_neighbor("A","F",ARC))
 writeln("Neighbors A and B: ", is_neighbor("A","B",ARC))

end-model 

Back to examples browserPrevious exampleNext example