Exemplo n.º 1
0
 def SolveWithSolutionObserver(self, model, callback):
     """Solves a problem and pass each solution found to the callback."""
     parameters = sat_parameters_pb2.SatParameters()
     self.__solution = (
         pywrapsat.SatHelper.SolveWithParametersAndSolutionObserver(
             model.ModelProto(), parameters, callback))
     return self.__solution.status
Exemplo n.º 2
0
 def SolveWithSolutionObserver(self, model, callback):
     parameters = sat_parameters_pb2.SatParameters()
     parameters.enumerate_all_solutions = True
     parameters.cp_model_presolve = False
     self.__solution = (
         pywrapsat.SatHelper.SolveWithParametersAndSolutionObserver(
             model.ModelProto(), parameters, callback))
     return self.__solution.status
Exemplo n.º 3
0
 def SearchForAllSolutions(self, model, callback):
   """Search for all solutions of a satisfiability problem."""
   if model.HasObjective():
     raise TypeError('Search for all solutions is only defined on '
                     'satisfiability problems')
   parameters = sat_parameters_pb2.SatParameters()
   parameters.enumerate_all_solutions = True
   parameters.cp_model_presolve = False
   self.__solution = (
       pywrapsat.SatHelper.SolveWithParametersAndSolutionObserver(
           model.ModelProto(), parameters, callback))
   return self.__solution.status
Exemplo n.º 4
0
 def __init__(self):
   self.__model = None
   self.__solution = None
   self.parameters = sat_parameters_pb2.SatParameters()