Module constraint :: Class SomeNotInSetConstraint
[show private | hide private]
[frames | no frames]

Type SomeNotInSetConstraint

object --+    
Constraint --+

Constraint enforcing that at least some of the values of given variables must not be present in a given set

>>> problem = Problem()
>>> problem.addVariables(["a", "b"], [1, 2])
>>> problem.addConstraint(SomeNotInSetConstraint([1]))
>>> sorted(sorted(x.items()) for x in problem.getSolutions())
[[('a', 1), ('b', 2)], [('a', 2), ('b', 1)], [('a', 2), ('b', 2)]]

Method Summary
  __init__(self, set, n, exact)
bool __call__(self, variables, domains, assignments, forwardcheck)
Perform the constraint checking
    Inherited from Constraint
bool forwardCheck(self, variables, domains, assignments, _unassigned)
Helper method for generic forward checking
  preProcess(self, variables, domains, constraints, vconstraints)
Preprocess variable domains
    Inherited from object
x.__delattr__('name') <==> del
x.__getattribute__('name') <==>
x.__hash__() <==> hash(x)
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T
helper for pickle
helper for pickle
x.__repr__() <==> repr(x)
x.__setattr__('name', value) <==> = value
x.__str__() <==> str(x)

Method Details

__init__(self, set, n=1, exact=False)

set - Set of values to be checked
n - Minimum number of assigned values that should not be present in set (default is 1)
exact - Whether the number of assigned values which are not present in set must be exactly n

__call__(self, variables, domains, assignments, forwardcheck=False)
(Call operator)

Perform the constraint checking

If the forwardcheck parameter is not false, besides telling if the constraint is currently broken or not, the constraint implementation may choose to hide values from the domains of unassigned variables to prevent them from being used, and thus prune the search space.
variables - Variables affected by that constraint, in the same order provided by the user
domains - Dictionary mapping variables to their domains
assignments - Dictionary mapping assigned variables to their current assumed value
forwardcheck - Boolean value stating whether forward checking should be performed or not
Boolean value stating if this constraint is currently broken or not
constraint.Constraint.__call__ (inherited documentation)

Generated by Epydoc 2.1 on Thu Jul 7 02:05:09 2005