Solve() now backtracks at the end/ RejectSolution on SearchMonitor is now split into AcceptSolution() and AtSolution/ There is a new virtual OnStart() on neighborhoods/Examples were tweaked to adapt to the new API

This commit is contained in:
lperron@google.com
2010-10-06 16:04:31 +00:00
parent e0c66e81da
commit 672aa0605c
14 changed files with 310 additions and 296 deletions

View File

@@ -103,9 +103,10 @@ def main(unused_argv):
tea, coffee, water, milk, fruit_juice,
red, green, yellow, blue, ivory]
if solver.Solve(solver.Phase(all_vars,
solver.INT_VAR_DEFAULT,
solver.INT_VALUE_DEFAULT)):
solver.NewSearch(solver.Phase(all_vars,
solver.INT_VAR_DEFAULT,
solver.INT_VALUE_DEFAULT))
if solver.NextSolution():
people = [englishman, spaniard, japanese, ukrainian, norwegian]
water_drinker = [p for p in people if p.Value() == water.Value()][0]
zebra_owner = [p for p in people if p.Value() == zebra.Value()][0]
@@ -113,6 +114,7 @@ def main(unused_argv):
print 'The %s owns the zebra.' % zebra_owner.name()
else:
print 'No solutions to the zebra problem, this is unusual!'
solver.EndSearch()
if __name__ == '__main__':