Initializing help system before first use

Loading solutions

Basic functions

With the Xpress Optimizer, it is possible to load external MIP solutions from memory to help the global search and heuristic algorithms. BCL replicates this same functionality with the XPRBloadmipsol and XPRBaddmipsol functions. In both cases, with solution we mean just the variable solution values: no objective value, slack or dual information is passed to the Optimizer as part of the solutions

.

The first function, XPRBloadmipsol, can be used when the solution values are known for all the model variables and the solution is feasible. The second one, XPRBaddmipsol, can be used even when only a partial solution is known or the "solution" is not feasible. If the provided solution is a partial solution or found to be infeasible, the Optimizer will run a limited local search heuristic in an attempt to find a close feasible integer solution.

In order to be loaded with XPRBaddmipsol, a solution must first be defined as a XPRBsol object. A new XPRBsol solution can be created with the XPRBnewsol function. Individual variables can then be added with function XPRBsetsolvar and arrays of variables with function XPRBsetsolarrvar, each time indicating the corresponding solution values. The current solution size can be obtained with XPRBgetsolsize and assigned variables can be queried or removed with functions XPRBgetsolvar and XPRBdelsolvar. Finally, the entire solution object can be deleted with function XPRBdelsol.

Note that it is also possible load external solutions from file with the XPRBreadbinsol and XPRBreadslxsol functions.

Note:
all variables that are added to a solution must belong to the same problem as the solution itself.

Example

The following code fragment shows how to create a partial solution and load it into the Optimizer with XPRBaddmipsol. It also shows how to set a callback function to receive the notification from the Optimizer on the solution loading outcome, which informs the user if the solution has been accepted and if it has been found to be feasible or required a reoptimization or local search heuristic (note that defining this callback is optional). The complete example can be found in file d1wagon2.c.

/* Callback function reporting loaded solution status */
void XPRS_CC solnotify(XPRSprob my_prob, void* my_object, const char* solname, int status)
{
  printf("Optimizer loaded solution %s with status=%d\n", solname, status);
}
	
void d1w2_solve(XPRBprob prob)
{
  int b;
  XPRBsol sol;
  ...

  /* Create a BCL solution from the heuristic solution previously found */
  sol = XPRBnewsol(prob);

  /* Set the solution values for some discrete variables */
  for (b = 0; b < NBOXES; b++) XPRBsetsolvar(sol, load[b][HeurSol[b]], 1);

  /* Send the solution to the optimizer */
  XPRBaddmipsol(prob, sol, "heurSol");

  /* Free the solution object */
  XPRBdelsol(sol);

  /* Request notification of solution status after processing */
  XPRSaddcbusersolnotify(XPRBgetXPRSprob(prob), solnotify, NULL, 0);	
  ...
}

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