Skip to content

Instantly share code, notes, and snippets.

@mlabonne
Created April 30, 2022 14:39
Show Gist options
  • Save mlabonne/aea856c2297ee6484a2578924fc4f647 to your computer and use it in GitHub Desktop.
Save mlabonne/aea856c2297ee6484a2578924fc4f647 to your computer and use it in GitHub Desktop.
class CountSolutions(cp_model.CpSolverSolutionCallback):
"""Count the number of solutions."""
def __init__(self):
cp_model.CpSolverSolutionCallback.__init__(self)
self.__solution_count = 0
def on_solution_callback(self):
self.__solution_count += 1
def solution_count(self):
return self.__solution_count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment