Purpose
Set optimizer callback functions and
procedures.
Synopsis
procedure setcallback(cbtype:integer, cb:string)
procedure setcallback(cbtype:integer, pr:procedure|function)
Arguments
cbtype
|
Type of the callback:
XPRS_CB_LPLOG
|
|
XPRS_CB_CUTLOG
|
|
XPRS_CB_GLOBALLOG
|
|
XPRS_CB_BARLOG
|
|
XPRS_CB_CHGNODE
|
User select node callback
|
XPRS_CB_PRENODE
|
User preprocess node callback
|
XPRS_CB_OPTNODE
|
User optimal node callback
|
XPRS_CB_INFNODE
|
User infeasible node callback
|
XPRS_CB_INTSOL
|
User integer solution callback
|
XPRS_CB_NODECUTOFF
|
User cut-off node callback
|
XPRS_CB_NEWNODE
|
|
XPRS_CB_BARITER
|
Barrier iteration callback
|
XPRS_CB_CUTMGR
|
Cut manager (branch-and-bound node) callback
|
XPRS_CB_CHGBRANCH
|
User choose branching variable callback
|
XPRS_CB_PREINTSOL
|
Integer solution callback called before acceptation
|
XPRS_CB_GAPNOTIFY
|
|
XPRS_CB_SOLNOTIFY
|
Integer notify callback called each time a solution added with
addmipsol is processed
|
XPRS_CB_PRESOLVE
|
A callback fired after presolve is performed
|
XPRS_CB_COMPUTERESTART
|
A callback fired when a solve in compute mode had to be restarted
|
XPRS_CB_CHECKTIME
|
|
|
cb
|
Name of the callback function/procedure (that must be public); the parameters and the type of the return value (if any) vary depending on the type of the callback:
function cb:boolean
|
XPRS_CB_LPLOG
|
function cb:boolean
|
XPRS_CB_CUTLOG
|
function cb:boolean
|
XPRS_CB_GLOBALLOG
|
function cb:boolean
|
XPRS_CB_BARLOG
|
function cb(node:integer):integer
|
XPRS_CB_CHGNODE
|
function cb:boolean
|
XPRS_CB_PRENODE
|
function cb:boolean
|
XPRS_CB_OPTNODE
|
procedure cb
|
XPRS_CB_INFNODE
|
procedure cb
|
XPRS_CB_INTSOL
|
procedure cb(node:integer)
|
XPRS_CB_NODECUTOFF
|
procedure cb(parent:integer,new:integer,branch:integer)
|
XPRS_CB_NEWNODE
|
function cb:integer
|
XPRS_CB_BARITER
|
function cb:boolean
|
XPRS_CB_CUTMGR
|
procedure cb(e:integer,u:integer,d:real)
|
XPRS_CB_CHGBRANCH
|
procedure cb(isheur:boolean,cutoff:real)
|
XPRS_CB_PREINTSOL
|
procedure cb(rt:real,at:real,aot:real,abt:real)
|
XPRS_CB_GAPNOTIFY
|
procedure cb(solid:string,status:integer)
|
XPRS_CB_SOLNOTIFY
|
procedure cb
|
XPRS_CB_PRESOLVE
|
procedure cb
|
XPRS_CB_COMPUTERESTART
|
function cb:boolean
|
XPRS_CB_CHECKTIME
|
|
pr
|
A subroutine reference compatible with the corresponding callback (see above).
|
Example
The following example defines a procedure to handle solution printing and sets it to be called whenever an integer solution is found using the integer solution callback:
public procedure printsol
declarations
objval:real
end-declarations
objval:= getparam("XPRS_lpobjval")
writeln("Solution value: ", objval)
end-procedure
setcallback(XPRS_CB_INTSOL, "printsol")
Further information
1. This procedure sets the optimizer callback functions and procedures. For a detailed description of these callbacks the user is referred to the
Xpress Optimizer Reference Manual.
2. Passing an empty string (
"") as the function name disables the corresponding callback.
3. The arguments of the Mosel subroutines implementing callback functions correspond to the arguments documented in the
Xpress Optimizer Reference Manual, with the exception of arguments that are used for passing back information to the solver: these are replaced by the subroutine return values. For the logging callbacks, the return value
true interrupts the solving. For the
PRENODE and
OPTNODE callbacks the return value
true declares the current node to be infeasible. The return value of the
BARITER callback is the selected barrier action (see
XPRSaddcbbariteraction in the
Xpress Optimizer Reference Manual for details). The cut manager routine is called repeatedly at each node until it returns
false.
4. Whilst the solution values can be accessed from Mosel in any callback function/procedure, all other information such as the problem status or the value of the objective function must be obtained directly from the Optimizer using function
getparam.
5. The function
setucbdata can be used to return information to the optimizer from the callback `CHGBRANCH'.
6. The functions
rejectintsol and
setcbcutoff can be used to return information to the optimizer from the callback `PREINTSOL'.
7. The function
setgndata can be used to return information to the optimizer from the callback `GAPNOTIFY'.
8. When the
mmxnlp model is used, this function can also be used to set the callbacks relevant to non-linear problems only. Please see the documentation of the
mmxnlp module for the list of extra callbacks.
Module
© 2001-2022 Fair Isaac Corporation. All rights reserved. This documentation is the
property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not
convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except
solely for internal evaluation purposes to determine whether to purchase a license to the software
described in this documentation, or as otherwise set forth in a written software license agreement
between you and FICO (or a FICO affiliate). Use of this documentation and the software described in
it must conform strictly to the foregoing permitted uses, and no other use is permitted.