Пример #1
0
 def OnSolutionCallback(self):
     self.__solution_count += 1
     # Build solution object.
     sol = Solution(self.__solution_count, self.orm, self.ObjectiveValue())
     sol.callback = self
     for lesson in self.orm.getLessons():
         for tVar in lesson.timeVars:
             sol.addLesson(lesson, self.roomMap[self.Value(lesson.roomVar)],
                           self.timeslotMap[self.Value(tVar)])
     # Validate solution object.
     try:
         if not SolutionValidation.validateSolution(
                 sol):  # print the TimeTable if the solution is invalid
             printTimeTable(self, self.dayMap, self.SolutionCount(),
                            self.orm.getLessons())
             logger.debug("Invalidations found in solution %i\n\n" %
                          self.__solution_count)
             self.__invalidCount += 1
     except Exception as e:
         print(traceback.format_exc())
         raise e