Esempio n. 1
0
 def save_grid(self,
               model=Model.MODEL_IKJ,
               solver=Solver.PYCOSAT_SOLVER,
               output=None):
     grid = self.solve(model, solver)
     if grid is None:
         return
     output = output or (self.file_path.split('.')[0] + '-' +
                         Model.get(model).name() + '-' +
                         Solver.get(solver).name() + '.GRID')
     f = open(output, 'w')
     for c in self.comments:
         f.write('{}\n'.format(c))
     f.write('sol {} \n'.format(self.n))
     for row in grid:
         f.write('{} 0\n'.format(' '.join(['#' if c else ' '
                                           for c in row])))
     f.close()
Esempio n. 2
0
 def solve(self, solver=Solver.PYCOSAT_SOLVER):
     self.solved[solver] = Solver.get(solver).solve(self.n, self.clauses)
     return self.solved[solver]