diff --git a/domains/npuzzle/macros.py b/domains/npuzzle/macros.py index 57f04a3..5983ec4 100644 --- a/domains/npuzzle/macros.py +++ b/domains/npuzzle/macros.py @@ -13,7 +13,7 @@ class learned: def load_learned_macros(): """Load the set of learned macro-actions""" results_dir = 'results/macros/npuzzle/' - filename = results_dir+'clean_macros.pickle' + filename = results_dir+'clean_macros-set12.pickle' try: with open(filename, 'rb') as file: _macros = pickle.load(file) diff --git a/experiments/npuzzle/macro_cleanup.py b/experiments/npuzzle/macro_cleanup.py index 1859082..62eda36 100644 --- a/experiments/npuzzle/macro_cleanup.py +++ b/experiments/npuzzle/macro_cleanup.py @@ -6,7 +6,8 @@ def main(): """Combine N-Puzzle macros for different starting positions into a single file""" results_dir = 'results/macros/npuzzle/' - filenames = glob.glob(results_dir+'macro-*-results.pickle') + set_suffix = '-set12' + filenames = glob.glob(results_dir+'macro{}-n15-*-results.pickle'.format(set_suffix)) macros = OrderedDict() for filename in filenames: row = int(filename.split('/')[-1].split('-')[-3][1:]) @@ -28,7 +29,7 @@ def main(): #%% Save the results os.makedirs('results/macros/npuzzle/', exist_ok=True) - with open('results/macros/npuzzle/clean_macros.pickle', 'wb') as file: + with open('results/macros/npuzzle/clean_macros{}.pickle'.format(set_suffix), 'wb') as file: pickle.dump(macros, file) if __name__ == '__main__': diff --git a/experiments/npuzzle/macro_search.py b/experiments/npuzzle/macro_search.py index fa8fab6..750db06 100644 --- a/experiments/npuzzle/macro_search.py +++ b/experiments/npuzzle/macro_search.py @@ -22,15 +22,15 @@ def main(): help='Initial row for blank space') parser.add_argument('-c', type=int, default=0, help='Initial col for blank space') - parser.add_argument('--max_transitions', type=lambda x: int(float(x)), default=62500, + parser.add_argument('--max_transitions', type=lambda x: int(float(x)), default=2000, help='Maximum number of variables changed per primitive action') - parser.add_argument('--save_best_n', type=int, default=100, + parser.add_argument('--save_best_n', type=int, default=12, help='Number of best macros to save') args = parser.parse_args() #%% Make n-puzzle and set initial blank location puzzle = npuzzle.NPuzzle(n=15, start_blank=(args.r, args.c)) - tag = 'n{}-r{}-c{}'.format(args.n, *puzzle.blank_idx) + tag = 'set{}-n{}-r{}-c{}'.format(args.save_best_n, args.n, *puzzle.blank_idx) #%% Configure the search def heuristic(puz): diff --git a/results/macros/npuzzle/clean_macros-set12.pickle b/results/macros/npuzzle/clean_macros-set12.pickle new file mode 100644 index 0000000..d31f5a9 Binary files /dev/null and b/results/macros/npuzzle/clean_macros-set12.pickle differ