Académique Documents
Professionnel Documents
Culture Documents
Submit all the necessary information, and wait for the password email to arrive almost immediately.
Once installed, a program named Xpress-IVE will be located under Xpress-MP folder from your start
menu. Click on Xpress-IVE and be sure to read the license agreement before clicking on I agree. The
program takes a few seconds to load, so do not panic.
Click File then New then the following window will appear.
Select
Mosel
Type
Click here to
change file
Type new location
file name
here
Type in a file name (sample) for your model, and select Mosel Type. Change the Absolute path to
wherever you want to store your new file. Leaving the suggested path unchanged is preferable. The
following window will then appear:
-1-
GETTING STARTED with Xpress-MP
1. Click here
to close the
newly
MODEL created file
EDITOR
Now you have successfully created a new mosel program file. This file under normal circumstances can
not be edited because it has Read-only property.
Once you are able to type in the model editor. Type the following model:
model simple
uses "mmxprs"
declarations
a: mpvar
b: mpvar
end-declarations
maximize(profit)
writeln("Profit is ", getobjval)
end-model
-2-
GETTING STARTED with Xpress-MP
Uses mmxprs is to
load the solver
algorithm to solve LP
models.
writeln(whatever you
want to appear,
getobjval). getobjval
returns the value of the
objective function.
-3-
GETTING STARTED with Xpress-MP You can also see the values of the data
and variables by clicking on the
appropriate identifiers in the "Entities" tab
3. Getting More Detail Solution on the left window pane.
The following expressions will help you model:
getsol(mpvar) returns the value of mpvar solution.
getdual(constraint) returns the value of an additional resource of the constraint.
-4-
GETTING STARTED with Xpress-MP
8
Maximize MaxValue = X
i =1
i * Valuei
such that
8
MaxWeight = X
i =1
i * Weight i < WTMAX
X i : Binary
Item 1 2 3 4 5 6 7 8
Value 15 100 90 60 40 15 10 1
Weight 2 20 20 30 40 30 60 10
In order to implement this formulation into mosel we will need to learn the following concepts:
Declare an array of real number variables such as Weight (i) and Value(i)
Declare an array of decision variables such as X(i)
Declare range variables such as Items=1..8
Declare constants
Input data for real numbers variables
Correct way to declare summation operation such as sum(i:=1 in Items) Weight(i) * X(i)
Incorporate for loop statement by using keyword: forall
Declaring binary variables by using keyword: is_binary
The mosel model for this burglar problem is given when you install XpressMP, as
XPressMP/examples/mosel/extra/modeling/burg.mos
The following window will appear when you load burg.mos file.
-5-
GETTING STARTED with Xpress-MP
This means that items 1,2,3,4, and 6 are taken and their total value is 280.
-6-
GETTING STARTED with Xpress-MP
From the previous burglar problem we will now read data from an external data file. The advantage of
this practice is that we will make the mosel model code more compact and more professional.
Use notepad to create a data file with the following lines in the same directory as the mosel file and
name it burg.dat
Notice the data file does not contain coma (,) between each data point.
Your new mosel code need the following changes as pointed by Dotted POINTER
-7-
GETTING STARTED with Xpress-MP
For the previous burglar problem we will now read data from an external Excel file.
Suppose we have the following Excel file (burg.xls) which has the data:
The new Mosel code is as follows (the dotted boxes highlight the changes):
Here are the key changes:
Add uses mmodbc to the top of the file to tell XPRESS to communicate with Excel
After the declarations section you need an initializations section:
Inside the initializations section you need to tell it what cells have the data in the
Excel file. For example, in the file burg.xls WTMAX data is in the cell B2, VALUE
data is in cells C5:C12 and WEIGHT data is in cells D5:D12, so we write:
Notice that each initialization starts one cell above where the data is. Thats an Xpress
quirk. I dont know why its set up that way, but it is to get the right data, you always
have to start reading from one cell higher than the datas location.