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

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)
• 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

arcpkg.mos

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

file arc.mos
````````````
Definition of the type 'arc'.

(c) 2008 Fair Isaac Corporation
author: S. Heipcke, Jan. 2007, rev. June 2018
*******************************************************!)

package arcpkg

public declarations
arc = public record                   ! Arcs:
Source,Sink: string                  !   Source and sink of arc
Cost: real                           !   Cost coefficient
end-record
end-declarations

(! Alternatively:
declarations
public arc = record                   ! Arcs:
public Source,Sink: string           !   Source and sink of arc
public Cost: real                    !   Cost coefficient
end-record
end-declarations
!)

public function is_neighbor(n1,n2: string, A: array(Arcs:set of integer) of arc): boolean
returned:=or(a in Arcs ) (( A(a).Source=n1 and A(a).Sink=n2) or
( A(a).Source=n2 and A(a).Sink=n1))
end-function

end-package

```