Initializing help system before first use

Integer Programming entities in BCL

The BCL code extracts in this document are formulated for the BCL C++ interface. The other BCL interfaces (C, Java, C#) work similarly, please refer to the Xpress documentation for further detail.

Definition: Integer Programming types are specified when creating decision variables (type XPRBvar); types may be changed with setType.

 XPRBprob prob("test");
 XPRBvar d, ifmake[NP][NL], x;
 int p,l;

 d = prob.newVar("d", XPRB_BV);         // Single binary variable

 for (p = 0; p < NP; p++)               // An array of binaries
  for (l = 0; l < NL; l++)
   ifmake[p][l] = prob.newVar("ifmake", XPRB_BV);

 x = prob.newVar("x", XPRB_UI, MINVAL, MAXVAL);  // An integer variable
 // MINVAL,MAXVAL: reals between -XPRB_INFINITY and XPRB_INFINITY
 ...
 x.setType(XPRB_PI);                    // Change type to partial integer
 x.setLim(10);
 ...
 x.setType(XPRB_PL);                    // Change type to continuous

Solving: use mipOptimize, possibly preceded by setSense (the default optimization direction is minimization), to solve a problem as a MIP problem. To solve just the LP relaxation use option "l" (if following up with MIP search) or lpOptimize (ignore all MIP information).

 prob.setSense(XPRB_MINIM);
 prob.mipOptimize("");

Accessing the solution: for obtaining solution values of decision variables and linear expressions use getSol; the MIP problem status is returned by getMIPstatus.

 int mipstatus = prob.getMIPStat();
 switch (mipstatus) {
  case XPRB_MIP_NOT_LOADED:
  case XPRB_MIP_LP_NOT_OPTIMAL:
    cout << "Solving not started" << endl;
    break;
  case XPRB_MIP_LP_OPTIMAL:
    cout << "Root LP solved" << endl;
    break;
  case XPRB_MIP_UNBOUNDED:
    cout << "LP unbounded" << endl;
    break;
  case XPRB_MIP_NO_SOL_FOUND:
  case XPRB_MIP_INFEAS:
    cout << "MIP search started, no solution" << endl;
    break;
  case XPRB_MIP_SOLUTION:
  case XPRB_MIP_OPTIMAL:
    cout << "MIP solution: " << prob.getObjVal() << endl;
    break;
 }
 cout << x.getName() << ": " << x.getSol() << endl;

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