Skip to content

Instantly share code, notes, and snippets.

@mlabonne
Created April 30, 2022 14:26
Show Gist options
  • Save mlabonne/4795ec782681dbe98bb85b4778fac4f9 to your computer and use it in GitHub Desktop.
Save mlabonne/4795ec782681dbe98bb85b4778fac4f9 to your computer and use it in GitHub Desktop.
# Find the variable that satisfies these constraints
status = solver.Solve(model)
# If a solution has been found, print results
if status == cp_model.OPTIMAL or status == cp_model.FEASIBLE:
print('================= Solution =================')
print(f'Solved in {solver.WallTime():.2f} milliseconds')
print()
print(f'🪖 Army = {solver.Value(army)}')
print()
print('Check solution:')
print(f' - Constraint 1: {solver.Value(army)} % 13 = {solver.Value(army) % 13}')
print(f' - Constraint 2: {solver.Value(army)} % 19 = {solver.Value(army) % 19}')
print(f' - Constraint 3: {solver.Value(army)} % 37 = {solver.Value(army) % 37}')
else:
print('The solver could not find a solution.')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment