Skip to content

Commit

Permalink
Cleaning up finalize of runs in persistent aposmm
Browse files Browse the repository at this point in the history
  • Loading branch information
jmlarson1 committed Jan 16, 2020
1 parent 9c403ae commit e3c1c57
Showing 1 changed file with 14 additions and 20 deletions.
34 changes: 14 additions & 20 deletions libensemble/gen_funcs/persistent_aposmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,9 +413,8 @@ def run_local_nlopt(user_specs, comm_queue, x0, f0, child_can_read, parent_can_r
# FIXME: Do we need to do something of the final 'x_opt'?
# print('[Child]: Started my optimization', flush=True)
x_opt = opt.optimize(x0)
# print('[Child]: I have converged.', flush=True)
comm_queue.put(ConvergedMsg(x_opt))
parent_can_read.set()

finish_queue(x_opt, comm_queue, parent_can_read)


def run_local_scipy_opt(user_specs, comm_queue, x0, f0, child_can_read, parent_can_read):
Expand Down Expand Up @@ -448,9 +447,7 @@ def run_local_scipy_opt(user_specs, comm_queue, x0, f0, child_can_read, parent_c
# FIXME: Need to do something with the exit codes.
# print(exit_code)

# print('[Child]: I have converged.', flush=True)
comm_queue.put(ConvergedMsg(x_opt))
parent_can_read.set()
finish_queue(x_opt, comm_queue, parent_can_read)


def run_external_localopt(user_specs, comm_queue, x0, f0, child_can_read, parent_can_read):
Expand All @@ -468,7 +465,7 @@ def run_external_localopt(user_specs, comm_queue, x0, f0, child_can_read, parent
opt_file = 'opt_' + run_id + '.txt'

# cmd = ["matlab", "-nodisplay", "-nodesktop", "-nojvm", "-nosplash", "-r",
cmd = ["octave", "--no-gui", "--eval",
cmd = ["octave", "--no-window-system", "--eval",
"x0=" + str(x0) + ";"
"opt_file='" + opt_file + "';"
"x_file='" + x_file + "';"
Expand All @@ -494,10 +491,7 @@ def run_external_localopt(user_specs, comm_queue, x0, f0, child_can_read, parent
for f in [x_file, y_file, opt_file]:
os.remove(f)

print(x_opt)

comm_queue.put(ConvergedMsg(x_opt))
parent_can_read.set()
finish_queue(x_opt, comm_queue, parent_can_read)


def run_local_dfols(user_specs, comm_queue, x0, f0, child_can_read, parent_can_read):
Expand All @@ -521,9 +515,7 @@ def run_local_dfols(user_specs, comm_queue, x0, f0, child_can_read, parent_can_r
# FIXME: Need to do something with the exit codes.
# print(exit_code)

# print('[Child]: I have converged.', flush=True)
comm_queue.put(ConvergedMsg(x_opt))
parent_can_read.set()
finish_queue(x_opt, comm_queue, parent_can_read)


def run_local_tao(user_specs, comm_queue, x0, f0, child_can_read, parent_can_read):
Expand Down Expand Up @@ -600,12 +592,7 @@ def run_local_tao(user_specs, comm_queue, x0, f0, child_can_read, parent_can_rea
x.destroy()
tao.destroy()

# FIXME: Do we need to do something of the final 'x_opt'?
# print('[Child]: I have converged.', flush=True)
comm_queue.put(ConvergedMsg(x_opt))
parent_can_read.set()

# FIXME: What do we do about the exit_code?
finish_queue(x_opt, comm_queue, parent_can_read)


# Callback functions and routines
Expand Down Expand Up @@ -645,6 +632,13 @@ def tao_callback_fun_grad(tao, x, g, comm_queue, child_can_read, parent_can_read
return f_recv


def finish_queue(x_opt, comm_queue, parent_can_read):

print('x_opt', x_opt, flush=True)
comm_queue.put(ConvergedMsg(x_opt))
parent_can_read.set()


def put_set_wait_get(x, comm_queue, parent_can_read, child_can_read):
"""This routine is used by children process callback functions. It:
- puts x into a comm_queue,
Expand Down

0 comments on commit e3c1c57

Please sign in to comment.