Beispiel #1
0
 def run(self):
     num_solutions = 0
     self.clock.tick("Consumer " + str(self.index))
     while True:
         next_task = self.task_queue.get()
         try:
             if next_task == "Poison" or (num_solutions
                                          == Options.NUM_INSTANCES):
                 self.task_queue.task_done()
                 break
         except:
             pass
         self.solver.push()
         self.solver.add(self.consumerConstraints[int(next_task)])
         self.clock.tick("Task " + str(next_task))
         while self.solver.check(
         ) == Common.SAT and num_solutions != Options.NUM_INSTANCES:
             model = self.solver.model()
             self.result_queue.put(model_to_string(self.cfr, model))
             num_solutions = num_solutions + 1
             preventSameModel(self.cfr, self.solver, model)
         self.task_queue.task_done()
         self.clock.tock("Task " + str(next_task))
         self.solver.pop()
     self.clock.tock("Consumer " + str(self.index))
     self.timeQueue.put(self.clock)
     return 0
Beispiel #2
0
 def run(self):
     num_solutions = 0
     self.clock.tick("Consumer " + str(self.index))
     while True:
         next_task = self.task_queue.get()
         try:
             if next_task == "Poison" or (num_solutions == Options.NUM_INSTANCES):
                 self.task_queue.task_done()
                 break
         except:
             pass    
         self.solver.push()
         self.solver.add(self.consumerConstraints[int(next_task)])
         self.clock.tick("Task " + str(next_task))
         while self.solver.check() == Common.SAT and num_solutions != Options.NUM_INSTANCES:
             model = self.solver.model()
             self.result_queue.put(model_to_string(self.cfr, model))
             num_solutions = num_solutions +  1
             preventSameModel(self.cfr, self.solver, model)
         self.task_queue.task_done()                    
         self.clock.tock("Task " + str(next_task))
         self.solver.pop()
     self.clock.tock("Consumer " + str(self.index))
     self.timeQueue.put(self.clock)
     return 0
Beispiel #3
0
 def standard_get_models(self, desired_number_of_models):
     result = []
     count = 0
     self.clock.tick("first model")
     while True:
         self.clock.tick("unsat")
         if (Options.MODE != Common.DEBUG and not(Options.PRODUCE_UNSAT_CORE)and count != desired_number_of_models and self.solver.check() == Common.SAT ) or \
             (Options.MODE != Common.DEBUG and Options.PRODUCE_UNSAT_CORE and count != desired_number_of_models and self.solver.check(self.unsat_core_trackers) == Common.SAT ) or \
             (Options.MODE == Common.DEBUG and count != desired_number_of_models and  self.solver.check(self.unsat_core_trackers) == Common.SAT ):
             if count == 0:
                 self.clock.tock("first model")
             m = self.solver.model()
             result.append(m)
             # Create a new constraint that blocks the current model
             if not Options.SUPPRESS_MODELS:
                 self.printVars(m)
             preventSameModel(self, self.solver, m)  
             count += 1
         else:
             if count == 0 and Options.PRODUCE_UNSAT_CORE:
                 self.clock.tock("unsat")
                 debug_print("UNSAT")
                 core = self.solver.unsat_core()
                 debug_print(str(len(core)) + " constraints in unsat core: \n")
                 for i in core:
                     print(Constraints.interpretUnsatCore(self, str(i)))
                     print()
                 return result
             elif count == 0:
                 standard_print("UNSAT")
             return result
Beispiel #4
0
    def genEquivalentSolutions(self, point, count):
        self.s.push()
        equivalentSolutions = []
        equalConstraint = self.ConstraintEqualToX(point)
        self.s.add(equalConstraint)
        preventSameModel(self.cfr, self.s, point)
        while self.s.check() == Common.SAT and not (len(equivalentSolutions) + count == self.options.num_models):
            solution = self.s.model()
            preventSameModel(self.cfr, self.s, solution)
            equivalentSolutions.append(solution)

        self.s.pop()
        return equivalentSolutions
Beispiel #5
0
    def genEquivalentSolutions(self, point, count):
        self.s.push()
        equivalentSolutions = []
        equalConstraint = self.ConstraintEqualToX(point)
        self.s.add(equalConstraint)
        preventSameModel(self.cfr, self.s, point)
        while (self.s.check() == Common.SAT
               and not (len(equivalentSolutions) + count
                        == self.options.num_models)):
            solution = self.s.model()
            preventSameModel(self.cfr, self.s, solution)
            equivalentSolutions.append(solution)

        self.s.pop()
        return equivalentSolutions