public class XPRBctr
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
void |
add(double val) |
void |
add(XPRBexpr l)
Add a linear expression to a constraint.
|
void |
add(XPRBvar var) |
void |
addTerm(double val)
Add a constant term to a constraint.
|
void |
addTerm(double val,
XPRBvar var) |
void |
addTerm(double val,
XPRBvar var1,
XPRBvar var2) |
void |
addTerm(XPRBvar var) |
void |
addTerm(XPRBvar var,
double val)
Add a linear term to a constraint.
|
void |
addTerm(XPRBvar var1,
XPRBvar var2,
double val)
Add a quadratic term to a constraint.
|
void |
assign(XPRBrelation lr)
Assign a linear relation to a constraint.
|
void |
delTerm(XPRBvar var)
Delete a linear term from a constraint.
|
void |
delTerm(XPRBvar var1,
XPRBvar var2)
Delete a quadratic term from a constraint.
|
double |
getAct()
Get the activity value for a constraint.
|
double |
getCoefficient(XPRBvar var)
Get the coefficient of a linear constraint term.
|
double |
getCoefficient(XPRBvar var1,
XPRBvar var2)
Get the coefficient of a quadratic constraint term.
|
double |
getDual()
Get the dual value for a constraint.
|
int |
getIndicator()
Get the indicator type of a constraint.
|
XPRBvar |
getIndVar()
Get the indicator variable of a constraint.
|
java.lang.String |
getName()
Get the name of a constraint.
|
java.lang.Iterable<XPRBqterm> |
getQTerms()
Returns an iterable (anonymous) object over the quadratic terms in this constraint.
|
double |
getRangeL()
Get the lower range bound for a range constraint.
|
double |
getRangeU()
Get the upper range bound for a range constraint.
|
double |
getRHS()
Get the RHS value (= constant term) of a constraint.
|
double |
getRNG(int rngtype)
Get ranging information for a constraint.
|
int |
getRowNum()
Get the row number for a constraint.
|
int |
getSize()
Get the size of a constraint.
|
double |
getSlack()
Get the slack value for a constraint.
|
java.lang.Iterable<XPRBterm> |
getTerms()
Returns an iterable (anonymous) object over the linear terms in this constraint.
|
int |
getType()
Get the type of a constraint.
|
boolean |
isDelayed()
Test the type of a constraint.
|
boolean |
isIncludeVars()
Test the type of a constraint.
|
boolean |
isIndicator()
Test the indicator type of a constraint.
|
boolean |
isModCut()
Test the type of a constraint.
|
boolean |
isValid()
Test whether a constraint is correctly defined.
|
void |
print()
Print out a constraint.
|
void |
setDelayed(boolean d)
Set the constraint type.
|
void |
setIncludeVars(boolean i)
Set the constraint type.
|
void |
setIndicator(int dir) |
void |
setIndicator(int dir,
XPRBvar b)
Set the indicator constraint type.
|
void |
setIndicator(XPRBvar b,
int dir) |
void |
setModCut(boolean m)
Set the constraint type.
|
void |
setRange(double lb,
double ub)
Define a range constraint.
|
void |
setTerm(double val)
Set the constant term (= RHS value) of a constraint.
|
void |
setTerm(double val,
XPRBvar var) |
void |
setTerm(double val,
XPRBvar var1,
XPRBvar var2) |
void |
setTerm(XPRBvar var,
double val)
Set a linear constraint term.
|
void |
setTerm(XPRBvar var1,
XPRBvar var2,
double val)
Set a quadratic constraint term.
|
void |
setType(int type)
Set the constraint row type.
|
java.lang.String |
toString() |
public boolean isValid()
XPRBctr ctr1;
if(ctr1.isValid() == false)
System.out.println("Error in constraint definition.");
public void assign(XPRBrelation lr)
XPRBprob expl2;
XPRBvar x1, x2;
XPRBrelation lr;
XPRBctr ctr5;
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);
ctr5.assign(lr);
lr - linear relationpublic void setType(int type)
setRange(double, double) has to be used for
changing the constraint to a ranged constraint. If a ranged constraint
is changed back to some other type with this method, its upper bound
becomes the RHS value.
XPRBprob expl2;
XPRBctr ctr1;
expl2 = new XPRBprob("example2");
ctr1 = expl2.newCtr("r1");
ctr1.setType(XPRB.E);
type - Constraint type. Possible values:
XPRB.L <= (inequality)XPRB.G >= (inequality)XPRB.E = (equation)XPRB.N non-bindingpublic void setRange(double lb,
double ub)
lb and ub.
The constraint type and RHS value of the constraint are replaced by
the type XPRB.R (range) and the two bounds.
XPRBprob expl2;
XPRBvar x4[5];
XPRBctr 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.setRange(4.0, 15.5);
lb - lower bound on the range constraintub - upper bound on the range constraintpublic void setDelayed(boolean d)
XPRBprob expl2;
XPRBctr ctr1;
expl2 = new XPRBprob("example2");
ctr1 = expl2.newCtr("r1");
ctr1.setDelayed(1);
d - Constraint type. Possible values:
true delayed constraintfalse ordinary constraintpublic boolean isDelayed()
XPRBprob expl2;
XPRBctr ctr1;
boolean dstat;
expl2 = new XPRBprob("example2");
ctr1 = expl2.newCtr("r1");
dstat = ctr1.isDelayed();
true model cutfalse constraintpublic void setIncludeVars(boolean i)
XPRBprob expl2;
XPRBctr ctr1;
expl2 = new XPRBprob("example2");
ctr1 = expl2.newCtr("r1");
ctr1.setIncludeVars(true);
i - Constraint type. Possible values:
true include varsfalse ordinary constraintpublic boolean isIncludeVars()
XPRBprob expl2;
XPRBctr ctr1;
boolean dstat;
expl2 = new XPRBprob("example2");
ctr1 = expl2.newCtr("r1");
dstat = ctr1.isIncludeVars();
true include varsfalse constraintpublic void setIndicator(int dir,
XPRBvar b)
XPRBprob expl2;
XPRBctr ctr1;
XPRBvar b, x1, x2;
expl2 = new XPRBprob("example2");
ctr1 = expl2.newCtr("r1", x2.gEql(x1));
b = expl2.newVar("b", XPRB.BV);
ctr1.setIndicator(1, b); // Results in: b=1 -> ctr1
dir - Constraint type. Possible values:
-1 indicator constraint with condition b=00 ordinary constraint1 indicator constraint with condition b=1b - Previsouly created binary variablepublic void setIndicator(XPRBvar b, int dir)
setIndicator(dir, b)public void setIndicator(int dir)
setIndicator(dir, null)public int getIndicator()
XPRBprob expl2;
XPRBctr ctr1;
int dir;
expl2 = new XPRBprob("example2");
ctr1 = expl2.newCtr("r1");
dir = ctr1.getIndicator();
-1 indicator constraint with condition b=00 ordinary constraint1 indicator constraint with condition b=1public XPRBvar getIndVar()
XPRBprob expl2;
XPRBctr ctr1;
XPRBvar x;
expl2 = new XPRBprob("example2");
ctr1 = expl2.newCtr("r1");
if (ctr1.isIndicator()) x = ctr1.getIndVar();
XPRBvar
(check its validity with XPRBvar.isValid()).public boolean isIndicator()
XPRBprob expl2;
XPRBctr ctr1;
boolean istat;
expl2 = new XPRBprob("example2");
ctr1 = expl2.newCtr("r1");
istat = ctr1.isIndicator();
true indicator constraintfalse ordinary constraintpublic void setModCut(boolean m)
XPRBprob expl2;
XPRBctr ctr1;
expl2 = new XPRBprob("example2");
ctr1 = expl2.newCtr("r1");
ctr1.setModCut(true);
m - Constraint type. Possible values:
true model cutfalse ordinary constraintpublic boolean isModCut()
XPRBprob expl2;
XPRBctr ctr1;
boolean mcstat;
expl2 = new XPRBprob("example2");
ctr1 = expl2.newCtr("r1");
mcstat = ctr1.isModCut();
true model cutfalse ordinary constraintpublic java.lang.String getName()
XPRBprob expl2;
XPRBctr ctr1;
expl2 = new XPRBprob("example2");
ctr1 = expl2.newCtr("r1");
System.out.println(ctr1.getName());
null otherwisepublic double getRangeL()
XPRBprob expl2;
XPRBvar x4[5];
XPRBctr ctr2;
int i;
double lr;
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));
lr = ctr2.getRangeL();
ctr2
public double getRangeU()
XPRBprob expl2;
XPRBvar x4[5];
XPRBctr ctr2;
int i;
double lr;
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));
lr = ctr2.getRangeU();
ctr2
public double getRHS()
XPRBprob expl2;
XPRBctr ctr1;
double rhs;
expl2 = new XPRBprob("example2");
ctr1 = expl2.newCtr("r1");
rhs = ctr1.getRHS();
public int getRowNum()
XPRB.N or no non-zero terms) then the return value is
negative. The counting of row numbers starts with 0.
XPRBprob expl2;
XPRBctr ctr1;
int rindex;
expl2 = new XPRBprob("example2");
ctr1 = expl2.newCtr("r1");
rindex = ctr1.getRowNum();
public int getSize()
XPRBprob expl2;
XPRBctr ctr1;
int size;
expl2 = new XPRBprob("example2");
ctr1 = expl2.newCtr("r1");
size = ctr1.getSize();
public int getType()
XPRBprob expl2;
XPRBctr ctr1;
int rtype;
expl2 = new XPRBprob("example2");
ctr1 = expl2.newCtr("r1");
rtype = ctr1.getType();
XPRB.L <= (inequality)XPRB.G >= (inequality)XPRB.E = (equation)XPRB.N non-bindingXPRB.R range constraint-1 an error has occurredpublic double getSlack()
XPRBprob expl2;
XPRBvar x4[5];
XPRBctr ctr2;
int i;
double slack;
expl2 = new XPRBprob("example2");
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));
expl2.lpOptimize();
slack = ctr2.getSlack();
public double getAct()
XPRBprob expl2;
XPRBvar x4[5];
XPRBctr ctr2;
int i;
double act;
expl2 = new XPRBprob("example2");
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));
expl2.lpOptimize();
act = ctr2.getAct();
public double getDual()
XPRBprob expl2;
XPRBvar x4[5];
XPRBctr ctr2;
int i;
double dual;
expl2 = new XPRBprob("example2");
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));
expl2.lpOptimize();
slack = ctr2.getDual();
public double getRNG(int rngtype)
XPRBprob expl2;
XPRBvar x4[5];
XPRBctr ctr2;
int i;
double upact;
expl2 = new XPRBprob("example2");
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));
expl2.lpOptimize();
upact = ctr2.getRNG(XPRB.UPACT);
rngtype - Ranging information type. Possible values:
XPRB.UPACT the largest value which the constraint RHS can take while the current basis remains optimalXPRB.LOACT the smallest value which the constraint RHS can take while the current basis remains optimalXPRB.UUP the change in objective value per unit increase in the constraint RHS, assuming the the current basis remains optimalXPRB.UDN the change in objective value per unit decrease in the constraint RHS, assuming the the current basis remains optimalpublic void setTerm(XPRBvar var, double val)
val.
XPRBprob expl2;
XPRBctr ctr1;
XPRBvar x1;
expl2 = new XPRBprob("example2");
x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
ctr1 = expl2.newCtr("r1");
ctr1.setTerm(x1, 5.4);
var - variable of type XPRBvarval - value of the coefficient of the variable varpublic void setTerm(double val,
XPRBvar var)
setTerm(var, val)public void setTerm(XPRBvar var1, XPRBvar var2, double val)
val.
XPRBprob expl2;
XPRBctr ctr1;
XPRBvar x1, x2;
expl2 = new XPRBprob("example2");
x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
x2 = expl2.newVar("abc1");
ctr1 = expl2.newCtr("r1");
ctr1.setTerm(x1, x2, 5.4);
var1 - variable of type XPRBvarvar2 - variable of type XPRBvarval - value of the coefficient of the product of the variablespublic void setTerm(double val,
XPRBvar var1,
XPRBvar var2)
setTerm(var1, var2, val)public void setTerm(double val)
XPRBprob expl2;
XPRBctr ctr1;
expl2 = new XPRBprob("example2");
ctr1 = expl2.newCtr("r1");
ctr1.setTerm(7);
val - constant term (RHS value)public double getCoefficient(XPRBvar var)
XPRBprob expl2;
XPRBctr ctr1;
XPRBvar x1;
double val;
expl2 = new XPRBprob("example2");
x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
ctr1 = expl2.newCtr("r1");
ctr1.setTerm(x1, 5.4);
val = ctr1.getCoefficient(x1);
var - variable of type XPRBvarpublic double getCoefficient(XPRBvar var1, XPRBvar var2)
XPRBprob expl2;
XPRBctr ctr1;
XPRBvar x1, x2;
double val;
expl2 = new XPRBprob("example2");
x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
x2 = expl2.newVar("abc1");
ctr1 = expl2.newCtr("r1");
ctr1.addTerm(x1, x2, 5.4);
val = ctr1.getCoefficient(x1, x2);
var1 - variable of type XPRBvarvar2 - variable of type XPRBvarpublic void addTerm(XPRBvar var, double val)
var with
coefficient val. If the constraint already has a
term with variable var, val is added
to its coefficient.
XPRBprob expl2;
XPRBctr ctr1;
XPRBvar x1;
expl2 = new XPRBprob("example2");
x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
ctr1 = expl2.newCtr("r1");
ctr1.addTerm(x1, 5.4);
var - variable of type XPRBvarval - value to be added to the coefficient of the variable varpublic void addTerm(double val,
XPRBvar var)
addTerm(var, val)public void addTerm(XPRBvar var)
addTerm(var, 1)public void addTerm(XPRBvar var1, XPRBvar var2, double val)
var1 and
var2 with coefficient val.
If the constraint already has a term with variables var1
and var2, then val is added
to its coefficient.
XPRBprob expl2;
XPRBctr ctr1;
XPRBvar x1, x2;
expl2 = new XPRBprob("example2");
x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
x2 = expl2.newVar("abc1");
ctr1 = expl2.newCtr("r1");
ctr1.addTerm(x1, x2, 5.4);
var1 - variable of type XPRBvarvar2 - variable of type XPRBvarval - value to be added to the coefficient of the product of the variablespublic void addTerm(double val,
XPRBvar var1,
XPRBvar var2)
addTerm(var1, var2, val)public void addTerm(double val)
XPRBprob expl2;
XPRBctr ctr1;
expl2 = new XPRBprob("example2");
ctr1 = expl2.newCtr("r1");
ctr1.addTerm(7);
val - value to be added to the RHS of the constraintpublic void delTerm(XPRBvar var)
XPRBprob expl2;
XPRBctr ctr1;
XPRBvar x1;
expl2 = new XPRBprob("example2");
x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
ctr1 = expl2.newCtr("r1");
ctr1.addTerm(x1, 5.4);
ctr1.delTerm(x1);
var - variable of type XPRBvarpublic void delTerm(XPRBvar var1, XPRBvar var2)
XPRBprob expl2;
XPRBctr ctr1;
XPRBvar x1, x2;
expl2 = new XPRBprob("example2");
x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
x2 = expl2.newVar("abc1");
ctr1 = expl2.newCtr("r1");
ctr1.addTerm(x1, x2, 5.4);
ctr1.delTerm(x1, x2);
var1 - variable of type XPRBvarvar2 - variable of type XPRBvarpublic void add(XPRBexpr l)
XPRBprob expl2;
XPRBctr ctr1;
XPRBvar x1;
expl2 = new XPRBprob("example2");
x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
ctr1 = expl2.newCtr("r1");
ctr1.add(x1.add(17));
l - linear expression of type XPRBexprpublic void add(XPRBvar var)
addTerm(var, 1)public void add(double val)
addTerm(val)public void print()
XPRBprob expl2;
XPRBctr ctr2;
XPRBvar x4[5];
XPRBctr 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();
public java.lang.String toString()
toString in class java.lang.ObjectgetName()public java.lang.Iterable<XPRBterm> getTerms()
XPRBprob expl2;
XPRBctr ctr1;
XPRBvar x1;
double val;
expl2 = new XPRBprob("example2");
x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
ctr1 = expl2.newCtr("r1");
ctr1.addTerm(x1, 5.4);
for (XPRBterm t : ctr1.getTerms()) {
System.out.println(t);
}
Iterable<XPRBterm>public java.lang.Iterable<XPRBqterm> getQTerms()
XPRBprob expl2;
XPRBctr ctr1;
XPRBvar x1, x2;
double val;
expl2 = new XPRBprob("example2");
x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
x2 = expl2.newVar("abc1");
ctr1 = expl2.newCtr("r1");
ctr1.addTerm(x1, x2, 5.4);
for (XPRBqterm t : ctr1.getQTerms()) {
System.out.println(t);
}
Iterable<XPRBqterm>