Package org.jacop.constraints
Class Sum
java.lang.Object
org.jacop.constraints.DecomposedConstraint<Constraint>
org.jacop.constraints.Constraint
org.jacop.constraints.Sum
- All Implemented Interfaces:
SatisfiedPresent
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) int
(package private) static AtomicInteger
IntVar[]
It specifies the variables to be summed.The position for the next grounded variable.It specifies variable sum to store the overall sum of the variables being summed up.The sum of grounded variables.Fields inherited from class org.jacop.constraints.Constraint
afcWeight, atomicExecution, consistencyPruningEvents, constraintScope, earlyTerminationOK, increaseWeight, numberId, scope, trace, watchedVariableGrounded
Fields inherited from class org.jacop.constraints.DecomposedConstraint
queueIndex
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
consistency
(Store store) It is a (most probably incomplete) consistency function which removes the values from variables domains.int
It specifies a constraint which if imposed by search will enhance propagation of this constraint.int
This function provides a value which if assigned to a variable returned by getGuideVariable() will enhance propagation of this constraint.This function provides a variable which assigned a value returned by will enhance propagation of this constraint.void
It imposes the constraint in a given store.boolean
It checks if the constraint is satisfied.void
supplyGuideFeedback
(boolean feedback) This function allows to provide a guide feedback.toString()
It produces a string representation of a constraint state.Methods inherited from class org.jacop.constraints.Constraint
afc, arguments, cleanAfterFailure, decompose, getConsistencyPruningEvent, grounded, grounded, id, impose, imposeDecomposition, increaseWeight, intArrayToString, long2int, numberArgs, queueVariable, removeConstraint, requiresMonotonicity, setConsistencyPruningEvent, setConstraintScope, setScope, setScope, setScope, setScope, setScope, setWatchedVariableGrounded, toInt, toInt, updateAFC, watchedVariableGrounded
Methods inherited from class org.jacop.constraints.DecomposedConstraint
auxiliaryVariables, checkInput, checkInput, checkInputForDuplication, checkInputForDuplicationSkipSingletons, checkInputForNullness, checkInputForNullness, checkInputForNullness, derivative, getDubletonsSkipSingletons, imposeDecomposition
-
Field Details
-
idNumber
-
list
It specifies the variables to be summed. -
sum
It specifies variable sum to store the overall sum of the variables being summed up. -
sumGrounded
The sum of grounded variables. -
nextGroundedPosition
The position for the next grounded variable. -
guideValue
int guideValue
-
-
Constructor Details
-
Sum
It constructs sum constraint which sums all variables and makes it equal to variable sum.- Parameters:
list
- list of variables to be addedsum
- the resulting sum
-
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
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 classConstraint
- Parameters:
store
- constraint store within which the constraint consistency is being checked.
-
getDefaultConsistencyPruningEvent
public int getDefaultConsistencyPruningEvent()- Specified by:
getDefaultConsistencyPruningEvent
in classConstraint
-
impose
Description copied from class:Constraint
It imposes the constraint in a given store.- Overrides:
impose
in classConstraint
- 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 interfaceSatisfiedPresent
- Returns:
- true if constraint is possible to verify that it is satisfied.
-
toString
Description copied from class:Constraint
It produces a string representation of a constraint state.- Overrides:
toString
in classConstraint
-
getGuideConstraint
Description copied from class:Constraint
It specifies a constraint which if imposed by search will enhance propagation of this constraint.- Overrides:
getGuideConstraint
in classConstraint
- 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 classConstraint
- Returns:
- Value which is a base of enhancing constraint.
-
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 classConstraint
- 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 classConstraint
- Parameters:
feedback
- true if the guide was useful, false otherwise.
-