 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

solarr_test.mos

```(!******************************************************
Mosel NI Examples
=================

File solarr_test.mos
````````````````````
Using module solarray

*** Compile solarraypkg.mos before running this model ****

(c) 2008 Fair Isaac Corporation
author: S. Heipcke, 2002
*******************************************************!)

model "Test solarray module"

uses "solarraypkg", "mmxprs"

declarations
R1=1..2
R2={6,7,9}
R3={5,-1}
x: array(R1,R2,R3) of mpvar
sol: array(R1,R2,R3) of real
end-declarations

! Define and solve a small problem
sum(i in R1, j in R2, k in R3) (i+j+2*k) * x(i,j,k) <= 20
forall(i in R1, j in R2, k in R3) x(i,j,k)<=1
maximize(sum(i in R1, j in R2, k in R3) (i+2*j+k) * x(i,j,k))

! Get the solution array
solarray(x,sol)

! Print the solution
forall(i in R1, j in R2, k in R3)
writeln(" (", i, ",", j, ",", k, ") ", sol(i,j,k), " ", getsol(x(i,j,k)))
writeln(sol)

end-model

```   