Initializing help system before first use

Solution input

Solutions can be input into the MIP solution pool from file, from memory and they can be captured automatically by the MIP solution pool directly from XPRSprob problems. The following two sections discuss this functionality.

Attaching problems

Of the more useful features of the MIP solution pool type has the ability to 'attach' XPRSprob problems to a MIP solution pool with a call to XPRS_msp_probattach. Once a problem is attached to a MIP solution pool they interact automatically with useful functions. For example, when an attached problem finds a solution it automatically stores the solution into the MIP solution pool.

As illustrated in the UML data model diagram a MIP solution pool can have one or more attached problems although a problem can only be attached to at most one MIP solution pool. The attached problems do not need to be copies of each other and they do not need to have the same number of columns.

The MIP solution pool ensures each solution is automatically loaded to all attached problems with the same number of columns as the solution. Solutions are loaded to a problem when the solver is running the problem with XPRSminim/XPRSmaxim/XPRSglobal. The solver can then use the loaded solutions to update the best solution and/or as a seed for heuristic searches.

Solutions loaded directly from attached problems (compared with solutions loaded by the user from file or from memory) are marked with the MSP_SOL_ISUSERSOLUTION solution attribute set to 0.

Note that problems are automatically detached from their MIP solution pool when they are destroyed (with a call to XPRSdestroyprob. A MIP solution pool automatically detaches all problems when it is destroyed (with a call to XPRS_msp_destroy).

Example:-

#include <stdio.h>
#include <stdio.h>
#include "xprs.h"

int main(int argc, char **argv) {
  XPRSprob prob;
  XPRSmipsolpool msp;
  int i, nSols, nCols, iSolutionId, iSolutionIdStatus;
  double dObj, dSol;
  const char *sProblem = argv[1];

  XPRSinit(NULL);

  XPRScreateprob(&prob);

  XPRSreadprob(prob, sProblem, "");

  XPRS_msp_create(&msp);

  XPRS_msp_probattach(msp, prob);

  XPRSmaxim(prob, "g");

  XPRS_msp_getintattrib(msp, XPRS_MSP_SOLUTIONS, &nSols);

  if(nSols) {

    XPRS_msp_getdblattribprobextreme(msp, prob, 0, &iSolutionId, XPRS_MSP_SOLPRB_OBJ,
                                     &dObj);

    printf("Optimal Solution ID: %i\n", iSolutionId);
    printf("Optimal Objective  : %12.5f\n", dObj);

    XPRS_msp_getintattribsol(msp, iSolutionId, &iSolutionIdStatus, XPRS_MSP_SOL_COLS,
                             &nCols);

    for(i = 0; i < nCols; i++) {
      XPRS_msp_getsol(msp, iSolutionId, &iSolutionIdStatus, &dSol, i, i, NULL);
      printf("%3i = %12.5f\n", i, dSol);
    }

  }

  XPRSdestroyprob(prob);

  XPRS_msp_destroy(msp);

  XPRSfree();
}

Input from file and from memory

Solutions can be input into the MIP solution pool via the file reader routine XPRS_msp_readslxsol or from memory via the XPRS_msp_loadsol routine. When solutions are loaded in these ways the user is returned the ID(s) of the stored solutions. When solutions are input from memory via XPRS_msp_loadsol only one solution is stored per call and the user is returned the ID of the stored solution each time. When solutions are input from file via XPRS_msp_readslxsol the user is returned the first and last ID of the set of solutions that were successfully stored.

Note that solutions are not stored with a mapping of column name to solution index. Therefore, once a solution is stored the user is responsible for mapping the solution values against any column names. The indexing of the solution values is determined when the solution is loaded. When loading solutions from memory with a call to XPRS_msp_loadsol, the solution values are indexed by their position in the dense array. Similarly, solutions loaded automatically to the MIP solution pool from a problem are also indexed in this way.

When loading solutions from .slx file using XPRS_msp_readslxsol the file format has column name/solution value pairs. Solution values may be mapped to solution index using a runtime supplied name map object of type XPRSnamelist passed in the call to XPRS_msp_readslxsol. The XPRSnamelist object is typically obtained from an XPRSprob by calling XPRSgetnamelistobject on the problem to get the column name list (type 2). If the XPRSnamelist object is passed as NULL the solution values are indexed by the order they are encountered in the file.

Solutions loaded by the user from file or from memory (compared with solutions loaded directly from attached problems) are marked with the MSP_SOL_ISUSERSOLUTION solution attribute set to 1.

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