XPRBcut
- java.lang.Object
-
- com.dashoptimization.XPRBcut
-
public class XPRBcut extends java.lang.Object
This class represents a cut definition in BCL. All terms in a cut must belong to the same problem as the cut itself.
-
-
Method Summary
Modifier and Type Method and Description void
add(double val)
void
add(XPRBexpr l)
Add a linear expression to a cut.void
add(XPRBvar var)
void
addTerm(double val)
Add a constant term to a cut.void
addTerm(double val, XPRBvar var)
void
addTerm(XPRBvar var)
void
addTerm(XPRBvar var, double val)
Add a variable term to a cut.void
assign(XPRBrelation lr)
Assign a linear relation to a cut.void
delTerm(XPRBvar var)
Delete a variable term from a cut.int
getID()
Get the ID of a cut.double
getRHS()
Get the RHS value (= constant term) of a cut.int
getType()
Get the type of a cut.boolean
isValid()
Test whether a cut is correctly defined.void
print()
Print out a cut.void
setID(int val)
Set the cut ID value.void
setTerm(double val)
Set the constant term (= RHS value) of a cut.void
setTerm(double val, XPRBvar var)
void
setTerm(XPRBvar var, double val)
Set a cut term.void
setType(int type)
Set the cut row type.java.lang.String
toString()
-
-
-
Method Detail
-
isValid
public boolean isValid()
Test whether a cut is correctly defined.XPRBcut cut1; if(cut1.isValid() == false) System.out.println("Error in cut definition.");
-
assign
public void assign(XPRBrelation lr) throws java.lang.ArithmeticException
Assign a linear relation to a cut.XPRBprob expl2; XPRBvar x1, x2; XPRBrelation lr; XPRBcut cut5; expl2 = new XPRBprob("example2"); x1 = expl2.newVar("abc3", XPRB.UI, 1, 100); x2 = expl2.newVar("abc1", XPRB.PL, 0, XPRB.INFINITY); lr = x2.gEql(x1); cut5.assign(lr);
- Parameters:
-
lr
- linear relation - Throws:
-
java.lang.ArithmeticException
- If the relation is not linear.
-
setType
public void setType(int type)
Set the cut row type. This method changes the type of a previously defined cut to inequality or equation.XPRBprob expl2; XPRBcut cut1; expl2 = new XPRBprob("example2"); cut1 = expl2.newCut(1); cut1.setType(XPRB.E);
- Parameters:
-
type
- Constraint type. Possible values:XPRB.L
<= (inequality)XPRB.G
>= (inequality)XPRB.E
= (equation)
-
setID
public void setID(int val)
Set the cut ID value. This method changes the ID value of a previously defined cut. The cut ID can be chosen freely by the user to identify or classify (groups of) cuts.XPRBprob expl2; XPRBcut cut1; expl2 = new XPRBprob("example2"); cut1 = expl2.newCut(); cut1.setID(10);
- Parameters:
-
val
- Cut ID value.
-
getRHS
public double getRHS()
Get the RHS value (= constant term) of a cut. The default RHS value is 0.XPRBprob expl2; XPRBcut cut1; double rhs; expl2 = new XPRBprob("example2"); cut1 = expl2.newCut(1); rhs = cut1.getRHS();
- Returns:
- Right hand side (RHS) value (default 0)
-
getType
public int getType()
Get the type of a cut.XPRBprob expl2; XPRBcut cut1; int rtype; expl2 = new XPRBprob("example2"); cut1 = expl2.newCut(1); rtype = cut1.getType();
- Returns:
-
Constraint type. Possible values:
XPRB.L
<= (inequality)XPRB.G
>= (inequality)XPRB.E
= (equation)-1
an error has occurred
-
getID
public int getID()
Get the ID of a cut. The default ID value is 0.XPRBprob expl2; XPRBcut cut1; int val; expl2 = new XPRBprob("example2"); cut1 = expl2.newCut(1); val = cut1.getID();
- Returns:
- Cut ID value.
-
setTerm
public void setTerm(XPRBvar var, double val)
Set a cut term. This method sets the coefficient of a given variable to the valuecoeff
.XPRBprob expl2; XPRBcut cut1; XPRBvar x1; expl2 = new XPRBprob("example2"); x1 = expl2.newVar("abc3", XPRB.UI, 1, 100); cut1 = expl2.newCut(1); cut1.setTerm(x1, 5.4);
- Parameters:
-
var
- variable of typeXPRBvar
-
val
- value of the coefficient of the variablevar
-
setTerm
public void setTerm(double val)
Set the constant term (= RHS value) of a cut. The RHS of the cut is set to the given constant.XPRBprob expl2; XPRBcut cut1; expl2 = new XPRBprob("example2"); cut1 = expl2.newCut(1); cut1.setTerm(7);
- Parameters:
-
val
- constant term (RHS value)
-
setTerm
public void setTerm(double val, XPRBvar var)
- See Also:
-
setTerm(var, val)
-
addTerm
public void addTerm(XPRBvar var, double val)
Add a variable term to a cut. This method adds a new term to a cut, comprising the variablevar
with coefficientcoeff
. If the cut already has a term with variablevar
,coeff
is added to its coefficient.XPRBprob expl2; XPRBcut cut1; XPRBvar x1; expl2 = new XPRBprob("example2"); x1 = expl2.newVar("abc3", XPRB.UI, 1, 100); cut1 = expl2.newCut(1); cut1.addTerm(x1, 5.4);
- Parameters:
-
var
- variable of typeXPRBvar
-
val
- value to be added to the coefficient of the variablevar
-
addTerm
public void addTerm(double val, XPRBvar var)
- See Also:
-
addTerm(var, val)
-
addTerm
public void addTerm(XPRBvar var)
- See Also:
-
addTerm(var, 1)
-
addTerm
public void addTerm(double val)
Add a constant term to a cut. The given constant term is added to the RHS value of the cut.XPRBprob expl2; XPRBcut cut1; expl2 = new XPRBprob("example2"); cut1 = expl2.newCut(1); cut1.addTerm(7);
- Parameters:
-
val
- value to be added to the RHS of the cut
-
delTerm
public void delTerm(XPRBvar var)
Delete a variable term from a cut.XPRBprob expl2; XPRBcut cut1; XPRBvar x1; expl2 = new XPRBprob("example2"); x1 = expl2.newVar("abc3", XPRB.UI, 1, 100); cut1 = expl2.newCut(1); cut1.addTerm(x1, 5.4); cut1.delTerm(x1);
- Parameters:
-
var
- variable of typeXPRBvar
-
add
public void add(XPRBexpr l) throws java.lang.ArithmeticException
Add a linear expression to a cut. The entire linear expression given is added to the left hand side of the cut. That is, in order to normalize the cut representation, any constant term contained in the linear expression will be subtracted from the RHS value.XPRBprob expl2; XPRBcut cut1; XPRBvar x1; expl2 = new XPRBprob("example2"); x1 = expl2.newVar("abc3", XPRB.UI, 1, 100); cut1 = expl2.newCut(1); cut1.add(x1.add(17));
- Parameters:
-
l
- linear expression of typeXPRBexpr
- Throws:
-
java.lang.ArithmeticException
- If the relation is not linear.
-
add
public void add(XPRBvar var)
- See Also:
-
addTerm(var, 1)
-
add
public void add(double val)
- See Also:
-
addTerm(val)
-
print
public void print()
Print out a cut. This method prints out a cut in LP-format.XPRBprob expl2; XPRBcut ctr2; XPRBvar x4[5]; XPRBcut ctr2; int i; for(i=0;i<5;i++) x4[i] = expl2.newVar("x4", XPRB.PL, 0, 500); ctr2 = expl2.newCtr("r2", x4[0].add(x4[1]).eql(9)); ctr2.print();
-
toString
public java.lang.String toString()
- Overrides:
-
toString
in classjava.lang.Object
- See Also:
-
getID()
-
-
© 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.