Xpress Appendix C

From TomWiki
Jump to navigationJump to search

Notice.png

This page is part of the Xpress Manual. See Xpress Manual.

The Matlab Interface Routines - Test Routines

xpaircrew

Purpose

Test of an air-crew schedule generation problem.

Calling Syntax

xpaircrew

Global Parameters Used

Parameter Description
xpControlVariables Structure with all XpressM P control variables. Set before the callback.
xpProblemAttrib Structure with all XpressM P problem attributes. Set before the callback.
MAX_x Maximal number of x elements printed in output statements. Default 20.
MAX_c Maximal number of constraint elements printed in output statements. Default 20.

Description

Test of an air-crew schedule generation problem. Based on D.M.Ryan, Airline Industry, Encyclopedia of Operations Research and Management Science. Two subfunctions are used (defined at the end of the xpaircrew.m file): The function generateT oDs create ToDs, i.e. Tours of Duty. The function sectordata generates some test data.

M-files Used

abc2gap, xpress

xpbiptest

Purpose

Test of TOMLAB /Xpress level 1 interface solving three larger binary integer linear optimization problems calling the XpressM P solver.

Calling Syntax

function xpbiptest(Cut, PreSolve, MipPre, NodeSel, BackTrack, xpcontrol)

Description of Input

Cut Value of the CUTSTRATEGY control parameter, default Cut = -1. Cut = -1, auto select of Cut = 1 or Cut = 2. Cut = 0, no cuts. Cut = 1, conservative cut strategy. Cut = 2, aggressive cut strategy
PreSolve Value of the PRESOLVE control parameter, default PreSolve = 1. PreSolve = 0, no presolve. PreSolve = 1, do presolve.
MipPre Value of the MIPPRESOLVE control parameter, where the default value is dependent on the matrix characteristics. It determines the type of integer processing to be performed in the Branch and Bound. M ipPre = 0, no processing will be performed. If bit 0 is set, do reduced cost fixing at each node. If bit 1 is set, do logical preprocessing on binary variables at each node. If bit 2 is set, do probing of binary variables is performed at the top node. A value M ipP re = 7 will set all three bits as 1.
NodeSel Value of the NODESELECT control parameter. The default value is dependent on the matrix characteristics. It determines which nodes will be considered for solution once the current node has been solved. N odeSel = 1, choose among the two descendant nodes, if none among all active nodes. N odeSel = 2, all nodes are always considered. N odeSel = 3, depth-first search exploring both descendants first. N odeSel = 4, all nodes are considered for the first BREADTHFIRST nodes, after which the usual default behavior is resumed. Setting xpcontrol.BREADTHFIRST influences the last choice.
BackTrack Value of the BACKTRACK control parameter, default value is 3. Determines how the next node in the tree search is selected for processing. BackTrack = 1, if MIPTARGET is not set, choose the node with the best estimate. Otherwise the node choice is based on the Forrest-Hirst-Tomlin Criterion, which takes into account the best current integer solution and seeks a new node which represents a large potential improvement. BackTrack = 2, always choose the node with the best estimated solution. BackT rack = 3, always choose the node with the best bound on the solution.
xpcontrol The initial xpcontrol structure. Here the user may set additional control parameters, e.g. xpcontrol.BREADTHFIRST. Default empty.

Global Parameters Used

MAX_x Maximal number of x elements printed in output statements. Default 20.
MAX_c Maximal number of constraint elements printed in output statements. Default 20.

Description

Test of three larger binary integer linear optimization problems calling the XpressM P solver. The test problem 1 and 2 have 1956 variables, 23 equalities and four inequalities with both lower and upper bounds set.

Test problem 1, in bilp1.mat, is randomly generated. It has several minima with optimal zero value. XpressM P runs faster if avoiding the use of a cut strategy, and skipping presolve. Test problem 2, in bilp2.mat, has a unique minimum. Runs faster if avoiding the use of presolve.

Test problem 3, in bilp1211.mat, has 1656 variables, 23 equalities and four inequalities with lower and upper bounds set. Runs very slow without the use of cuts. A call xpbiptest(0, 0) gives the fastest execution for the first two problems, but will be extremly slow for the third problem.

It might be interesting the follow the progress towards the solution by setting the global log callback. This could be done by removing the comment from the line

%   callback(9) = 1;

in the code. Timings are made with the Matlab functions tic and toc.

M-files Used

xpress, xpprint

xpiptest

Purpose

Test of the TOMLAB /Xpress level 1 interface solving three larger integer linear optimization problems calling the XpressMP solver.

Calling Syntax

function xpiptest(Cut, PreSolve, MipPre, NodeSel, BackTrack, xpcontrol)

Description of Input

Input Description
Cut Value of the CUTSTRATEGY control parameter, default Cut = -1. Cut = -1, auto select of Cut = 1 or Cut = 2. C ut = 0, no cuts. Cut = 1, conservative cut strategy. Cut = 2, aggressive cut strategy
PreSolve Value of the PRESOLVE control parameter, default PreSolve = 1. PreSolve = 0, no presolve. PreSolve = 1, do presolve.
MipPre Value of the MIPPRESOLVE control parameter, where the default value is dependent on the matrix characteristics. It determines the type of integer processing to be performed in the Branch and Bound. M ipPre = 0, no processing will be performed. If bit 0 is set, do reduced cost fixing at each node. If bit 1 is set, do logical preprocessing on binary variables at each node. If bit 2 is set, do probing of binary variables is performed at the top node. A value M ipP re = 7 will set all three bits as 1.
NodeSel Value of the NODESELECT control parameter. The default value is dependent on the matrix characteristics. It determines which nodes will be considered for solution once the current node has been solved. NodeSel = 1, choose among the two descendant nodes, if none among all active nodes. N odeSel = 2, all nodes are always considered. N odeSel = 3, depth-first search exploring both descendants first. NodeSel = 4, all nodes are considered for the first BREADTHFIRST nodes, after which the usual default behavior is resumed. Setting xpcontrol.BREADTHFIRST influences the last choice.

Description of Input

BackTrack Value of the BACKTRACK control parameter, default value is 3. Determines how the next node in the tree search is selected for processing. BackTrack = 1, if MIPTARGET is not set, choose the node with the best estimate. Otherwise the node choice is based on the Forrest-Hirst-Tomlin Criterion, which takes into account the best current integer solution and seeks a new node which represents a large potential improvement. BackT rack = 2, always choose the node with the best estimated solution. BackT rack = 3, always choose the node with the best bound on the solution.
xpcontrol The initial xpcontrol structure. Here the user may set additional control parameters, e.g. xpcontrol.BREADTHFIRST. Default empty.

Global Parameters Used

MAX_x Maximal number of x elements printed in output statements. Default 20.
MAX_c Maximal number of constraint elements printed in output statements. Default 20.

Description

Test of three larger integer linear optimization problems calling the XpressM P solver. The test problems have

61 variables and 138 linear inequalities. 32 of the 138 inequalities are just zero rows in the matrix A. The three problems are stored in ilp061.mat, ilp062.mat and ilp063.mat.

Code is included to remove the 32 zero rows, and compute better upper bounds using the positivity of the matrix elements, right hand side and the variables. But this does not influence the timing much, the XpressM P presolve will do all these problem changes.

It might be interesting the follow the progress towards the solution by setting the global log callback. This could be done by removing the comment from the line

%   callback(9) = 1;

in the code.

A call xpiptest(2, 1, 3, 3, 3) probably gives the fastest execution. Timings are made with the Matlab functions tic and toc.

M-files Used

xpress, xpprint

xptomtest1

Purpose

Test of using TOMLAB to call XpressM P for problems defined in the TOMLAB IF format.

Calling Syntax

xptomtest1

Description

Test of using TOMLAB to call XpressM P for problems defined in the TOMLAB IF format. The examples show the solution of LP, QP and MILP problems.

M-files Used

tomRun.

See Also

xpressTL.

xptomtest2

Purpose

Test of using TOMLAB to call XpressM P for problems defined in the TOMLAB TQ format.

Calling Syntax

xptomtest2

Description

Test of using TOMLAB to call XpressM P for problems defined in the TOMLAB TQ format. The routine mipAssign is used to define the problem. A simple problem is solved with XpressM P both as an LP problem and as a MILP problem. The problem is solved both with and without explicitly defining the slack variables.

M-files Used

mipAssign, tomRun and PrintResult.

See Also

xpressTL and xpress.

xpknaps

Purpose

XpressM P Matlab level 1 interface Knapsack test routine

Calling Syntax

xpknaps(P, Run, Cut)

Description of Input

Input Description
P Problem number 1-3. Default 1.
Run If empty or Run = 0, run normal XpressM P global solve. If Run > 0 run simple knapsack heuristic in callback xpcb GL.m Default 0.
Cut Cut strategy. 0 = no cuts, 1 = cuts, 2 = aggressive cuts. Default 0.

Global Parameters Used

Parameter Description
MAX_x Maximal number of x elements printed in output statements. Default 20.
MAX_c Maximal number of constraint elements printed in output statements. Default 20.
xpControlVariables Structure with all XpressM P control variables.
xpProblemAttrib Structure with all XpressM P problem attributes.

Description

The XpressM P Matlab level 1 interface knapsack test routine runs three different test problems. It is possible to change cut strategy and use heuristics defined in callbacks.

Currently defined knapsack problems:

Problem Name Knapsacks Variables
1 Weingartner 1 2 28 2 Hansen, Plateau 1 4 28 3 PB 4 2 29

M-files Used

xpress

xpknapsTL

Purpose

XpressMP Matlab level 1 interface Knapsack test routine

Calling Syntax

xpknapsTL(P, Run, Cut)

Description of Input

Input Description
P Problem number 1-3. Default 1.
Run If empty or Run = 0, run normal XpressMP global solve. If Run > 0 run simple knapsack heuristic in callback xpcb GL.m Default 0.
Cut Cut strategy. 0 = no cuts, 1 = cuts, 2 = aggressive cuts. Default 0.

Global Parameters Used

MAX_x Maximal number of x elements printed in output statements. Default 20.
MAX_c Maximal number of constraint elements printed in output statements. Default 20.
xpControlVariables Structure with all XpressMP control variables.
xpProblemAttrib Structure with all XpressMP problem attributes.

Description

The XpressMP Matlab level 2 interface knapsack test routine runs three different test problems. It is possible to change cut strategy and use heuristics defined in callbacks.

Currently defined knapsack problems:

Problem Name Knapsacks Variables
1 Weingartner 1 2 28
2 Hansen, Plateau 1 4 28
3 PB 4 2 29

M-files Used

''xpress''

xptest1

Purpose

Test routine 1, calls XpressMP Matlab level 1 interface to solve a GAP problem.

Calling Syntax

x = xptest1

Global Parameters Used

xpControlVariables Structure with all XpressMP control variables.
xpProblemAttrib Structure with all XpressMP problem attributes.
MAX_x Maximal number of x elements printed in output statements. Default 20.
MAX_c Maximal number of constraint elements printed in output statements. Default 20.

Description

Running a generalized assignment problem (GAP) from Wolsey [2, 9.8.16, pp165]. In this test the linear sos1 constraints are defined explicitly.

Given the matrices A (constraints) and C (costs), xptest1 is using the utility abc2gap to reformulate the problem into the standard form suitable for XpressMP

The number of iterations are increased, no presolve is used, and an aggressive cut strategy.

M-files Used

abc2gap, xpress

xptest2

Purpose

Test routine 2, calls XpressMP Matlab level 1 interface to solve a GAP problem.

Calling Syntax

x = xptest2

Global Parameters Used

xpControlVariables Structure with all XpressMP control variables.
xpProblemAttrib Structure with all XpressMP problem attributes.
MAX_x Maximal number of x elements printed in output statements. Default 20.
MAX_c Maximal number of constraint elements printed in output statements. Default 20.

Description

Running a generalized assignment problem (GAP) from Wolsey [2, 9.8.16, pp165]. In this test sos1 variables are used.

Given the matrices A (constraints) and C (costs), xptest2 is using the utility abc2gap to reformulate the problem into the standard form suitable for XpressMP

The number of iterations are increased, no presolve is used, and an aggressive cut strategy is applied.

M-files Used

abc2gap, xpress

See Also

xptest3

xptest3

Purpose

Test routine 3, calls XpressMP Matlab level 1 interface to solve a GAP problem.

Calling Syntax

x = xptest3

Global Parameters Used

Parameter Description
xpControlVariables Structure with all XpressMP control variables.
xpProblemAttrib Structure with all XpressMP problem attributes.
MAX_x Maximal number of x elements printed in output statements. Default 20.
MAX_c Maximal number of constraint elements printed in output statements. Default 20.

Description

Running a generalized assignment problem (GAP) from Wolsey [2, 9.6, pp159]. In this test the linear sos1 constraints are defined explicitly.

Given the matrices A (constraints) and C (costs), xptest1 is using the utility abc2gap to reformulate the problem into the standard form suitable for XpressMP

The number of iterations are increased, no presolve is used, and no cut strategy is used.

M-files Used

abc2gap, xpress

See Also

xptest2

xptestqp1

Purpose

Simple test of calling XpressMP Matlab level 1 interface to solve a QP problem.

Calling Syntax

x = xptestqp1(MIP)

Description of Input

Input Description
MIP If MIP = 1, run as a MIQP problem, trying to make the first variable integer valued, otherwise run as a pure QP problem. Default MIP = 0.

Global Parameters Used

xpControlVariables Structure with all XpressMP control variables.
xpProblemAttrib Structure with all XpressMP problem attributes.
MAX_x Maximal number of x elements printed in output statements. Default 20.
MAX_c Maximal number of constraint elements printed in output statements. Default 20.

Description

Simple test of calling XpressMP Matlab level 1 interface to solve a QP or MIQP problem. The problem is the first test problem in the TOMLAB qpp rob.m file.

M-files Used

xpress

xptestqp2

Purpose

Simple test of MIQP problem running XpressMP. Simple test of calling XpressMP Matlab level 1 interface to solve a QP problem.

Calling Syntax

x = xptestqp2(MIP)

Description of Input

Input Description
MIP If M I P = 1 (default), run as a MIQP problem, trying to make the first variable integer valued, otherwise run as a pure QP problem.

Global Parameters Used

Parameter Description
xpControlVariables Structure with all XpressM P control variables.
xpProblemAttrib Structure with all XpressM P problem attributes.
MAX_x Maximal number of x elements printed in output statements. Default 20.
MAX_c Maximal number of constraint elements printed in output statements. Default 20.

Description

Simple test of MIQP problem running XpressM P. The MIQP problem is from the Xpress-Optimizer Reference

Manual [1], page 166. The problem is defined as

M-files Used

xpress