From cb1fc93b94ecda90518b154a8b66b38b7fbce59e Mon Sep 17 00:00:00 2001 From: Laurent Perron Date: Tue, 15 May 2018 14:04:53 +0200 Subject: [PATCH] fix wedding_optimal_chart_sat.py --- examples/python/wedding_optimal_chart.py | 12 ++++++------ examples/python/wedding_optimal_chart_sat.py | 5 ++++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/examples/python/wedding_optimal_chart.py b/examples/python/wedding_optimal_chart.py index 0930d1a2db..e8360e03cd 100644 --- a/examples/python/wedding_optimal_chart.py +++ b/examples/python/wedding_optimal_chart.py @@ -51,14 +51,14 @@ def main(): # # Easy problem (from the paper) - n = 2 # number of tables - a = 10 # maximum number of guests a table can seat - b = 1 # minimum number of people each guest knows at their table + # n = 2 # number of tables + # a = 10 # maximum number of guests a table can seat + # b = 1 # minimum number of people each guest knows at their table # Slightly harder problem (also from the paper) - # n = 5 # number of tables - # a = 4 # maximum number of guests a table can seat - # b = 1 # minimum number of people each guest knows at their table + n = 5 # number of tables + a = 4 # maximum number of guests a table can seat + b = 1 # minimum number of people each guest knows at their table # Connection matrix: who knows who, and how strong # is the relation diff --git a/examples/python/wedding_optimal_chart_sat.py b/examples/python/wedding_optimal_chart_sat.py index 807b8f5843..0ae54c9195 100644 --- a/examples/python/wedding_optimal_chart_sat.py +++ b/examples/python/wedding_optimal_chart_sat.py @@ -180,10 +180,13 @@ def main(): for g1 in range(num_guests - 1): for g2 in range(g1 + 1, num_guests): for t in all_tables: - # Maintain same_table. + # Link same_table and seats. model.AddBoolOr([seats[(t, g1)].Not(), seats[(t, g2)].Not(), same_table[(g1, g2, t)]]) + model.AddImplication(same_table[(g1, g2, t)], seats[(t, g1)]) + model.AddImplication(same_table[(g1, g2, t)], seats[(t, g2)]) + # Link colocated and same_table. model.Add(sum(same_table[(g1, g2, t)] for t in all_tables) == colocated[(g1, g2)])