How to use the libensemble.libE_worker.worker_main function in libensemble

To help you get started, we’ve selected a few libensemble examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Libensemble / libensemble / libensemble / libE.py View on Github external
def libE_mpi_worker(mpi_comm, sim_specs, gen_specs, libE_specs):
    "Worker routine run at ranks > 0."

    from libensemble.comms.mpi import MainMPIComm
    comm = MainMPIComm(mpi_comm)
    worker_main(comm, sim_specs, gen_specs, log_comm=True)
    logger.debug("Worker {} exiting".format(libE_specs['comm'].Get_rank()))
github Libensemble / libensemble / libensemble / libE.py View on Github external
def libE_tcp_worker(sim_specs, gen_specs, libE_specs):
    "Main routine for TCP worker launched by libE."

    ip = libE_specs['ip']
    port = libE_specs['port']
    authkey = libE_specs['authkey']
    workerID = libE_specs['workerID']

    with ClientQCommManager(ip, port, authkey, workerID) as comm:
        worker_main(comm, sim_specs, gen_specs,
                    workerID=workerID, log_comm=True)
        logger.debug("Worker {} exiting".format(workerID))
github Libensemble / libensemble / libensemble / libE_process.py View on Github external
"""
    libE_specs = check_inputs(libE_specs, alloc_specs, sim_specs, gen_specs,
                              exit_criteria, H0)

    CalcInfo.make_statdir()

    exit_flag = []
    hist = History(alloc_specs, sim_specs, gen_specs, exit_criteria, H0)

    # Launch workers here
    dtypes = {EVAL_SIM_TAG: hist.H[sim_specs['in']].dtype,
              EVAL_GEN_TAG: hist.H[gen_specs['in']].dtype}

    try:
        wcomms = [QCommProcess(worker_main, dtypes, sim_specs, gen_specs, w)
                  for w in range(1, libE_specs['nworkers']+1)]
        for wcomm in wcomms:
            wcomm.run()
        persis_info, exit_flag = \
          manager_main(hist, libE_specs, alloc_specs, sim_specs, gen_specs,
                       exit_criteria, persis_info, wcomms)

    except Exception:
        eprint(traceback.format_exc())
        eprint("\nManager exception raised .. aborting ensemble:\n")
        eprint("\nDumping ensemble history with {} sims evaluated:\n".
               format(hist.sim_count))
        filename = 'libE_history_at_abort_' + str(hist.sim_count) + '.npy'
        np.save(filename, hist.trim_H())
        sys.stdout.flush()
        sys.stderr.flush()
github Libensemble / libensemble / libensemble / libE.py View on Github external
def start_proc_team(nworkers, sim_specs, gen_specs, libE_specs, log_comm=True):
    "Launch a process worker team."
    wcomms = [QCommProcess(worker_main, sim_specs, gen_specs, libE_specs, w, log_comm)
              for w in range(1, nworkers+1)]
    for wcomm in wcomms:
        wcomm.run()
    return wcomms
github Libensemble / libensemble / libensemble / libE_thread.py View on Github external
"""
    libE_specs = check_inputs(libE_specs, alloc_specs, sim_specs, gen_specs,
                              exit_criteria, H0)

    CalcInfo.make_statdir()

    exit_flag = []
    hist = History(alloc_specs, sim_specs, gen_specs, exit_criteria, H0)

    # Launch workers here
    dtypes = {EVAL_SIM_TAG: hist.H[sim_specs['in']].dtype,
              EVAL_GEN_TAG: hist.H[gen_specs['in']].dtype}

    try:
        wcomms = [QCommThread(worker_main, dtypes=dtypes,
                              sim_specs=sim_specs,
                              gen_specs=gen_specs,
                              workerID=w+1)
                  for w in range(libE_specs['nworkers'])]
        for wcomm in wcomms:
            wcomm.run()
        persis_info, exit_flag = \
          manager_main(hist, libE_specs, alloc_specs, sim_specs, gen_specs,
                       exit_criteria, persis_info, wcomms)

    except Exception as e:
        eprint(traceback.format_exc())
        eprint("\nManager exception raised .. aborting ensemble:\n")
        eprint("\nDumping ensemble history with {} sims evaluated:\n".
               format(hist.sim_count))
        filename = 'libE_history_at_abort_' + str(hist.sim_count) + '.npy'
github Libensemble / libensemble / libensemble / libE.py View on Github external
def libE_mpi_worker(sim_specs, gen_specs, libE_specs):
    "Worker routine run at ranks > 0."

    from libensemble.comms.mpi import MainMPIComm
    comm = MainMPIComm(libE_specs['comm'])
    worker_main(comm, sim_specs, gen_specs, libE_specs, log_comm=True)
    logger.debug("Worker {} exiting".format(libE_specs['comm'].Get_rank()))
github Libensemble / libensemble / libensemble / libE.py View on Github external
def libE_tcp_worker(sim_specs, gen_specs, libE_specs):
    "Main routine for TCP worker launched by libE."

    ip = libE_specs['ip']
    port = libE_specs['port']
    authkey = libE_specs['authkey']
    workerID = libE_specs['workerID']

    with ClientQCommManager(ip, port, authkey, workerID) as comm:
        worker_main(comm, sim_specs, gen_specs, libE_specs,
                    workerID=workerID, log_comm=True)
        logger.debug("Worker {} exiting".format(workerID))