Interface LinearExpr
- All Superinterfaces:
LinearArgument
- All Known Implementing Classes:
AffineExpression,ConstantExpression,WeightedSumExpression
A linear expression (sum (ai * xi) + b). It specifies methods to help parsing the expression.
-
Method Summary
Modifier and TypeMethodDescriptionstatic LinearExpraffine(LinearArgument expr, long coeff, long offset) Shortcut for newBuilder().addTerm(expr, coeff).add(offset).build()static LinearExprconstant(long value) Shortcut for newBuilder().add(value).build()longgetCoefficient(int index) Returns the ith coefficient.longReturns the constant part of the expression.intgetVariableIndex(int index) Returns the index of the ith variable.static LinearExprBuilderReturns a builderintReturns the number of terms (excluding the constant one) in this expression.static LinearExprstatic LinearExprsum(LinearArgument[] exprs) Shortcut for newBuilder().addSum(exprs).build()static LinearExprterm(LinearArgument expr, long coeff) Shortcut for newBuilder().addTerm(expr, coeff).build()static LinearExprweightedSum(LinearArgument[] exprs, long[] coeffs) Shortcut for newBuilder().addWeightedSum(exprs, coeffs).build()Methods inherited from interface com.google.ortools.sat.LinearArgument
build
-
Method Details
-
numElements
int numElements()Returns the number of terms (excluding the constant one) in this expression. -
getVariableIndex
int getVariableIndex(int index) Returns the index of the ith variable. -
getCoefficient
long getCoefficient(int index) Returns the ith coefficient. -
getOffset
long getOffset()Returns the constant part of the expression. -
newBuilder
Returns a builder -
constant
Shortcut for newBuilder().add(value).build() -
term
Shortcut for newBuilder().addTerm(expr, coeff).build() -
affine
Shortcut for newBuilder().addTerm(expr, coeff).add(offset).build() -
sum
Shortcut for newBuilder().addSum(exprs).build() -
weightedSum
Shortcut for newBuilder().addWeightedSum(exprs, coeffs).build() -
rebuildFromLinearExpressionProto
-