# TOMLAB  
# REGISTER (TOMLAB)
# LOGIN  
# myTOMLAB
TOMLAB LOGO

« Previous « Start » Next »

4  Callbacks in Matlab

There are eleven of the XpressMP callbacks defined in the interface. A logical vector defines the callbacks to be used in XpressMP . This vector is named callback and is one of the input variables to the level 1 interface routine xpress (Section A.1). If the ith entry of the logical vector callback is set, the corresponding callback is defined. See Section 5.3 in [1]. The callback calls the m-file specified in Table 2. The user can edit this m-file directly, or make a new copy. It is important that a new copy is placed in a directory that is searched before the xpress directory when Matlab goes through the Matlab path.



Table 2: The m-file callback routines.


Index m-file Description Section
(1) xpcb_usn User Select Node Callback D.11
(2) xpcb_upn User Preprocess Node Callback D.10
(3) xpcb_uon User Optimal Node Callback D.8
(4) xpcb_uin User Infeasible Node Callback D.6
(5) xpcb_uis User Integer Solution Callback D.7
(6) xpcb_ucn User Node Cut-off Callback D.5
(7) xpcb_ucb User Choose Branching Variable Callback D.4
(8) xpcb_il Simplex Log Callback D.3
(9) xpcb_gl Global Log D.2
(10) xpcb_bl Barrier Log Callback D.1
(11) xpcb_uop User Output Callback D.9

Before each call to the callback routine, the interface is defining the control variables and problem attributes as global variables in Matlab. By making the following global declarations in the callback m-file,
global xpControlVariables xpProblemAttrib
all control variables and problem attributes are accessible as subfields to the global variables.

The Prob structure is input to all callback m-file routines as the last parameter. If TOMLAB calls xpress, then Prob is the standard TOMLAB problem structure, otherwise the user optionally can set: Prob.P = ProblemNumber;, where ProblemNumber is some integer. If any callback is defined (see description of callback) then the arrays that define the current problem are set by the interface as fields in Prob. The defined fields are Prob.c, Prob.x_L, Prob.x_U, Prob.A, Prob.b_L, Prob.b_U and. Prob.QP.F. The user then has full access to the original problem in the callback routine.

In one of the callback routines, xpcb_gl, a simple knapsack heuristic is implemented. This heuristic is also part of the standard XpressMP example files. Running the knapsack test program xpknaps, with the second input argument Run = 1 runs the knapsack heuristic in the callback. xpknaps sets Prob.MIP.KNAPSACK = 1 to enable execution of the heuristic in xpcb_gl.

If there are no integer variables in the problem to be solved, i.e. a pure LP or QP problem, then the first seven callbacks as well as the 9th callback (Global Log) are automatically disabled. If the problem is a mixed-integer problem, then the 8th callback (Simplex Log Callback) is disabled. This change is made on around row 254 i xpress.m and the user may comment this row (callback(8) = 0;) to avoid it.

« Previous « Start » Next »