Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions libensemble/gen_funcs/persistent_aposmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

__all__ = ["aposmm", "initialize_APOSMM", "decide_where_to_start_localopt", "update_history_dist"]

import glob
import os
import pickle

from math import log, pi, sqrt

import numpy as np
Expand All @@ -35,6 +39,17 @@ def cdist(XA, XB, metric="euclidean"):
return distances


def write_persis_info(persis_info, iteration):
fname = "gen_data_after_gen_{}.pickle"
filename = fname.format(iteration)
for old_file in glob.glob(
fname.format("*")
):
os.remove(old_file)
with open(filename, "wb") as f:
pickle.dump(persis_info, f)


def aposmm(H, persis_info, gen_specs, libE_info):
"""
APOSMM coordinates multiple local optimization runs, dramatically reducing time for
Expand Down Expand Up @@ -188,6 +203,7 @@ def aposmm(H, persis_info, gen_specs, libE_info):

tag = None
first_pass = True
iteration = 0
while 1:
new_opt_inds_to_send_mgr = []
new_inds_to_send_mgr = []
Expand Down Expand Up @@ -283,9 +299,14 @@ def aposmm(H, persis_info, gen_specs, libE_info):
ps.send(local_H[new_inds_to_send_mgr + new_opt_inds_to_send_mgr][[i[0] for i in gen_specs["out"]]])
something_sent = True

iteration+=1
write_persis_info(persis_info, iteration)

return local_H, persis_info, FINISHED_PERSISTENT_GEN_TAG
finally:
try:
# Final write of persis_info
write_persis_info(persis_info, iteration)
clean_up_and_stop(local_opters)
except NameError:
pass
Expand Down