XPRBexpr
- java.lang.Object
-
- com.dashoptimization.XPRBexpr
-
- All Implemented Interfaces:
- java.lang.Cloneable
- Direct Known Subclasses:
- XPRBlinExp, XPRBquadExp, XPRBrelation
public class XPRBexpr extends java.lang.Object implements java.lang.CloneableThis class represents an expression in BCL. All variables in an expression must belong to the same problem.
-
-
Constructor Summary
Constructor and Description XPRBexpr()XPRBexpr(double d)XPRBexpr(double d, XPRBvar v)Create an expression.XPRBexpr(double d, XPRBvar v1, XPRBvar v2)Create a quadratic expression.XPRBexpr(XPRBvar v)XPRBexpr(XPRBvar v, double d)XPRBexpr(XPRBvar v1, XPRBvar v2)XPRBexpr(XPRBvar v1, XPRBvar v2, double d)
-
Method Summary
Modifier and Type Method and Description XPRBexpradd(double val)static XPRBexpradd(double val, XPRBexpr l)XPRBexpradd(XPRBexpr l)Add an expression to an expression.static XPRBexpradd(XPRBexpr l, double val)static XPRBexpradd(XPRBexpr l1, XPRBexpr l2)Create the sum of two expressions.static XPRBexpradd(XPRBexpr l, XPRBvar v)XPRBexpradd(XPRBvar v)static XPRBexpradd(XPRBvar v, XPRBexpr l)XPRBexpraddTerm(double val)XPRBexpraddTerm(double val, XPRBvar var)XPRBexpraddTerm(double val, XPRBvar var1, XPRBvar var2)XPRBexpraddTerm(XPRBvar var)XPRBexpraddTerm(XPRBvar var, double val)Add a linear term to an expression.XPRBexpraddTerm(XPRBvar var1, XPRBvar var2, double val)Add a quadratic term to an expression.XPRBexprassign(XPRBexpr l)Assign an expression.java.lang.Objectclone()Make a copy of an expression.XPRBexprdelTerm(XPRBvar var)Delete a term from an expression.XPRBexprdelTerm(XPRBvar var1, XPRBvar var2)Delete a quadratic term from an expression.XPRBrelationeql(double val)XPRBrelationeql(XPRBexpr l)Create a relation of type "equal".XPRBrelationeql(XPRBvar v)XPRBrelationgEql(double val)XPRBrelationgEql(XPRBexpr l)Create a relation of type "greater or equal".XPRBrelationgEql(XPRBvar v)doublegetSol()Get the evaluation of an expression with the current solution.intgetStatus()Get the status of an expressionXPRBrelationlEql(double val)XPRBrelationlEql(XPRBexpr l)Create a relation of type "less or equal".XPRBrelationlEql(XPRBvar v)XPRBexprmul(double d)Multiply an expression with a constant factor.static XPRBexprmul(double d, XPRBexpr l)XPRBexprmul(XPRBexpr q)Multiply an expression with an expression.static XPRBexprmul(XPRBexpr l, double d)Create the product of an expression with a constant factor.static XPRBexprmul(XPRBexpr q1, XPRBexpr q2)Create the product of two expressions.XPRBexprmul(XPRBvar v)Multiply an expression with a variable.XPRBexprneg()Negate an expression.static XPRBexprneg(XPRBexpr l)Create the negation of an expression.voidprint()Print out an expression.voidreset()Reset an expression.XPRBexprsetTerm(double val)XPRBexprsetTerm(double val, XPRBvar var)XPRBexprsetTerm(double val, XPRBvar var1, XPRBvar var2)XPRBexprsetTerm(XPRBvar var, double val)Set a term in an expression.XPRBexprsetTerm(XPRBvar var1, XPRBvar var2, double val)Set a quadratic term in an expression.XPRBexprsqr()Raise an expression to the power of 2static XPRBexprsqr(XPRBexpr l)Create the square of an expression.java.lang.StringtoString()Provide a string representation of an expression.
-
-
-
Constructor Detail
-
XPRBexpr
public XPRBexpr()
- See Also:
-
XPRBexpr(0, null)
-
XPRBexpr
public XPRBexpr(double d)
- See Also:
-
XPRBexpr(d, null)
-
XPRBexpr
public XPRBexpr(double d, XPRBvar v)Create an expression.XPRBprob expl2; XPRBvar x1; XPRBexpr l1; expl2 = new XPRBprob("example2"); x1 = expl2.newVar("abc3", XPRB.UI, 1, 100); l1 = new XPRBexpr(3.7, x1);- Parameters:
-
d- a double constant (= coefficient or constant term) -
v- a variable of typeXPRBvar
-
XPRBexpr
public XPRBexpr(XPRBvar v)
- See Also:
-
XPRBexpr(1, v)
-
XPRBexpr
public XPRBexpr(XPRBvar v, double d)
- See Also:
-
XPRBexpr(d, v)
-
XPRBexpr
public XPRBexpr(double d, XPRBvar v1, XPRBvar v2)Create a quadratic expression.XPRBprob expl2; XPRBvar x1; XPRBvar x2; XPRBexpr l1; expl2 = new XPRBprob("example2"); x1 = expl2.newVar("abc3", XPRB.UI, 1, 100); l1 = new XPRBexpr(3.7, x1,x2);- Parameters:
-
d- a double constant (= coefficient or constant term) -
v1- a variable of typeXPRBvar -
v2- a variable of typeXPRBvar
-
XPRBexpr
public XPRBexpr(XPRBvar v1, XPRBvar v2, double d)
- See Also:
-
XPRBexpr(d, v1,v2)
-
XPRBexpr
public XPRBexpr(XPRBvar v1, XPRBvar v2)
- See Also:
-
XPRBexpr(1, v1,v2)
-
-
Method Detail
-
clone
public java.lang.Object clone()
Make a copy of an expression.- Overrides:
-
clonein classjava.lang.Object - Returns:
- A new expression
-
reset
public void reset()
Reset an expression. This method deletes the content of an expression.
-
getSol
public double getSol()
Get the evaluation of an expression with the current solution. This method returns the evaluation of the expression with the current solution values for all its variables that are in the problem (that is, for which a solution value is available). All other variables are treated as 0.XPRBprob expl2; XPRBvar x1, x2; XPRBexpr l1; double sol; expl2 = new XPRBprob("example2"); x1 = expl2.newVar("abc3", XPRB.UI, 1, 100); x2 = expl2.newVar("abc1", XPRB.PL); l1 = new XPRBexpr(3.7, x1); l1.add(x2); expl2.lpOptimize(); sol = l1.getSol();- Returns:
- Evaluation of an expression (default 0)
-
neg
public XPRBexpr neg()
Negate an expression. This methods turns an expressionlinto the expression-1*l.XPRBprob expl2; XPRBvar x1; XPRBexpr l1; expl2 = new XPRBprob("example2"); x1 = expl2.newVar("abc3", XPRB.UI, 1, 100); l1 = new XPRBexpr(3.7, x1); l1.neg();- Returns:
- An expression
-
neg
public static XPRBexpr neg(XPRBexpr l)
Create the negation of an expression. This methods returns the negation-1*lof an expressionl.XPRBprob expl2; XPRBvar x1; XPRBexpr l1, l2; expl2 = new XPRBprob("example2"); x1 = expl2.newVar("abc3", XPRB.UI, 1, 100); l1 = new XPRBexpr(3.7, x1); l2 = XPRBexpr.neg(l1);- Returns:
- A new expression
-
add
public XPRBexpr add(XPRBexpr l)
Add an expression to an expression.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 = new XPRBexpr(3.7, x1); l2 = new XPRBexpr(x2); l2.add(l1);- Parameters:
-
l- expression of typeXPRBexpr - Returns:
- An expression
-
add
public static XPRBexpr add(XPRBexpr l1, XPRBexpr l2)
Create the sum of two expressions.XPRBprob expl2; XPRBvar x1, x2; XPRBexpr l1, l2, l3; expl2 = new XPRBprob("example2"); x1 = expl2.newVar("abc3", XPRB.UI, 1, 100); x2 = expl2.newVar("abc1", XPRB.PL, 0, XPRB.INFINITY); l1 = new XPRBexpr(3.7, x1); l2 = new XPRBexpr(x2); l3 = XPRBexpr.add(l1,l2);- Parameters:
-
l1- expression of typeXPRBexpr -
l2- expression of typeXPRBexpr - Returns:
- A new expression
-
add
public static XPRBexpr add(XPRBexpr l, double val)
- See Also:
-
add(l,val)
-
add
public static XPRBexpr add(double val, XPRBexpr l)
- See Also:
-
add(val,l)
-
setTerm
public XPRBexpr setTerm(XPRBvar var, double val)
Set a term in an expression. This method sets the coefficient of a given variable to the valueval.XPRBprob expl2; XPRBvar x1; XPRBexpr l1; expl2 = new XPRBprob("example2"); x1 = expl2.newVar("abc3", XPRB.UI, 1, 100); l1 = new XPRBexpr(3.7, x1); l1.setTerm(x1, 5.4); // Set coefficient of x1 to 5.4- Parameters:
-
var- variable of typeXPRBvar -
val- value of the coefficient of the variablevar - Returns:
- An expression
-
setTerm
public XPRBexpr setTerm(double val, XPRBvar var)
- See Also:
-
setTerm(var,val)
-
setTerm
public XPRBexpr setTerm(double val)
- See Also:
-
setTerm(0,val)
-
setTerm
public XPRBexpr setTerm(XPRBvar var1, XPRBvar var2, double val)
Set a quadratic term in an expression. This method sets the coefficient of the product of the given variables to the valueval.XPRBprob expl2; XPRBvar x1, x2; XPRBexpr q1; expl2 = new XPRBprob("example2"); x1 = expl2.newVar("abc3", XPRB.UI, 1, 100); x2 = expl2.newVar("abc1"); q1 = new XPRBexpr(-7.2, x1, x2); q1.setTerm(x1, x2, 5.4); // Set coefficient of x1*x2 to 5.4- Parameters:
-
var1- variable of typeXPRBvar -
var2- variable of typeXPRBvar -
val- value of the coefficient of the product of the variables - Returns:
- A quadratic expression
-
setTerm
public XPRBexpr setTerm(double val, XPRBvar var1, XPRBvar var2)
- See Also:
-
setTerm(var1,var2,val)
-
addTerm
public XPRBexpr addTerm(XPRBvar var, double val)
Add a linear term to an expression. This method adds a new term to an expression, comprising the variablevarwith coefficientval. If the expression already has a term with variablevar,valis added to its coefficient.XPRBprob expl2; XPRBvar x1; XPRBexpr l1; expl2 = new XPRBprob("example2"); x1 = expl2.newVar("abc3", XPRB.UI, 1, 100); l1 = new XPRBexpr(3.7, x1); l1.addTerm(x1, 5.4); // New coefficient of x1: 8.1- Parameters:
-
var- variable of typeXPRBvar -
val- value of the coefficient of the variablevar - Returns:
- An expression
-
addTerm
public XPRBexpr addTerm(double val, XPRBvar var)
- See Also:
-
addTerm(var,val)
-
addTerm
public XPRBexpr addTerm(XPRBvar var)
- See Also:
-
addTerm(var,1)
-
addTerm
public XPRBexpr addTerm(double val)
- See Also:
-
addTerm(0,val)
-
addTerm
public XPRBexpr addTerm(XPRBvar var1, XPRBvar var2, double val)
Add a quadratic term to an expression. This method adds a new term to an expression, comprising the product of the variablesvar1andvar2with coefficientval. If the expression already has a term with variablesvar1andvar2, thenvalis added to its coefficient.XPRBprob expl2; XPRBvar x1, x2; XPRBexpr q1; expl2 = new XPRBprob("example2"); x1 = expl2.newVar("abc3", XPRB.UI, 1, 100); x2 = expl2.newVar("abc1"); q1 = new XPRBexpr(-7.2, x1, x2); q1.addTerm(x1, x2, 5.4); // New coefficient of x1*x2: -1.8- Parameters:
-
var1- variable of typeXPRBvar -
var2- variable of typeXPRBvar -
val- value of the coefficient of the product of the variables - Returns:
- A quadratic expression
-
addTerm
public XPRBexpr addTerm(double val, XPRBvar var1, XPRBvar var2)
- See Also:
-
addTerm(var1,var2,val)
-
delTerm
public XPRBexpr delTerm(XPRBvar var)
Delete a term from an expression. This method removes the term involving the given variablevarfrom the expression.XPRBprob expl2; XPRBvar x1; XPRBexpr l1; expl2 = new XPRBprob("example2"); x1 = expl2.newVar("abc3", XPRB.UI, 1, 100); l1 = new XPRBexpr(3.7, x1); l1.delTerm(x1);- Parameters:
-
var- variable of typeXPRBvar - Returns:
- An expression
-
delTerm
public XPRBexpr delTerm(XPRBvar var1, XPRBvar var2)
Delete a quadratic term from an expression. This method removes the term involving the product of the two given variables from the expression.XPRBprob expl2; XPRBvar x1, x2; XPRBexpr q1; expl2 = new XPRBprob("example2"); x1 = expl2.newVar("abc3", XPRB.UI, 1, 100); x2 = expl2.newVar("abc1"); q1 = new XPRBexpr(-7.2, x1, x2); q1.delTerm(x1, x2);- Parameters:
-
var1- variable of typeXPRBvar -
var2- variable of typeXPRBvar - Returns:
- A quadratic expression
-
mul
public XPRBexpr mul(double d)
Multiply an expression with a constant factor.XPRBprob expl2; XPRBvar x1; XPRBexpr l1; expl2 = new XPRBprob("example2"); x1 = expl2.newVar("abc3", XPRB.UI, 1, 100); l1 = new XPRBexpr(3.7, x1); l1.mul(-2);- Parameters:
-
d- constant value - Returns:
- An expression
-
mul
public static XPRBexpr mul(XPRBexpr l, double d)
Create the product of an expression with a constant factor.XPRBprob expl2; XPRBvar x1; XPRBexpr l1, l2; expl2 = new XPRBprob("example2"); x1 = expl2.newVar("abc3", XPRB.UI, 1, 100); l1 = new XPRBexpr(3.7, x1); l2 = XPRBexpr.mul(l1, -2);- Parameters:
-
l- expression of typeXPRBexpr -
d- constant value - Returns:
- A new expression
-
mul
public XPRBexpr mul(XPRBvar v) throws java.lang.ArithmeticException
Multiply an expression with a variable.XPRBprob expl2; XPRBvar x1, x2; XPRBexpr l1; XPRBexpr q; expl2 = new XPRBprob("example2"); x1 = expl2.newVar("abc3", XPRB.UI, 1, 100); x2 = expl2.newVar("abc1", XPRB.PL, 0, XPRB.INFINITY); l1 = new XPRBexpr(3.7, x1); q = l1.mul(x2);- Parameters:
-
v- variable of typeXPRBvar - Returns:
- A new expression
- Throws:
-
java.lang.ArithmeticException- If the result of the multiplication has a power higher than quadratic.
-
sqr
public XPRBexpr sqr() throws java.lang.ArithmeticException
Raise an expression to the power of 2XPRBprob expl2; XPRBvar x1; XPRBexpr l1; XPRBexpr q; expl2 = new XPRBprob("example2"); x1 = expl2.newVar("abc3", XPRB.UI, 1, 100); l1 = new XPRBexpr(3.7, x1); l1.sqr();- Returns:
- An expression
- Throws:
-
java.lang.ArithmeticException
-
sqr
public static XPRBexpr sqr(XPRBexpr l) throws java.lang.ArithmeticException
Create the square of an expression.XPRBprob expl2; XPRBvar x1; XPRBexpr l1; XPRBexpr q; expl2 = new XPRBprob("example2"); x1 = expl2.newVar("abc3", XPRB.UI, 1, 100); l1 = new XPRBexpr(3.7, x1); q = XPRBexpr.sqr(l1);- Returns:
- A new expression
- Throws:
-
java.lang.ArithmeticException
-
mul
public XPRBexpr mul(XPRBexpr q) throws java.lang.ArithmeticException
Multiply an expression with an expression.XPRBprob expl2; XPRBvar x1, x2; XPRBexpr q1, q2; expl2 = new XPRBprob("example2"); x1 = expl2.newVar("abc3", XPRB.UI, 1, 100); x2 = expl2.newVar("abc1"); q1 = new XPRBexpr(-7.2, x1, x2); q2 = new XPRBexpr(x1.mul(3.7)); q1.mul(q2);- Parameters:
-
q- expression of typeXPRBexpr - Returns:
- An expression
- Throws:
-
java.lang.ArithmeticException- If the result of the multiplication has a power higher than quadratic.
-
mul
public static XPRBexpr mul(XPRBexpr q1, XPRBexpr q2) throws java.lang.ArithmeticException
Create the product of two expressions.XPRBprob expl2; XPRBvar x1, x2; XPRBexpr q1, q2, q3; expl2 = new XPRBprob("example2"); x1 = expl2.newVar("abc3", XPRB.UI, 1, 100); x2 = expl2.newVar("abc1"); q1 = new XPRBexpr(-7.2, x1, x2); q2 = new XPRBexpr(x1.mul(3.7)); q3 = XPRBexpr.mul(q1, q2);- Parameters:
-
q1- expression of typeXPRBexpr -
q2- expression of typeXPRBexpr - Returns:
- An expression
- Throws:
-
java.lang.ArithmeticException- If the result of the multiplication has a power higher than quadratic.
-
assign
public XPRBexpr assign(XPRBexpr l)
Assign an expression.XPRBprob expl2; XPRBvar x1; XPRBexpr l1, l2; expl2 = new XPRBprob("example2"); x1 = expl2.newVar("abc3", XPRB.UI, 1, 100); l1 = new XPRBexpr(3.7, x1); l2 = new XPRBexpr(); l2.assign(l1);- Parameters:
-
l- expression of typeXPRBexpr - Returns:
- An expression
-
getStatus
public int getStatus()
Get the status of an expression- Returns:
- 0 if constant, 1 if linear, 2 or 3 if quadratic
-
lEql
public XPRBrelation lEql(XPRBexpr l)
Create a relation of type "less or equal". Applied to an expressionl1, this method creates a new relationl1<=l.XPRBprob expl2; XPRBvar x1, x2; XPRBexpr l1, l2; XPRBrelation lr; expl2 = new XPRBprob("example2"); x1 = expl2.newVar("abc3", XPRB.UI, 1, 100); x2 = expl2.newVar("abc1", XPRB.PL, 0, XPRB.INFINITY); l1 = new XPRBexpr(3.7, x1); l2 = new XPRBexpr(8, x2); lr = l1.lEql(l2);- Parameters:
-
l- expression of typeXPRBexpr - Returns:
- A new 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 relation of type "greater or equal". Applied to an expressionl1, this method creates a new relationl1>=l.XPRBprob expl2; XPRBvar x1, x2; XPRBexpr l1, l2; XPRBrelation lr; expl2 = new XPRBprob("example2"); x1 = expl2.newVar("abc3", XPRB.UI, 1, 100); x2 = expl2.newVar("abc1", XPRB.PL, 0, XPRB.INFINITY); l1 = new XPRBexpr(3.7, x1); l2 = new XPRBexpr(8, x2); lr = l1.gEql(l2);- Parameters:
-
l- expression of typeXPRBexpr - Returns:
- A new 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 relation of type "equal". Applied to an expressionl1, this method creates a new relationl1=l.XPRBprob expl2; XPRBvar x1, x2; XPRBexpr l1, l2; XPRBrelation lr; expl2 = new XPRBprob("example2"); x1 = expl2.newVar("abc3", XPRB.UI, 1, 100); x2 = expl2.newVar("abc1", XPRB.PL, 0, XPRB.INFINITY); l1 = new XPRBexpr(3.7, x1); l2 = new XPRBexpr(8, x2); lr = l1.eql(l2);- Parameters:
-
l- expression of typeXPRBexpr - Returns:
- A new 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 an expression. This method is not available in the Student Edition.XPRBprob expl2; XPRBvar x1; XPRBexpr l1; expl2 = new XPRBprob("example2"); x1 = expl2.newVar("abc3", XPRB.UI, 1, 100); l1 = new XPRBexpr(3.7, x1); l1.print();
-
toString
public java.lang.String toString()
Provide a string representation of an expression.XPRBprob expl2; XPRBvar x1; XPRBexpr l1; expl2 = new XPRBprob("example2"); x1 = expl2.newVar("abc3", XPRB.UI, 1, 100); l1 = new XPRBexpr(3.7, x1); System.out.println(l1.toString());- Overrides:
-
toStringin classjava.lang.Object
-
-
© 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.
