Skip to content

Instantly share code, notes, and snippets.

@mlabonne
Created April 30, 2022 14:37
Show Gist options
  • Save mlabonne/253fd724f1c8f30fe5cddbee5ad56cb9 to your computer and use it in GitHub Desktop.
Save mlabonne/253fd724f1c8f30fe5cddbee5ad56cb9 to your computer and use it in GitHub Desktop.
# Solve problem
status = solver.Solve(model)
# If an optimal solution has been found, print results
if status == cp_model.OPTIMAL:
print('================= Solution =================')
print(f'Solved in {solver.WallTime():.2f} milliseconds')
print()
print(f'Optimal value = {3*solver.Value(bread)+10*solver.Value(meat)+26*solver.Value(beer)} popularity')
print('Food:')
print(f' - 🥖Bread = {solver.Value(bread)}')
print(f' - 🥩Meat = {solver.Value(meat)}')
print(f' - 🍺Beer = {solver.Value(beer)}')
else:
print('The solver could not find an optimal solution.')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment