Initializing help system before first use

setcallback

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 
Simplex log callback
XPRS_CB_CUTLOG 
Cut log callback
XPRS_CB_MIPLOG 
Global log callback
XPRS_CB_BARLOG 
Barrier log callback
XPRS_CB_CHGNODE 
User select node callback (deprecated)
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 
New node callback
XPRS_CB_BARITER 
Barrier iteration callback
XPRS_CB_CUTMGR 
Cut manager (branch-and-bound node) callback (deprecated: use XPRS_CB_OPTNODE instead)
XPRS_CB_CHGBRANCH 
User choose branching variable callback (deprecated)
XPRS_CB_PREINTSOL 
Integer solution callback called before acceptation
XPRS_CB_GAPNOTIFY 
Gap notify callback
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 
Check time callback
XPRS_CB_NODELPSOLVED 
A callback fired after the LP relaxation has been solved for the current node during a branch and bound search
XPRS_CB_BEFOREOBJECTIVE 
A callback fired before each objective in a multi-objective problem is solved
XPRS_CB_AFTEROBJECTIVE 
A callback fired after each objective in a multi-objective problem is solved
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_MIPLOG
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(soltype:integer,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
procedure cb 
XPRS_CB_NODELPSOLVED
procedure cb 
XPRS_CB_BEFOREOBJECTIVE
procedure cb 
XPRS_CB_AFTEROBJECTIVE
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-2025 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.