setcallback


Purpose
Set optimizer callback functions and procedures.
Synopsis
procedure setcallback(cbtype:integer, cb:string)
Arguments
cbtype 
Type of the callback:
XPRS_CB_LPLOG 
Simplex log callback
XPRS_CB_CUTLOG 
Cut log callback
XPRS_CB_GLOBALLOG 
Global log callback
XPRS_CB_BARLOG 
Barrier log callback
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_INITCUTMGR 
Cut manager initialization callback
XPRS_CB_FREECUTMGR 
Cut manager termination callback
XPRS_CB_CUTMGR 
Cut manager (branch-and-bound node) callback
XPRS_CB_CHGBRANCH 
User choose branching variable callback
cb 
Name of the callback function/procedure; 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(node:integer):integer 
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 
XPRS_CB_INITCUTMGR
procedure cb 
XPRS_CB_FREECUTMGR
function cb:boolean 
XPRS_CB_CUTMGR
procedure cb(e:integer,u:integer,d:real) 
XPRS_CB_CHGBRANCH
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:
procedure printsol
 declarations
  objval:real
 end-declarations

 objval:= getparam("XPRS_lpobjval")
 writeln("Solution value: ", objval)
end-procedure
	
setcallback(XPRS_CB_INTSOL, "printsol") 
Further information
This procedure sets the optimizer callback functions and procedures. Passing an empty string ("") as the function name disables the corresponding callback. For a detailed description of these callbacks the user is referred to the Xpress-Optimizer Reference Manual. Note that 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. Note further that the function setucbdata can be used to return information to the optimizer from the callback `CHGBRANCH'.


If you have any comments or suggestions about these pages, please send mail to docs@dashoptimization.com.