def tearDown(self):
     Yices.exit()
    return all_results


def best(set_of_puzzles):
    # Could run some evaluation function here. For now just pick
    # the one with the fewest "givens".
    least = min(set_of_puzzles.keys())
    print(f'least number of givens: {least}')
    return least, set_of_puzzles[least][0]


def main():
    results = None
    if len(sys.argv) == 3:
        n = int(sys.argv[1])
        iterations = int(sys.argv[2])
        results = run(n, iterations)
    else:
        results = run()

    least, puzzle = best(results)  # use the best one of those puzzles.
    puzzle.pprint()  # display that puzzle.
    puzzle.puzzle2path(f'puzzle_{least}_{str(date.today())}.sudoku')


if __name__ == '__main__':
    main()
    print(Census.dump())
    Yices.exit(True)
set_value(context, (8, 3), 9)
set_value(context, (8, 7), 8)
set_value(context, (8, 9), 5)

set_value(context, (9, 1), 6)
set_value(context, (9, 2), 7)
set_value(context, (9, 3), 1)
set_value(context, (9, 7), 2)

#check sat

smt_stat = context.check_context(None)

if smt_stat != Status.SAT:
    print('No solution: smt_stat = {0}\n'.format(smt_stat))
else:
    #print model
    model = Model.from_context(context, 1)
    for i in range(9):
        for j in range(9):
            val = model.get_value(V(i, j))
            print('V({0}, {1}) = {2}'.format(i, j, val))
    model.dispose()

print('Cleaning up\n')

context.dispose()
config.dispose()

Yices.exit()
Exemplo n.º 4
0
 def tearDown(self):
     self.cfg.dispose()
     self.ctx.dispose()
     self.param.dispose()
     Yices.exit()
Exemplo n.º 5
0
 def _cleanUp(self):
     self.context.dispose()
     Yices.exit()