fix wedding_optimal_chart_sat.py

This commit is contained in:
Laurent Perron
2018-05-15 14:04:53 +02:00
parent 798fa68a73
commit cb1fc93b94
2 changed files with 10 additions and 7 deletions

View File

@@ -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

View File

@@ -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)])