Home | Trees | Index | Help |
---|
Module constraint :: Class BacktrackingSolver |
|
object
--+ |Solver
--+ | BacktrackingSolver
Problem solver with backtracking capabilities
Examples:
>>> result = [[('a', 1), ('b', 2)],
... [('a', 1), ('b', 3)],
... [('a', 2), ('b', 3)]]
>>> problem = Problem(BacktrackingSolver())
>>> problem.addVariables(["a", "b"], [1, 2, 3])
>>> problem.addConstraint(lambda a, b: b > a, ["a", "b"])
>>> solution = problem.getSolution() >>> sorted(solution.items()) in result True
>>> for solution in problem.getSolutionIter(): ... sorted(solution.items()) in result True True True
>>> for solution in problem.getSolutions(): ... sorted(solution.items()) in result True True True
Method Summary | |
---|---|
| |
Return one solution for the given problem | |
Return an iterator for the solutions of the given problem | |
Return all solutions for the given problem | |
Inherited from object | |
x.__delattr__('name') <==> del x.name | |
x.__getattribute__('name') <==> x.name | |
x.__hash__() <==> hash(x) | |
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) <==> x.name = value | |
x.__str__() <==> str(x) |
Method Details |
---|
__init__(self,
forwardcheck=True)
|
getSolution(self, domains, constraints, vconstraints)Return one solution for the given problem
|
getSolutionIter(self, domains, constraints, vconstraints)Return an iterator for the solutions of the given problem
|
getSolutions(self, domains, constraints, vconstraints)Return all solutions for the given problem
|
Home | Trees | Index | Help |
---|
Generated by Epydoc 2.1 on Thu Jul 7 02:05:09 2005 | http://epydoc.sf.net |