Solving and solution information
As well as enabling model definition, BCL also provides common solving and solution information functions, as summarized in Figure Solving and solution information. For more advanced tasks the user may employ the corresponding Optimizer library functions, once the matrix has been loaded into the Optimizer (function XPRBloadmat). However, only the BCL functions can reference the BCL model objects when retrieving the solution information.
- Solve active problem
-
XPRBlpoptimize(prob,"p");
XPRBmipoptimize(prob,"");
- Status information
-
XPRBgetprobstat(prob);
XPRBgetlpstat(prob);
XPRBgetmipstat(prob);
- Get objective value
-
XPRBgetobjval(prob);
- Load solutions
-
int ncol; double *d; XPRBsol s;
XPRBloadmipsol(prob,d,ncol,1);
XPRBaddmipsol(prob,s);
- Solution reading and writing
-
XPRBreadbinsol(prob,"","");
XPRBreadslxsol(prob,"","");
XPRBwritesol(prob,"","");
XPRBwritebinsol(prob,"","");
XPRBwriteprtsol(prob,"","");
XPRBwriteslxsol(prob,"","");
- Solution information
-
XPRBvar y; XPRBctr c;
XPRBgetsol(y); XPRBgetdual(c);
XPRBgetrcost(y); XPRBgetslack(c);
XPRBgetact(c);
- Ranging information
-
XPRBgetvarrng(y,XPRB_UCOST);
XPRBgetctrrng(c,XPRB_LOACT);
- Fix globals
-
XPRBfixglobals(prob,1);
- Advanced bases
-
XPRBbasis b;
b=XPRBsavebasis(prob);
XPRBloadbasis(b);
XPRBdelbasis(b):
Figure 2.6: Solving and solution information
Before any solution function is called, the objective function must be selected using XPRBsetobj. It is also required to set the sense of the objective, that is, whether to minimize (default) or to maximize the objective. All solution functions XPRBlpoptimize, and XPRBmipoptimize can be parameterized to choose the type of solution algorithm. Once the problem has been solved, the following solution information can be obtained: the optimal objective function value (XPRBgetobjval), values for all the problem variables (XPRBgetsol), slack values (XPRBgetslack), reduced costs (XPRBgetrcost, LP only), constraint activity (XPRBgetact), and dual values (XPRBgetdual, LP only). It is also possible to obtain ranging information for variables (XPRBgetvarrng) and constraints (XPRBgetctrrng) after solving an LP problem.
If the objective function value or solution information for variables or constraints is accessed during the optimization (for instance from Xpress Optimizer callbacks) the solution information in BCL needs to be updated with a call to XPRBsync with the parameter XPRB_XPRS_SOL or XPRB_XPRS_SOLMIP (see Appendix Using BCL with the Optimizer library for more detail).
Before solving or accessing solution information it may be helpful to check the current problem and/or solution status (using functions XPRBgetprobstat, XPRBgetlpstat and XPRBgetmipstat). It may happen that a variable defined in the model does not appear in any constraint, or a constraint only contains 0-valued coefficients so that is ignored when loading the problem into the Optimizer. In these cases the object's column or row index is negative and no solution information can be obtained. It is possible to force the loading of some variables into the Optimizer by creating a type XPRB_N constraint, adding the variables to this constraint (with any non-zero coefficients) and setting the constraint to be an include vars constraint with XPRBsetincvars. Include vars constraints are not loaded into the Optimizer but all variables they contain are always loaded (even if they don't appear in other constraints).
When solving MIP problems, the function XPRBfixglobals fixes all the global entities to the values of the last found MIP solution. This is useful for example for finding the reduced costs of the continuous variables after the global variables have been fixed to their optimal values.
It is possible to load solutions from memory with function XPRBloadmipsol, which loads a solution into BCL or the Optimizer, or XPRBaddmipsol which can also load partial or infeasible solutions into the Optimizer. Solutions can also be written and read from file with XPRBwritesol, XPRBwritebinsol, XPRBwriteprtsol, XPRBwriteslxsol, XPRBreadslxsol.
With BCL, it is also possible to save the current basis of a problem in memory and reload (and/or delete) it after some changes have been carried out to the problem. These changes may include, for instance, the addition or deletion of variables and constraints.
For more advanced functionality using Optimizer library functions refer to the Optimizer Reference Manual.
© 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.