QuadTermMap
- java.lang.Object
-
- com.dashoptimization.objects.Expression
-
- com.dashoptimization.objects.AbstractExpression
-
- com.dashoptimization.objects.QuadExpression
-
- com.dashoptimization.objects.QuadTermMap
-
public final class QuadTermMap extends QuadExpression
A quadratic expression. This class implements a quadratic expression as a map from variables to values.- Since:
- 43.00
-
-
Constructor Summary
Constructor Description QuadTermMap()
Create a new empty expression.QuadTermMap(double constant)
Create an expression with a constant term.
-
Method Summary
Modifier and Type Method Description QuadTermMap
addConstant(double c)
Add a value to the constant term of this expression.QuadTermMap
addTerm(double coefficient, Variable variable)
Add a term to this expression.QuadTermMap
addTerm(double coefficient, Variable variable1, Variable variable2)
Add a term to this expression.QuadTermMap
addTerm(Variable x)
Add term1.0*x
to this expression.QuadTermMap
addTerm(Variable variable, double coefficient)
Add a term to this expression.QuadTermMap
addTerm(Variable x1, Variable x2)
Add term1.0*x1*x2
to this expression.QuadTermMap
addTerm(Variable variable1, Variable variable2, double coefficient)
Add a term to this expression.QuadTermMap
addTerms(LinExpression expr)
Add another linear expression to this expression.QuadTermMap
addTerms(LinExpression expr, double factor)
Add another linear expression to this expression.QuadTermMap
addTerms(QuadExpression expr)
Add another quadratic expression to this expression.QuadTermMap
addTerms(QuadExpression expr, double factor)
Add another quadratic expression to this expression.QuadTermMap
addTerms(Variable[] variables, double[] coefficients)
Add multiple terms to this expression.QuadTermMap
addTerms(Variable[] variables, double[] coefficients, int offset, int count)
Add multiple terms to this expression.QuadTermMap
addTerms(Variable[] variables1, Variable[] variables2, double[] coefficients)
Add multiple terms to this expression.QuadTermMap
addTerms(Variable[] variables1, Variable[] variables2, double[] coefficients, int offset, int count)
Add multiple terms to this expression.QuadTermMap
addTerms(java.lang.Iterable<Variable> variables1, java.lang.Iterable<Variable> variables2, java.lang.Iterable<java.lang.Double> coefficients)
Add multiple terms to this expression.QuadTermMap
addTerms(java.lang.Iterable<Variable> variables, java.lang.Iterable<java.lang.Double> coefficients)
Add multiple terms to this expression.QuadTermMap
addTerms(java.util.stream.Stream<Variable> variables1, java.util.stream.Stream<Variable> variables2, java.util.stream.Stream<java.lang.Double> coefficients)
Add multiple quadratic terms to this expression.QuadTermMap
addTerms(java.util.stream.Stream<Variable> variables, java.util.stream.Stream<java.lang.Double> coefficients)
Add multiple linear terms to this expression.QuadExpression
deepCopy()
Get a deep copy of this expression.QuadExpression
deepCopy(double factor)
Get a deep copy of this expression multiplied by a constantdouble
evaluate(double[] solution)
Compute the value of this expression with respect to the given solution vector (which is not required to be feasible).double
getCoefficient(Variable variable)
Get the coefficient for a variable.double
getCoefficient(Variable variable1, Variable variable2)
Get the coefficient for a variable product.double
getConstant()
Get the constant value in this expression.QuadTermMap
reset()
Clear this expression.QuadTermMap
setCoefficient(Variable variable, double coefficient)
Set the coefficient for a variable in this expression.QuadTermMap
setCoefficient(Variable variable1, Variable variable2, double coefficient)
Set the coefficient for a variable product in this expression.QuadTermMap
setConstant(double c)
Set the constant term in this expression.java.lang.String
toString()
-
Methods inherited from class com.dashoptimization.objects.QuadExpression
addTerm, addTerm, create, create
-
Methods inherited from class com.dashoptimization.objects.AbstractExpression
eq, eq, geq, geq, in, leq, leq
-
-
-
-
Method Detail
-
deepCopy
public QuadExpression deepCopy()
Get a deep copy of this expression.- Specified by:
-
deepCopy
in classQuadExpression
- Returns:
- A deep copy of this expression.
- Since:
- 43.00
-
deepCopy
public QuadExpression deepCopy(double factor)
Get a deep copy of this expression multiplied by a constant- Specified by:
-
deepCopy
in classQuadExpression
- Parameters:
-
factor
- Factor to scalethis
with. - Returns:
-
A deep copy of this expression multiplied by
factor
. - Since:
- 43.00
-
reset
public QuadTermMap reset()
Clear this expression. Removes all terms and sets the constant to 0.- Specified by:
-
reset
in classQuadExpression
- Returns:
-
Always returns
this
. - Since:
- 43.00
-
addTerms
public QuadTermMap addTerms(java.util.stream.Stream<Variable> variables, java.util.stream.Stream<java.lang.Double> coefficients)
Add multiple linear terms to this expression. Adds the scalar product defined by the element-wise multiplication ofvariables
andcoefficients
.- Overrides:
-
addTerms
in classQuadExpression
- Parameters:
-
variables
- Variables. -
coefficients
- Coefficients. - Returns:
-
Always returns
this
. - Since:
- 43.00
-
addTerms
public QuadTermMap addTerms(java.util.stream.Stream<Variable> variables1, java.util.stream.Stream<Variable> variables2, java.util.stream.Stream<java.lang.Double> coefficients)
Add multiple quadratic terms to this expression. Adds the scalar product defined by the element-wise multiplication ofvariables1
,variables2
andcoefficients
.- Overrides:
-
addTerms
in classQuadExpression
- Parameters:
-
variables1
- First variables. -
variables2
- Second variables. -
coefficients
- Coefficients. - Returns:
-
Always returns
this
. - Since:
- 43.00
-
addTerms
public QuadTermMap addTerms(java.lang.Iterable<Variable> variables, java.lang.Iterable<java.lang.Double> coefficients)
Add multiple terms to this expression. Adds the scalar product defined by the element-wise multiplication ofvariables
andcoefficients
.- Overrides:
-
addTerms
in classQuadExpression
- Parameters:
-
variables
- Variables -
coefficients
- Coefficients - Returns:
-
Always returns
this
. - Since:
- 43.00
-
addTerms
public QuadTermMap addTerms(java.lang.Iterable<Variable> variables1, java.lang.Iterable<Variable> variables2, java.lang.Iterable<java.lang.Double> coefficients)
Add multiple terms to this expression. Adds the scalar product defined by the element-wise multiplication ofvariables1
,variables2
andcoefficients
.- Overrides:
-
addTerms
in classQuadExpression
- Parameters:
-
variables1
- First variables -
variables2
- Second variables -
coefficients
- Coefficients - Returns:
-
Always returns
this
. - Since:
- 43.00
-
addTerms
public QuadTermMap addTerms(Variable[] variables, double[] coefficients)
Add multiple terms to this expression. Adds the scalar product defined by the element-wise multiplication ofvariables
andcoefficients
.- Overrides:
-
addTerms
in classQuadExpression
- Parameters:
-
variables
- Variables -
coefficients
- Coefficients - Returns:
-
Always returns
this
. - Since:
- 43.00
-
addTerms
public QuadTermMap addTerms(Variable[] variables1, Variable[] variables2, double[] coefficients)
Add multiple terms to this expression. Adds the scalar product defined by the element-wise multiplication ofvariables1
,variables2
andcoefficients
.- Overrides:
-
addTerms
in classQuadExpression
- Parameters:
-
variables1
- First variables -
variables2
- Second variables -
coefficients
- Coefficients - Returns:
-
Always returns
this
. - Since:
- 43.00
-
addTerms
public QuadTermMap addTerms(Variable[] variables, double[] coefficients, int offset, int count)
Add multiple terms to this expression. Adds the scalar product defined by the element-wise multiplication ofvariables
andcoefficients
usingcount
elements starting fromoffset
.- Overrides:
-
addTerms
in classQuadExpression
- Parameters:
-
variables
- Variables -
coefficients
- Coefficients -
offset
- Offset into arrays. -
count
- Number of elements to use from each array. - Returns:
-
Always returns
this
. - Since:
- 43.00
-
addTerms
public QuadTermMap addTerms(Variable[] variables1, Variable[] variables2, double[] coefficients, int offset, int count)
Add multiple terms to this expression. Adds the scalar product defined by the element-wise multiplication ofvariables1
,variables2
andcoefficients
usingcount
elements starting fromoffset
.- Overrides:
-
addTerms
in classQuadExpression
- Parameters:
-
variables1
- First variables -
variables2
- Second variables -
coefficients
- Coefficients -
offset
- Offset into arrays. -
count
- Number of elements to use from each array. - Returns:
-
Always returns
this
. - Since:
- 43.00
-
addTerm
public QuadTermMap addTerm(Variable variable, double coefficient)
Add a term to this expression. If the expression already has a coefficient forvariable
then the old and the new coefficients will be added.- Specified by:
-
addTerm
in classQuadExpression
- Parameters:
-
variable
- Variable. -
coefficient
- Coefficient to add forvariable
. - Returns:
-
Always returns
this
. - Since:
- 43.00
-
addTerm
public QuadTermMap addTerm(double coefficient, Variable variable)
Add a term to this expression. If the expression already has a coefficient forvariable
then the old and the new coefficients will be added.- Specified by:
-
addTerm
in classQuadExpression
- Parameters:
-
coefficient
- Coefficient to add forvariable
. -
variable
- Variable. - Returns:
-
Always returns
this
. - Since:
- 43.00
-
addTerm
public QuadTermMap addTerm(Variable x)
Add term1.0*x
to this expression. If the expression already has a coefficient forx
then the old and the new coefficients will be added.- Specified by:
-
addTerm
in classQuadExpression
- Parameters:
-
x
- Variable. - Returns:
-
Always returns
this
. - Since:
- 43.00
-
addTerm
public QuadTermMap addTerm(Variable variable1, Variable variable2, double coefficient)
Add a term to this expression. If the expression already has a coefficient forvariable1*variable2
then the old and the new coefficients will be added.- Specified by:
-
addTerm
in classQuadExpression
- Parameters:
-
variable1
- First variable. -
variable2
- Second variable. -
coefficient
- Coefficient to add forvariable1*variable2
. - Returns:
-
Always returns
this
. - Since:
- 43.00
-
addTerm
public QuadTermMap addTerm(double coefficient, Variable variable1, Variable variable2)
Add a term to this expression. If the expression already has a coefficient forvariable1*variable2
then the old and the new coefficients will be added.- Specified by:
-
addTerm
in classQuadExpression
- Parameters:
-
coefficient
- Coefficient to add forvariable1*variable2
. -
variable1
- First variable. -
variable2
- Second variable. - Returns:
-
Always returns
this
. - Since:
- 43.00
-
addTerm
public QuadTermMap addTerm(Variable x1, Variable x2)
Add term1.0*x1*x2
to this expression. If the expression already has a coefficient forx
then the old and the new coefficients will be added.- Specified by:
-
addTerm
in classQuadExpression
- Parameters:
-
x1
- First variable. -
x2
- Second variable. - Returns:
-
Always returns
this
. - Since:
- 43.00
-
addTerms
public QuadTermMap addTerms(LinExpression expr)
Add another linear expression to this expression.- Specified by:
-
addTerms
in classQuadExpression
- Parameters:
-
expr
- The expression to add - Returns:
-
Always returns
this
. - Since:
- 43.00
-
addTerms
public QuadTermMap addTerms(QuadExpression expr)
Add another quadratic expression to this expression.- Specified by:
-
addTerms
in classQuadExpression
- Parameters:
-
expr
- The expression to add - Returns:
-
Always returns
this
. - Since:
- 43.00
-
addTerms
public QuadTermMap addTerms(LinExpression expr, double factor)
Add another linear expression to this expression.- Specified by:
-
addTerms
in classQuadExpression
- Parameters:
-
expr
- The expression to add. -
factor
- Factor by which to multiply elements inexpr
before adding. - Returns:
-
Always returns
this
. - Since:
- 43.00
-
addTerms
public QuadTermMap addTerms(QuadExpression expr, double factor)
Add another quadratic expression to this expression.- Specified by:
-
addTerms
in classQuadExpression
- Parameters:
-
expr
- The expression to add. -
factor
- Factor by which to multiply elements inexpr
before adding. - Returns:
-
Always returns
this
. - Since:
- 43.00
-
setCoefficient
public QuadTermMap setCoefficient(Variable variable, double coefficient)
Set the coefficient for a variable in this expression. Any existing coefficient will be overwritten.- Parameters:
-
variable
- objects.Variable index. -
coefficient
- New coefficient forvariable
. - Returns:
-
Always returns
this
. - Since:
- 43.00
-
setCoefficient
public QuadTermMap setCoefficient(Variable variable1, Variable variable2, double coefficient)
Set the coefficient for a variable product in this expression. Any existing coefficient will be overwritten.- Parameters:
-
variable1
- First variable index. -
variable2
- Second variable index. -
coefficient
- New coefficient forvariable
. - Returns:
-
Always returns
this
. - Since:
- 43.00
-
getCoefficient
public double getCoefficient(Variable variable)
Get the coefficient for a variable.- Parameters:
-
variable
- objects.Variable to query. - Returns:
-
The coefficient for
variable
in this expression. - Since:
- 43.00
-
getCoefficient
public double getCoefficient(Variable variable1, Variable variable2)
Get the coefficient for a variable product.- Parameters:
-
variable1
- First variable to query. -
variable2
- Second variable to query. - Returns:
-
The coefficient for
variable
in this expression. - Since:
- 43.00
-
addConstant
public QuadTermMap addConstant(double c)
Add a value to the constant term of this expression.- Specified by:
-
addConstant
in classQuadExpression
- Parameters:
-
c
- The constant to add. - Returns:
-
Always returns
this
. - Since:
- 43.00
-
setConstant
public QuadTermMap setConstant(double c)
Set the constant term in this expression. Any existing constant term will be overwritten.- Specified by:
-
setConstant
in classQuadExpression
- Parameters:
-
c
- New constant term for this expression - Returns:
-
Always returns
this
. - Since:
- 43.00
-
getConstant
public double getConstant()
Get the constant value in this expression.- Specified by:
-
getConstant
in classQuadExpression
- Returns:
- The constant value in this expression.
- Since:
- 43.00
-
evaluate
public double evaluate(double[] solution)
Compute the value of this expression with respect to the given solution vector (which is not required to be feasible).- Specified by:
-
evaluate
in classExpression
- Parameters:
-
solution
- Solution values for which the expression is evaluated. - Returns:
-
The value of this expression evaluated at
solution
. - Since:
- 43.00
-
toString
public java.lang.String toString()
- Overrides:
-
toString
in classjava.lang.Object
- Returns:
- Since:
- 43.00
-
-
© 2001-2024 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.