Initializing help system before first use

XPRSaddcbintsol

XPRSaddcbintsol


Purpose
Declares a user integer solution callback function, called every time an integer solution is found by heuristics or during the Branch and Bound search. This callback function will be called in addition to any callbacks already added by XPRSaddcbintsol.
Synopsis
int XPRS_CC XPRSaddcbintsol(XPRSprob prob, void (XPRS_CC *f_intsol)(XPRSprob my_prob, void *my_object), void *object, int priority);
Arguments
prob 
The current problem.
f_intsol 
The callback function which takes two arguments, my_prob and my_object, and has no return value. This function is called if the current node is found to have an integer feasible solution, i.e. every time an integer feasible solution is found.
my_prob 
The problem passed to the callback function, f_intsol.
my_object 
The user-defined object passed as object when setting up the callback with XPRSaddcbintsol.
object 
A user-defined object to be passed to the callback function, f_intsol.
priority 
An integer that determines the order in which multiple integer solution callbacks will be invoked. The callback added with a higher priority will be called before a callback with a lower priority. Set to 0 if not required.
Example
The following example prints integer solutions as they are discovered in the global search:
XPRSaddcbintsol(prob,printsol,NULL,0);
XPRSmipoptimize(prob,"");
The callback function might resemble:
void XPRS_CC printsol(XPRSprob my_prob, void *object)
{
  int i, cols;
  double objval, *x;

  XPRSgetintattrib(my_prob, XPRS_ORIGINALCOLS, &cols);
  XPRSgetdblattrib(my_prob, XPRS_LPOBJVAL, &objval);
  x = malloc(cols * sizeof(double));
  if (!x) return;
  XPRSgetlpsol(my_prob, x, NULL, NULL, NULL);

  printf("\nInteger solution found: %f\n", objval);
  for(i=0;i<cols;i++) printf(" x[%d] = %d\n", i, x[i]);
  free(x);
}
Further information
1. This callback is useful if the user wants to retrieve the integer solution when it is found.
2. To retrieve the integer solution, use either XPRSgetlpsol or XPRSgetpresolvesol. XPRSgetmipsol always returns the last integer solution found and, if called from the intsol callback, it will not necessarily return the solution that caused the invocation of the callback (for example, it is possible that when solving with multiple MP threads, another thread finds a new integer solution before the user calls XPRSgetmipsol).
3. This callback is called after a new integer solution was found by the Optimizer. Use a callback set by XPRSaddcbpreintsol in order to be notified before a new integer solution is accepted by the Optimizer, which allows for the new solution to be rejected.
Related topics

© 2001-2020 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.