Package com.google.ortools.modelbuilder
Interface LinearExpr
-
- All Superinterfaces:
LinearArgument
- All Known Implementing Classes:
AffineExpression,ConstantExpression,WeightedSumExpression
public interface LinearExpr extends LinearArgument
A linear expression (sum (ai * xi) + b). It specifies methods to help parsing the expression.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static LinearExpraffine(LinearArgument expr, double coeff, double offset)Shortcut for newBuilder().addTerm(expr, coeff).add(offset).build()static LinearExprconstant(double value)Shortcut for newBuilder().add(value).build()doublegetCoefficient(int index)Returns the ith coefficient.doublegetOffset()Returns the constant part of the expression.intgetVariableIndex(int index)Returns the index of the ith variable.static LinearExprBuildernewBuilder()Returns a builderintnumElements()Returns the number of terms (excluding the constant one) in this expression.static LinearExprsum(LinearArgument[] exprs)Shortcut for newBuilder().addSum(exprs).build()static LinearExprterm(LinearArgument expr, double coeff)Shortcut for newBuilder().addTerm(expr, coeff).build()static LinearExprweightedSum(LinearArgument[] exprs, double[] coeffs)Shortcut for newBuilder().addWeightedSum(exprs, coeffs).build()-
Methods inherited from interface com.google.ortools.modelbuilder.LinearArgument
build
-
-
-
-
Method Detail
-
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
double getCoefficient(int index)
Returns the ith coefficient.
-
getOffset
double getOffset()
Returns the constant part of the expression.
-
newBuilder
static LinearExprBuilder newBuilder()
Returns a builder
-
constant
static LinearExpr constant(double value)
Shortcut for newBuilder().add(value).build()
-
term
static LinearExpr term(LinearArgument expr, double coeff)
Shortcut for newBuilder().addTerm(expr, coeff).build()
-
affine
static LinearExpr affine(LinearArgument expr, double coeff, double offset)
Shortcut for newBuilder().addTerm(expr, coeff).add(offset).build()
-
sum
static LinearExpr sum(LinearArgument[] exprs)
Shortcut for newBuilder().addSum(exprs).build()
-
weightedSum
static LinearExpr weightedSum(LinearArgument[] exprs, double[] coeffs)
Shortcut for newBuilder().addWeightedSum(exprs, coeffs).build()
-
-