コード例 #1
0
ファイル: switchboard.py プロジェクト: NilsBarlaug/TDT4136
def main():

    puzzles = [
        ((4, 4), (1, 3), (3, 0)),
        ((6, 5), (0, 4), (5, 0)),
        ((8, 8), (1, 7), (7, 0))
    ]

    for puzzle in puzzles:
        problem = SwitchboardProblem(puzzle[0], 3, 2, puzzle[1], puzzle[2])
        solution = simulated_annealing.search(problem, schedule)

        image = SwitchboardImage(64, 3, puzzle[1], puzzle[2], solution.data)
        image.save('../SwitchboardSolutions/'
                   + str(puzzles.index(puzzle)) + '_.png')
        print('Done with ', puzzle)
コード例 #2
0
ファイル: egg_carton.py プロジェクト: NilsBarlaug/TDT4136
def main():

    puzzles = [
        (5, 5, 2),
        (6, 6, 2),
        (8, 8, 1),
        (10, 10, 3),
        (15, 15, 4)
    ]

    for puzzle in puzzles:
        problem = EggCartonProblem(puzzle[0], puzzle[1], puzzle[2])
        solution = simulated_annealing.search(problem, schedule)

        image = EggCartonImage(puzzle[0], puzzle[1], 64, 3, solution.data)

        image.save('../EggSolutions/' + str(puzzle[0]) + 'x' \
                   + str(puzzle[1]) + '_' + str(puzzle[2]) + '.png')
コード例 #3
0
            exit(1)

        filename = sys.argv[1]
        runtime = int(sys.argv[2])
        max_temperature = int(sys.argv[3])
        seed = int(sys.argv[4])

        print('')
        print('Running %s' % filename)
        print('runtime: %i' % runtime)
        print('max_temperature: %i' % max_temperature)
        print('seed: %i' % seed)
        print('')

        nr_nodes, edges = load(filename)
        best_solution, evaluation_list = search(nr_nodes, edges, runtime, max_temperature, seed)
        plot_evaluations(filename, nr_nodes, len(edges), evaluation_list, len(best_solution), runtime,
                         max_temperature, seed)
        exit(0)

    """
    Exectue all files from data directory with all available settings
    """
    data_files = filter(lambda x: '.gr' in x, os.listdir('data'))

    for filename in data_files:
        nr_runs = 10
        runtime = 60000
        max_temperature = 1

        overall_best = {'evaluation': math.inf}