Skip to content

Commit

Permalink
Decrease 15-puzzle macro set size & macro search budget
Browse files Browse the repository at this point in the history
  • Loading branch information
camall3n committed Jun 18, 2021
1 parent 5c9137d commit f1acb75
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion domains/npuzzle/macros.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions experiments/npuzzle/macro_cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:])
Expand All @@ -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__':
Expand Down
6 changes: 3 additions & 3 deletions experiments/npuzzle/macro_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Binary file added results/macros/npuzzle/clean_macros-set12.pickle
Binary file not shown.

0 comments on commit f1acb75

Please sign in to comment.