XPRBvar
- java.lang.Object
-
- com.dashoptimization.XPRBvar
-
public class XPRBvar extends java.lang.Object
This class represents a variable definition in BCL.
-
-
Method Summary
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()
-
-
-
Method Detail
-
isValid
public boolean isValid()
Test whether a variable is correctly defined.XPRBvar x1; if(x1.isValid() == false) System.out.println("Error in variable definition.");
-
setType
public void setType(int type)
Set the variable type. This method changes the type of a variable that has been created previously.XPRBprob expl2; XPRBvar x1; expl2 = new XPRBprob("example2"); x1 = expl2.newVar("abc3", XPRB.UI, 1, 100); x1.setType(x1, XPRB.BV);
- Parameters:
-
type
- variable type. Possible values:XPRB.PL
continuousXPRB.BV
binaryXPRB.UI
general integerXPRB.PI
partial integerXPRB.SC
semi-continuousXPRB.SI
semi-continuous integer
-
setUB
public void setUB(double val)
Set an upper bound on a variable.XPRBprob expl2; XPRBvar x1; expl2 = new XPRBprob("example2"); x1 = expl2.newVar("abc3", XPRB.UI, 1, 100); x1.setUB(200.0);
- Parameters:
-
val
- the variable's new upper bound
-
setLB
public void setLB(double val)
Set a lower bound on a variable.XPRBprob expl2; XPRBvar x1; expl2 = new XPRBprob("example2"); x1 = expl2.newVar("abc3", XPRB.UI, 1, 100); x1.setLB(3.0);
- Parameters:
-
val
- the variable's new lower bound
-
setLim
public 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.XPRBprob expl2; XPRBvar x3; expl2 = new XPRBprob("example2"); x3 = expl2.newVar("abc4", XPRB.SC, 0, 50); x3.setLim(5);
- Parameters:
-
val
- value of the integer limit
-
fix
public void fix(double val)
Fix a variable to a given value. This method replaces calls tosetUB(double)
andsetLB(double)
. The valueval
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);
- Parameters:
-
val
- value the variable is fixed to
-
setDir
public void setDir(int type, double val)
Set a branching directive for a variable. This method sets any type of branching directive available in Xpress. This may be a priority for branching on a variable (typeXPRB.PR
), the preferred branching direction (typesXPRB.UP, XPRB.DN
) or the estimated cost incurred when branching on a variable (typesXPRB.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). MethodXPRBsos.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);
- Parameters:
-
type
- directive type. Possible values:XPRB.PR
priorityXPRB.UP
first branch upwardsXPRB.DN
first branch downwardsXPRB.PU
pseudocost on branching upwardsXPRB.PD
pseudocost on branching downwards
-
val
- 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 branch
-
setDir
public void setDir(int type)
- See Also:
-
setDir(type, 0)
-
getName
public java.lang.String getName()
Get the name of a variable. If the user has not defined a name the default name generated by BCL is returned.XPRBprob expl2; XPRBvar x1; expl2 = new XPRBprob("example2"); x1 = expl2.newVar("abc3", XPRB.UI, 1, 100); System.out.println(x1.getName());
- Returns:
-
Name of the variable if method executed successfully,
null
otherwise
-
getColNum
public int getColNum()
Get the column number for a variable. This method returns the column number of a variable in the matrix currently loaded in Xpress. If the variable is not part of the matrix, or if the matrix has not yet been generated, the method returns a negative value. The counting of column numbers starts with 0.XPRBprob expl2; XPRBvar x1; int vindex; expl2 = new XPRBprob("example2"); x1 = expl2.newVar("abc3", XPRB.UI, 1, 100); vindex = x1.getColNum();
- Returns:
- Column number (integer value)
-
getType
public int getType()
Get the type of a variable.XPRBprob expl2; XPRBvar x1; int vtype; expl2 = new XPRBprob("example2"); x1 = expl2.newVar("abc3", XPRB.UI, 1, 100); vtype = x1.getType();
- Returns:
-
Variable type. Possible values:
XPRB.PL
continuousXPRB.BV
binaryXPRB.UI
general integerXPRB.PI
partial integerXPRB.SC
semi-continuousXPRB.SI
semi-continuous integer-1
an error has occurred
-
getLB
public double getLB()
Get the lower bound of a variable.XPRBprob expl2; XPRBvar x1; double lbound; expl2 = new XPRBprob("example2"); x1 = expl2.newVar("abc3", XPRB.UI, 1, 100); lbound = x1.getLB()
- Returns:
- Lower bound value
-
getUB
public double getUB()
Get the upper bound of a variable.XPRBprob expl2; XPRBvar x1; double ubound; expl2 = new XPRBprob("example2"); x1 = expl2.newVar("abc3", XPRB.UI, 1, 100); ubound = x1.getUB()
- Returns:
- Upper bound value
-
getLim
public double getLim()
Get the integer limit for a partial integer or the semi-continuous limit for a semi-continuous or semi-continuous integer variable.XPRBprob expl2; XPRBvar x3; double vlim; expl2 = new XPRBprob("example2"); x3 = expl2.newVar("abc4", XPRB.SC, 0, 50); vlim = x3.getLim();
- Returns:
- Limit value
-
getSol
public double getSol()
Get the solution value for a variable. The user may wish to test first whether this variable is part of the problem, for instance by checking that the column number is non-negative.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();
- Returns:
- Solution value for a variable (default 0)
-
getRCost
public double getRCost()
Get the reduced cost value for a variable. The user may wish to test first whether this variable is part of the problem, for instance by checking that the column number is non-negative. Reduced cost information is available only after LP solving. Reduced information for MIP problems can be obtained by fixing all discrete variables to their solution values and re-solving the resulting LP problem.XPRBprob expl2; XPRBvar x1; double rcval; expl2 = new XPRBprob("example2"); x1 = expl2.newVar("abc3", XPRB.UI, 1, 100); expl2.lpOptimize(); rcval = x1.getRCost();
- Returns:
- Reduced cost value for a variable (default 0)
-
getRNG
public double getRNG(int rngtype)
Get ranging information for a variable. This method can only be used after solving an LP problem. Ranging information for MIP problems can be obtained by fixing all discrete variables to their solution values and re-solving the resulting LP problem. For non-basic variables, the unit costs are always the (absolute) values of the reduced costs.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);
- Parameters:
-
rngtype
- Ranging information type. Possible values:XPRB.UPACT
upper activity (= the activity level [solution value] that would result from a cost coefficient increase from the input cost to the upper cost XPRB_UCOST--assuming a minimization problem--ignoring the upper bound on this variable)XPRB.LOACT
lower activity (= the activity level [solution value] that would result from a cost coefficient decrease from the input cost to the lower cost XPRB_LCOST--assuming a minimization problem--ignoring the upper bound on this variable)XPRB.UUP
upper unit cost (= the change in the objective function per unit of change in the activity up to the upper activity XPRB_UPACT)XPRB.UDN
lower unit cost (= the change in the objective function per unit of change in the activity down to the lower activity XPRB_LOACT)XPRB.UCOST
upper costXPRB.LCOST
lower cost
- Returns:
- Ranging information of the required type
-
neg
public XPRBexpr neg()
Turn a variable into a linear expression by negating it. This methods turns a variablex
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();
- Returns:
- Newly created linear expression
-
add
public XPRBexpr add(XPRBexpr l)
Create a linear expression by adding a linear expression to a variable. Applied to a variablex
, this method creates a new linear expressionx+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);
- Parameters:
-
l
- linear expression of typeXPRBexpr
- Returns:
- Newly created linear expression
-
mul
public XPRBexpr mul(double val)
Create a linear expression by multiplying a variable with a constant. Applied to a variablex
, this method creates a new linear expressionc*x
.XPRBprob expl2; XPRBvar x1; XPRBexpr l1; expl2 = new XPRBprob("example2"); x1 = expl2.newVar("abc3", XPRB.UI, 1, 100); l1 = x1.mul(-4.2);
- Parameters:
-
val
- constant value - Returns:
- Newly created linear expression
-
mul
public XPRBexpr mul(XPRBexpr l)
Create an expression by multiplying a variable with an expression. Applied to a variablex
, this method creates a new expressionx*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);
- Parameters:
-
l
- linear expression of typeXPRBexpr
- Returns:
- Newly created quadratic expression
-
sqr
public XPRBexpr sqr()
Create an expression which is the square of a variable. Applied to a variablex
, this method creates a new expressionx*x
.XPRBprob expl2; XPRBvar x1; XPRBexpr q; expl2 = new XPRBprob("example2"); x1 = expl2.newVar("abc3", XPRB.UI, 1, 100); q = x1.sqr();
- Returns:
- Newly created quadratic expression
-
lEql
public XPRBrelation lEql(XPRBexpr l)
Create a relation of type "less or equal". Applied to a variablex
, this method creates a new linear relationx<=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());
- Parameters:
-
l
- linear expression of typeXPRBexpr
- Returns:
- Newly created linear relation
-
lEql
public XPRBrelation lEql(XPRBvar v)
- See Also:
-
lEql(v)
-
lEql
public XPRBrelation lEql(double val)
- See Also:
-
lEql(val)
-
gEql
public XPRBrelation gEql(XPRBexpr l)
Create a linear relation of type "greater or equal". Applied to a variablex
, this method creates a new linear relationx>=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());
- Parameters:
-
l
- linear expression of typeXPRBexpr
- Returns:
- Newly created linear relation
-
gEql
public XPRBrelation gEql(XPRBvar v)
- See Also:
-
gEql(v)
-
gEql
public XPRBrelation gEql(double val)
- See Also:
-
gEql(val)
-
eql
public XPRBrelation eql(XPRBexpr l)
Create a linear relation of type "equal". Applied to a variablex
, this method creates a new linear relationx=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());
- Parameters:
-
l
- linear expression of typeXPRBexpr
- Returns:
- Newly created linear relation
-
eql
public XPRBrelation eql(XPRBvar v)
- See Also:
-
eql(v)
-
eql
public XPRBrelation eql(double val)
- See Also:
-
eql(val)
-
print
public void print()
Print out a variable. This method prints out name and bounds for continuous, binary and integer variables; name, bounds and integer limit or lower semi-continuous limit for partial integer, semi-continuous, and semi-continuous integer variables. If a solution value is available, this value is printed instead of the bounds.XPRBprob expl2; XPRBvar x1; expl2 = new XPRBprob("example2"); x1 = expl2.newVar("abc3", XPRB.UI, 1, 100); x1.print();
-
toString
public java.lang.String toString()
- Overrides:
-
toString
in classjava.lang.Object
- See Also:
-
getName()
-
-
© 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.