Class WeightedSumExpression

java.lang.Object
com.google.ortools.sat.WeightedSumExpression
All Implemented Interfaces:
LinearArgument, LinearExpr

public final class WeightedSumExpression extends Object implements LinearExpr
A specialized linear expression: sum(ai * xi) + b.
  • Constructor Details

    • WeightedSumExpression

      public WeightedSumExpression(int[] variablesIndices, long[] coefficients, long offset)
  • Method Details

    • build

      public LinearExpr build()
      Description copied from interface: LinearArgument
      Builds a linear expression.
      Specified by:
      build in interface LinearArgument
    • numElements

      public int numElements()
      Description copied from interface: LinearExpr
      Returns the number of terms (excluding the constant one) in this expression.
      Specified by:
      numElements in interface LinearExpr
    • getVariableIndex

      public int getVariableIndex(int index)
      Description copied from interface: LinearExpr
      Returns the index of the ith variable.
      Specified by:
      getVariableIndex in interface LinearExpr
    • getCoefficient

      public long getCoefficient(int index)
      Description copied from interface: LinearExpr
      Returns the ith coefficient.
      Specified by:
      getCoefficient in interface LinearExpr
    • getOffset

      public long getOffset()
      Description copied from interface: LinearExpr
      Returns the constant part of the expression.
      Specified by:
      getOffset in interface LinearExpr