Professional Documents
Culture Documents
in Mosel Xpress-IVE
1
How to write a model
(1) Name of the model & options
model ModelName
options …
uses “mmxprs”
… !other sections
end-model
2
How to write a model
(2) Parameters – optional section
model ModelName
!parameters section first
parameters
MAXTIME=300
USE_LOG=false
!...
end-parameters
!Rest of the model (declarations, statements, etc.)
end-model
3
How to write a model
(3) Declarations (variables, arrays, etc.)
declarations
Variable : mpvar
VariableArray : array() of mpvar
IntegerVariable : mpvar
BinaryVariable : mpvar
end-declarations
4
How to write a model
(4) Data input – optional section
declarations
UnitCost : array(1..10) of integer
end-declarations
5
How to write a model
(5) Objective function
Cost:=2*x1+3*x2
!...constraints
minimize(Cost) !you don’t need to declare Cost
or
Profit:=2*x1+3*x2
!...constraints
miximize(Profit) !you don’t need to declare Profit
6
How to write a model
(6) Constraints
! simple constraint
X1+3*X2-5*X3<=8
x1 3x2 5x3 8
x
! sum constraint
i B
sum(i in 1..10) X(i)<=B
i 1
x
j 1
ij 1 for i 1, .. ,5
7
How to write a model
(7) Output & results