public class XPRBvar
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
XPRBexpr |
add(double val) |
XPRBexpr |
add(XPRBexpr l)
Create a linear expression by adding a linear expression to a variable.
|
XPRBexpr |
add(XPRBvar v) |
XPRBrelation |
eql(double val) |
XPRBrelation |
eql(XPRBexpr l)
Create a linear relation of type "equal".
|
XPRBrelation |
eql(XPRBvar v) |
void |
fix(double val)
Fix a variable to a given value.
|
XPRBrelation |
gEql(double val) |
XPRBrelation |
gEql(XPRBexpr l)
Create a linear relation of type "greater or equal".
|
XPRBrelation |
gEql(XPRBvar v) |
int |
getColNum()
Get the column number for a variable.
|
double |
getLB()
Get the lower bound of a variable.
|
double |
getLim()
Get the integer limit for a partial integer or the semi-continuous
limit for a semi-continuous or semi-continuous integer variable.
|
java.lang.String |
getName()
Get the name of a variable.
|
double |
getRCost()
Get the reduced cost value for a variable.
|
double |
getRNG(int rngtype)
Get ranging information for a variable.
|
double |
getSol()
Get the solution value for a variable.
|
int |
getType()
Get the type of a variable.
|
double |
getUB()
Get the upper bound of a variable.
|
boolean |
isValid()
Test whether a variable is correctly defined.
|
XPRBrelation |
lEql(double val) |
XPRBrelation |
lEql(XPRBexpr l)
Create a relation of type "less or equal".
|
XPRBrelation |
lEql(XPRBvar v) |
XPRBexpr |
mul(double val)
Create a linear expression by multiplying a variable with a constant.
|
XPRBexpr |
mul(XPRBexpr l)
Create an expression by multiplying a variable with an
expression.
|
XPRBexpr |
mul(XPRBvar v) |
XPRBexpr |
neg()
Turn a variable into a linear expression by negating it.
|
void |
print()
Print out a variable.
|
void |
setDir(int type) |
void |
setDir(int type,
double val)
Set a branching directive for a variable.
|
void |
setLB(double val)
Set a lower bound on a variable.
|
void |
setLim(double val)
Set the integer limit (= lower bound of the
continuous part) for a partial integer, or the lower semi-continuous
limit for a semi-continuous or semi-continuous integer variable.
|
void |
setType(int type)
Set the variable type.
|
void |
setUB(double val)
Set an upper bound on a variable.
|
XPRBexpr |
sqr()
Create an expression which is the square of a variable.
|
java.lang.String |
toString() |
public boolean isValid()
XPRBvar x1;
if(x1.isValid() == false)
System.out.println("Error in variable definition.");
public void setType(int type)
XPRBprob expl2;
XPRBvar x1;
expl2 = new XPRBprob("example2");
x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
x1.setType(x1, XPRB.BV);
type - variable type. Possible values:
XPRB.PL continuous XPRB.BV binaryXPRB.UI general integerXPRB.PI partial integer XPRB.SC semi-continuousXPRB.SI semi-continuous integerpublic void setUB(double val)
XPRBprob expl2;
XPRBvar x1;
expl2 = new XPRBprob("example2");
x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
x1.setUB(200.0);
val - the variable's new upper boundpublic void setLB(double val)
XPRBprob expl2;
XPRBvar x1;
expl2 = new XPRBprob("example2");
x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
x1.setLB(3.0);
val - the variable's new lower boundpublic void setLim(double val)
XPRBprob expl2;
XPRBvar x3;
expl2 = new XPRBprob("example2");
x3 = expl2.newVar("abc4", XPRB.SC, 0, 50);
x3.setLim(5);
val - value of the integer limitpublic void fix(double val)
setUB(double) and setLB(double). The
value val may lie outside the original bounds of the
variable.
XPRBprob expl2;
XPRBvar x1;
expl2 = new XPRBprob("example2");
x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
x1.fix(20.0);
val - value the variable is fixed topublic void setDir(int type,
double val)
XPRB.PR), the preferred branching direction
(types XPRB.UP, XPRB.DN) or the estimated cost
incurred when branching on a variable (types XPRB.PU,
XPRB.PU). Several directives of different types may be set for
a single variable.
Note that it is only possibly to set branching directives for
discrete variables (including semi-continuous and partial integer
variables). Method XPRBsos.setDir(int, double) may be used to set
a branching directive for a SOS.
XPRBprob expl2;
XPRBvar x1;
expl2 = new XPRBprob("example2");
x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
x1.setDir(XPRB.PR, 10);
x1.setDir(XPRB.UP);
type - directive type. Possible values:
XPRB.PR priorityXPRB.UP first branch upwardsXPRB.DN first branch downwardsXPRB.PU pseudocost on branching upwards XPRB.PD pseudocost on branching downwardsval - the value of this argument depends on the type of
directive to be defined. Possible values:
XPRB.PR: priority value, integer
between 1 (highest) and 1000 (least priority, default
value)XPRB.UP,XPRB.DN: no input required, choose any
dummy value (e.g. 0) XPRB.PU,XPRB.PD: value of pseudocost for the
corresponding branchpublic void setDir(int type)
setDir(type, 0)public java.lang.String getName()
XPRBprob expl2;
XPRBvar x1;
expl2 = new XPRBprob("example2");
x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
System.out.println(x1.getName());
null otherwisepublic int getColNum()
XPRBprob expl2;
XPRBvar x1;
int vindex;
expl2 = new XPRBprob("example2");
x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
vindex = x1.getColNum();
public int getType()
XPRBprob expl2;
XPRBvar x1;
int vtype;
expl2 = new XPRBprob("example2");
x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
vtype = x1.getType();
XPRB.PL continuous XPRB.BV binary XPRB.UI general integerXPRB.PI partial integer XPRB.SC semi-continuousXPRB.SI semi-continuous integer-1 an error has occurredpublic double getLB()
XPRBprob expl2;
XPRBvar x1;
double lbound;
expl2 = new XPRBprob("example2");
x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
lbound = x1.getLB()
public double getUB()
XPRBprob expl2;
XPRBvar x1;
double ubound;
expl2 = new XPRBprob("example2");
x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
ubound = x1.getUB()
public double getLim()
XPRBprob expl2;
XPRBvar x3;
double vlim;
expl2 = new XPRBprob("example2");
x3 = expl2.newVar("abc4", XPRB.SC, 0, 50);
vlim = x3.getLim();
public double getSol()
XPRBprob expl2;
XPRBvar x1;
double solval;
expl2 = new XPRBprob("example2");
x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
expl2.lpOptimize();
solval = (x1.getColNum()>=0?x1.getSol():x1.getLB();
public double getRCost()
XPRBprob expl2;
XPRBvar x1;
double rcval;
expl2 = new XPRBprob("example2");
x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
expl2.lpOptimize();
rcval = x1.getRCost();
public double getRNG(int rngtype)
XPRBprob expl2;
XPRBvar x1;
double ucval;
expl2 = new XPRBprob("example2");
x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
expl2.lpOptimize();
ucval = x1.getRNG(XPRB.UCOST);
rngtype - Ranging information type. Possible values:
XPRB.UPACT for a variable which is at one of its bounds, the largest value which that bound can take while the current basis remains optimalXPRB.LOACT for a variable which is at one of its bounds, the smallest value which that bound can take while the current basis remains optimalXPRB.UUP the change in objective value per unit increase in the variable activity, assuming the the current basis remains optimalXPRB.UDN the change in objective value per unit decrease in the variable activity, assuming the the current basis remains optimalXPRB.UCOST the largest value which this variable's objective coefficient can take while the current basis remains optimalXPRB.LCOST the smallest value which this variable's objective coefficient can take while the current basis remains optimalpublic XPRBexpr neg()
x into the linear
expression -x.
XPRBprob expl2;
XPRBvar x1;
XPRBexpr l;
expl2 = new XPRBprob("example2");
x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
l = x1.neg();
public XPRBexpr add(XPRBexpr l)
x, this method creates a new linear
expression x+l.
XPRBprob expl2;
XPRBvar x1, x2;
XPRBexpr l1, l2;
expl2 = new XPRBprob("example2");
x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
x2 = expl2.newVar("abc1", XPRB.PL, 0, XPRB.INFINITY);
l1 = x1.add(17);
l2 = x2.add(l1);
l - linear expression of type XPRBexprpublic XPRBexpr mul(double val)
x, this method creates a new linear
expression c*x.
XPRBprob expl2;
XPRBvar x1;
XPRBexpr l1;
expl2 = new XPRBprob("example2");
x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
l1 = x1.mul(-4.2);
val - constant valuepublic XPRBexpr mul(XPRBexpr l)
x, this method creates a new
expression x*l.
XPRBprob expl2;
XPRBvar x1, x2;
XPRBexpr l;
XPRBexpr q;
expl2 = new XPRBprob("example2");
x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
x2 = expl2.newVar("abc1", XPRB.PL, 0, XPRB.INFINITY);
l = x1.neg();
q = x2.mul(l);
l - linear expression of type XPRBexprpublic XPRBexpr sqr()
x, this method creates a new
expression x*x.
XPRBprob expl2;
XPRBvar x1;
XPRBexpr q;
expl2 = new XPRBprob("example2");
x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
q = x1.sqr();
public XPRBrelation lEql(XPRBexpr l)
x, this method creates a new
linear relation x<=l.
XPRBprob expl2;
XPRBvar x1, x2;
XPRBrelation lr;
expl2 = new XPRBprob("example2");
x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
x2 = expl2.newVar("abc1", XPRB.PL, 0, XPRB.INFINITY);
lr = x2.lEql(x1.neg());
l - linear expression of type XPRBexprpublic XPRBrelation lEql(XPRBvar v)
lEql(v)public XPRBrelation lEql(double val)
lEql(val)public XPRBrelation gEql(XPRBexpr l)
x, this method creates a new
linear relation x>=l.
XPRBprob expl2;
XPRBvar x1, x2;
XPRBrelation lr;
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.neg());
l - linear expression of type XPRBexprpublic XPRBrelation gEql(XPRBvar v)
gEql(v)public XPRBrelation gEql(double val)
gEql(val)public XPRBrelation eql(XPRBexpr l)
x, this method creates a new
linear relation x=l.
XPRBprob expl2;
XPRBvar x1, x2;
XPRBrelation lr;
expl2 = new XPRBprob("example2");
x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
x2 = expl2.newVar("abc1", XPRB.PL, 0, XPRB.INFINITY);
lr = x2.eql(x1.neg());
l - linear expression of type XPRBexprpublic XPRBrelation eql(XPRBvar v)
eql(v)public XPRBrelation eql(double val)
eql(val)public void print()
XPRBprob expl2;
XPRBvar x1;
expl2 = new XPRBprob("example2");
x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
x1.print();
public java.lang.String toString()
toString in class java.lang.ObjectgetName()