How to use the libensemble.history.History 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_local(sim_specs, gen_specs, exit_criteria,
               persis_info, alloc_specs, libE_specs, H0):
    "Main routine for thread/process launch of libE."

    nworkers = libE_specs['nprocesses']
    check_inputs(libE_specs, alloc_specs, sim_specs, gen_specs, exit_criteria, H0)

    jobctl = JobController.controller
    if jobctl is not None:
        local_host = socket.gethostname()
        jobctl.add_comm_info(libE_nodes=local_host, serial_setup=True)

    hist = History(alloc_specs, sim_specs, gen_specs, exit_criteria, H0)

    # Launch worker team and set up logger
    wcomms = start_proc_team(nworkers, sim_specs, gen_specs)
    manager_logging_config()

    # Set up cleanup routine to shut down worker team
    def cleanup():
        "Handler to clean up comms team."
        kill_proc_team(wcomms, timeout=libE_specs.get('worker_timeout'))

    # Run generic manager
    return libE_manager(wcomms, sim_specs, gen_specs, exit_criteria,
                        persis_info, alloc_specs, libE_specs, hist,
                        on_cleanup=cleanup)
github Libensemble / libensemble / libensemble / libE.py View on Github external
def libE_mpi_manager(mpi_comm, sim_specs, gen_specs, exit_criteria, persis_info,
                     alloc_specs, libE_specs, H0):
    "Manager routine run at rank 0."

    from libensemble.comms.mpi import MainMPIComm

    hist = History(alloc_specs, sim_specs, gen_specs, exit_criteria, H0)

    # Lauch worker team
    wcomms = [MainMPIComm(mpi_comm, w) for w in
              range(1, mpi_comm.Get_size())]
    manager_logging_config()

    # Set up abort handler
    def on_abort():
        "Shut down MPI on error."
        comms_abort(mpi_comm)

    # Run generic manager
    return libE_manager(wcomms, sim_specs, gen_specs, exit_criteria,
                        persis_info, alloc_specs, libE_specs, hist,
                        on_abort=on_abort)
github Libensemble / libensemble / libensemble / libE.py View on Github external
def libE_tcp_mgr(sim_specs, gen_specs, exit_criteria,
                 persis_info, alloc_specs, libE_specs, H0):
    "Main routine for TCP multiprocessing launch of libE at manager."

    hist = History(alloc_specs, sim_specs, gen_specs, exit_criteria, H0)

    # Set up a worker launcher
    launchf = libE_tcp_worker_launcher(libE_specs)

    # Get worker launch parameters and fill in defaults for TCP/IP conn
    if 'nprocesses' in libE_specs:
        workers = None
        nworkers = libE_specs['nprocesses']
    elif 'workers' in libE_specs:
        workers = libE_specs['workers']
        nworkers = len(workers)
    ip = libE_specs.get('ip', None) or get_ip()
    port = libE_specs.get('port', 0)
    authkey = libE_specs.get('authkey', libE_tcp_authkey())

    with ServerQCommManager(port, authkey.encode('utf-8')) as manager:
github Libensemble / libensemble / libensemble / libE_thread.py View on Github external
:doc:`(example)`

    exit_flag: :obj:`int`

        Flag containing job status: 0 = No errors,
        1 = Exception occured and MPI aborted,
        2 = Manager timed out and ended simulation

    """
    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)
github Libensemble / libensemble / libensemble / libE.py View on Github external
def libE_tcp_mgr(sim_specs, gen_specs, exit_criteria,
                 persis_info, alloc_specs, libE_specs, H0):
    "Main routine for TCP multiprocessing launch of libE at manager."

    hist = History(alloc_specs, sim_specs, gen_specs, exit_criteria, H0)

    # Set up a worker launcher
    launchf = libE_tcp_worker_launcher(libE_specs)

    # Get worker launch parameters and fill in defaults for TCP/IP conn
    if 'nworkers' in libE_specs:
        workers = None
        nworkers = libE_specs['nworkers']
    elif 'workers' in libE_specs:
        workers = libE_specs['workers']
        nworkers = len(workers)
    ip = libE_specs.get('ip', None) or get_ip()
    port = libE_specs.get('port', 0)
    authkey = libE_specs.get('authkey', libE_tcp_authkey())

    with ServerQCommManager(port, authkey.encode('utf-8')) as manager:
github Libensemble / libensemble / libensemble / libE.py View on Github external
def libE_mpi_manager(mpi_comm, sim_specs, gen_specs, exit_criteria, persis_info,
                     alloc_specs, libE_specs, H0):
    "Manager routine run at rank 0."

    from libensemble.comms.mpi import MainMPIComm

    hist = History(alloc_specs, sim_specs, gen_specs, exit_criteria, H0)

    # Lauch worker team
    wcomms = [MainMPIComm(mpi_comm, w) for w in
              range(1, mpi_comm.Get_size())]
    manager_logging_config()

    # Set up abort handler
    def on_abort():
        "Shut down MPI on error."
        comms_abort(mpi_comm)

    # Run generic manager
    return libE_manager(wcomms, sim_specs, gen_specs, exit_criteria,
                        persis_info, alloc_specs, libE_specs, hist,
                        on_abort=on_abort)
github Libensemble / libensemble / libensemble / libE_process.py View on Github external
:doc:`(example)`

    exit_flag: :obj:`int`

        Flag containing job status: 0 = No errors,
        1 = Exception occured and MPI aborted,
        2 = Manager timed out and ended simulation

    """
    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())
github Libensemble / libensemble / libensemble / libE.py View on Github external
def libE_local(sim_specs, gen_specs, exit_criteria,
               persis_info, alloc_specs, libE_specs, H0):
    "Main routine for thread/process launch of libE."

    nworkers = libE_specs['nworkers']
    check_inputs(libE_specs, alloc_specs, sim_specs, gen_specs, exit_criteria, H0)

    exctr = Executor.executor
    if exctr is not None:
        local_host = socket.gethostname()
        exctr.add_comm_info(libE_nodes=local_host, serial_setup=True)

    hist = History(alloc_specs, sim_specs, gen_specs, exit_criteria, H0)

    # Launch worker team and set up logger
    wcomms = start_proc_team(nworkers, sim_specs, gen_specs, libE_specs)
    manager_logging_config()

    # Set up cleanup routine to shut down worker team
    def cleanup():
        "Handler to clean up comms team."
        kill_proc_team(wcomms, timeout=libE_specs.get('worker_timeout'))

    # Run generic manager
    return libE_manager(wcomms, sim_specs, gen_specs, exit_criteria,
                        persis_info, alloc_specs, libE_specs, hist,
                        on_cleanup=cleanup)