Class Sum

All Implemented Interfaces:
SatisfiedPresent

public class Sum extends Constraint implements SatisfiedPresent
  • Field Details

    • idNumber

      static AtomicInteger idNumber
    • list

      public IntVar[] list
      It specifies the variables to be summed.
    • sum

      public IntVar sum
      It specifies variable sum to store the overall sum of the variables being summed up.
    • sumGrounded

      private TimeStamp<Integer> sumGrounded
      The sum of grounded variables.
    • nextGroundedPosition

      private TimeStamp<Integer> nextGroundedPosition
      The position for the next grounded variable.
    • guideValue

      int guideValue
  • Constructor Details

    • Sum

      public Sum(IntVar[] list, IntVar sum)
      It constructs sum constraint which sums all variables and makes it equal to variable sum.
      Parameters:
      list - list of variables to be added
      sum - the resulting sum
    • Sum

      public Sum(List<? extends IntVar> list, IntVar sum)
      It creates a sum constraints which sums all variables and makes it equal to variable sum.
      Parameters:
      list - variables being summed up.
      sum - the sum variable.
  • Method Details

    • consistency

      public void consistency(Store store)
      Description copied from class: Constraint
      It is a (most probably incomplete) consistency function which removes the values from variables domains. Only values which do not have any support in a solution space are removed.
      Specified by:
      consistency in class Constraint
      Parameters:
      store - constraint store within which the constraint consistency is being checked.
    • getDefaultConsistencyPruningEvent

      public int getDefaultConsistencyPruningEvent()
      Specified by:
      getDefaultConsistencyPruningEvent in class Constraint
    • impose

      public void impose(Store store)
      Description copied from class: Constraint
      It imposes the constraint in a given store.
      Overrides:
      impose in class Constraint
      Parameters:
      store - the constraint store to which the constraint is imposed to.
    • satisfied

      public boolean satisfied()
      Description copied from interface: SatisfiedPresent
      It checks if the constraint is satisfied. It can return false even if constraint is satisfied but not all variables in its scope are grounded. It needs to return true if all variables in its scope are grounded and constraint is satisfied.

      Implementations of this interface for constraints that are not PrimitiveConstraint may require constraint imposition and consistency check as a requirement to work correctly.

      Specified by:
      satisfied in interface SatisfiedPresent
      Returns:
      true if constraint is possible to verify that it is satisfied.
    • toString

      public String toString()
      Description copied from class: Constraint
      It produces a string representation of a constraint state.
      Overrides:
      toString in class Constraint
    • getGuideConstraint

      public Constraint getGuideConstraint()
      Description copied from class: Constraint
      It specifies a constraint which if imposed by search will enhance propagation of this constraint.
      Overrides:
      getGuideConstraint in class Constraint
      Returns:
      Constraint enhancing propagation of this constraint.
    • getGuideValue

      public int getGuideValue()
      Description copied from class: Constraint
      This function provides a value which if assigned to a variable returned by getGuideVariable() will enhance propagation of this constraint.
      Overrides:
      getGuideValue in class Constraint
      Returns:
      Value which is a base of enhancing constraint.
    • getGuideVariable

      public Var getGuideVariable()
      Description copied from class: Constraint
      This function provides a variable which assigned a value returned by will enhance propagation of this constraint.
      Overrides:
      getGuideVariable in class Constraint
      Returns:
      Variable which is a base of enhancing constraint.
    • supplyGuideFeedback

      public void supplyGuideFeedback(boolean feedback)
      Description copied from class: Constraint
      This function allows to provide a guide feedback. If constraint does not propose sufficiently good enhancing constraints it will be informed so it has a chance to reexamine its efforts.
      Overrides:
      supplyGuideFeedback in class Constraint
      Parameters:
      feedback - true if the guide was useful, false otherwise.