Initializing help system before first use

XPRBcut

Description
Methods for modifying and accessing cuts and operators for constructing them. Note that all terms in a cut must belong to the same problem as the cut itself.
Constructors
Methods
Add a linear expression to a cut.
Add a term to a cut.
Delete a term from a cut.
Get the C modeling object.
Get the classification or identification number of a cut.
Get the RHS value of a cut.
Get the type of a cut.
Test the validity of the cut object.
Print out a cut.
Reset the cut object.
Set the classification or identification number of a cut.
Set a cut term.
Set the type of a cut.
Operators
Assigning cuts and adding linear expressions:
cut = linrel
cut += linexp
cut -= linexp

Constructor detail

XPRBcut
Synopsis
XPRBcut();
XPRBcut(xbcut *c);
XPRBcut(xbcut *c, XPRBrelation& r);
Arguments
A cut in BCL C.
Linear relation defining the cut.
Description
Create a new cut object.

Method detail

add
Synopsis
int add(XPRBexpr& le);
Argument
le 
A linear expression (may be a single variable or a constant).
Return value
0 if method executed successfully, 1 otherwise.
Description
This method adds a linear expression to a cut. That means, if the linear expression contains a constant, this value is subtracted from the constant representing the right hand side of the cut.
Example
This example defines a cut and then modifies its definition by adding a terms and changing the coefficient of a variable. The resulting cut definitions (as displayed by XPRBcut.print) are shown as comments. Please notice in particular the different behavior of add and addTerm for the addition of constants.
 XPRBvar x,y,b;
 XPRBcut Cut2;
 XPRBprob prob("myprob");

 x = prob.newVar("y", XPRB_PL, 0, 200);
 y = prob.newVar("y", XPRB_PL, 0, 200);
 b = prob.newVar("b", XPRB_BV);

 Cut2 = prob.newCut(y <= 100*b, 1);
 Cut2.add(x+2);                // x + y - 100*b <= -2
 Cut2.delTerm(x);              //     y - 100*b <= -2
 Cut2.setTerm(0);              //     y - 100*b <= 0
 Cut2 += x+2;                  // x + y - 100*b <= -2
 Cut2.addTerm(2);              // x + y - 100*b <= 0
 Cut2.setTerm(y, -5);          // x - 5*y - 100*b <= 0 

addTerm
Synopsis
int addTerm(XPRBvar& var, double val);
int addTerm(double val, XPRBvar& var);
int addTerm(XPRBvar& var);
int addTerm(double val);
Arguments
var 
A BCL variable.
val 
Value of the coefficient of the variable var.
Return value
0 if method executed successfully, 1 otherwise.
Description
This method adds a new term to a cut, comprising the variable var with coefficient val. If the cut already has a term with variable var, val is added to its coefficient. If no variable is specified, the value val is added to the right hand side of the cut. Cut terms can also be added with method XPRBcut.add.
Example
Related topics

delTerm
Synopsis
int delTerm(XPRBvar& var);
Argument
var 
A BCL variable.
Return value
0 if method executed successfully, 1 otherwise.
Description
This method removes a variable term from a cut. The constant term (right hand side value) is changed/reset with method XPRBcut.setTerm.
Example
Related topics

getCRef
Synopsis
xbcut *getCRef();
Return value
The underlying modeling object in BCL C.
Description
This method returns the cut object in BCL C that belongs to the C++ cut object.

getID
Synopsis
int getID();
Return value
Classification or identification number.
Description
This method returns the classification or identification number of a cut.
Example
Related topics
Calls XPRBgetcutid

getRHS
Synopsis
double getRHS();
Return value
Right hand side (RHS) value (default 0).
Description
This method returns the RHS value (= constant term) of a previously defined cut. The default RHS value is 0.
Related topics

getType
Synopsis
int getType();
Return value
XPRB_L 
(inequality)
XPRB_G 
(inequality)
XPRB_E 
= (equation)
-1 
An error has occurred,
Description
This method returns the type of the given cut.
Related topics

isValid
Synopsis
bool isValid();
Return value
true if object is valid, false otherwise.
Description
This method checks whether the cut object is correctly defined.

print
Synopsis
int print();
Return value
0 if function executed successfully, 1 otherwise.
Description
This function prints out a cut in LP format.
Example
Related topics
Calls XPRBprintcut

reset
Synopsis
void reset();
Description
Clear the definition of the cut object.

setID
Synopsis
int setID(int id);
Argument
id 
Classification or identification number.
Return value
0 if method executed successfully, 1 otherwise.
Description
This function changes the classification or identification number of a previously defined cut. This change does not have any effect on the cut definition in Xpress Optimizer if the cut has already been added to the matrix with XPRBprob.addCuts.
Example
This example defines a cut and then modifies its ID and relation type. The resulting output is shown in the comment.
XPRBvar y,b;
XPRBcut Cut1;
XPRBprob prob("myprob");

y = prob.newVar("y", XPRB_PL, 0, 200);
b = prob.newVar("b", XPRB_BV);

Cut1 = prob.newCut(y == 100*b);
Cut1.setID(1);
if (Cut1.getID()>0)  Cut1.setType(XPRB_G);
Cut1.print();             // CUT(1):  y - 100*b >= 0 
Related topics
Calls XPRBsetcutid

setTerm
Synopsis
int setTerm(XPRBvar& var, double val);
int setTerm(double val, XPRBvar& var);
int setTerm(XPRBvar& var);
int setTerm(double val);
Arguments
var 
A BCL variable.
val 
Value of the coefficient of the variable var.
Return value
0 if method executed successfully, 1 otherwise.
Description
This function sets the coefficient of a variable to the value val. If no variable is specified, the right hand side of the cut is set to val.
Example
Related topics

setType
Synopsis
int setType(int type);
Argument
type 
Type of the cut:
XPRB_L 
(inequality)
XPRB_G 
(inequality)
XPRB_E 
= (equation)
Return value
0 if method executed successfully, 1 otherwise.
Description
This function changes the type of the given cut. This change does not have any effect on the cut definition in Xpress Optimizer if the cut has already been added to the matrix with the method XPRBprob.addCuts.
Example
Related topics


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