Exemplo n.º 1
0
def setup_executor_noreg():
    # sim_app = './my_simtask.x'
    if not os.path.isfile(sim_app):
        build_simfunc()

    if USE_BALSAM:
        from libensemble.executors.balsam_executor import BalsamMPIExecutor
        exctr = BalsamMPIExecutor(auto_resources=False)
    else:
        from libensemble.executors.mpi_executor import MPIExecutor
        exctr = MPIExecutor(auto_resources=False)

    exctr.register_calc(full_path=sim_app, calc_type='sim')
Exemplo n.º 2
0
def setup_executor_noapp():
    # sim_app = './my_simtask.x'
    if not os.path.isfile(sim_app):
        build_simfunc()

    if USE_BALSAM:
        from libensemble.executors.balsam_executor import BalsamMPIExecutor
        exctr = BalsamMPIExecutor(auto_resources=False)
    else:
        from libensemble.executors.mpi_executor import MPIExecutor
        exctr = MPIExecutor(auto_resources=False)
        if exctr.workerID is not None:
            sys.exit("Something went wrong in creating Executor")
Exemplo n.º 3
0
              'comms': 'mpi',
              'save_every_k_sims': 400,
              'save_every_k_gens': 20,
              }

nworkers = MPI.COMM_WORLD.Get_size() - 1
is_master = MPI.COMM_WORLD.Get_rank() == 0

cores_per_task = 1

sim_app = './my_simtask.x'
if not os.path.isfile(sim_app):
    build_simfunc()
sim_app2 = six_hump_camel.__file__

exctr = BalsamMPIExecutor(auto_resources=False, central_mode=False, custom_info={'not': 'used'})
exctr.register_calc(full_path=sim_app, calc_type='sim')  # Default 'sim' app - backward compatible
exctr.register_calc(full_path=sim_app2, app_name='six_hump_camel')  # Named app

sim_specs = {'sim_f': executor_hworld,
             'in': ['x'],
             'out': [('f', float), ('cstat', int)],
             'user': {'cores': cores_per_task,
                      'balsam_test': True}
             }

gen_specs = {'gen_f': uniform_random_sample,
             'in': ['sim_id'],
             'out': [('x', float, (2,))],
             'user': {'lb': np.array([-3, -2]),
                      'ub': np.array([3, 2]),
Exemplo n.º 4
0
    mess_resources = 'TCP comms does not support auto_resources. Auto_resources set to False'
else:
    use_auto_resources = True
    mess_resources = 'Auto_resources set to True'

if is_master:
    print('\nCores req: {} Cores avail: {}\n  {}\n'.format(
        cores_all_tasks, logical_cores, mess_resources))

sim_app = './my_simtask.x'
if not os.path.isfile(sim_app):
    build_simfunc()

if USE_BALSAM:
    from libensemble.executors.balsam_executor import BalsamMPIExecutor
    exctr = BalsamMPIExecutor(auto_resources=use_auto_resources)
else:
    from libensemble.executors.mpi_executor import MPIExecutor
    exctr = MPIExecutor(auto_resources=use_auto_resources)
exctr.register_calc(full_path=sim_app, calc_type='sim')

# if nworkers == 3:
#    CalcInfo.keep_worker_stat_files = True # Testing this functionality
# else:
#    CalcInfo.keep_worker_stat_files = False # Testing this functionality

sim_specs = {
    'sim_f': sim_f,
    'in': ['x'],
    'out': [('f', float), ('cstat', int)],
    'user': {
Exemplo n.º 5
0
nworkers, is_master, libE_specs, _ = parse_args()

if is_master:
    print('\nRunning with {} workers\n'.format(nworkers))

if not os.path.isfile('./forces.x'):
    if os.path.isfile('./build_forces.sh'):
        import subprocess
        subprocess.check_call(['./build_forces.sh'])
sim_app = os.path.abspath('./forces.x')

# Create executor and register sim to it.
if USE_BALSAM:
    from libensemble.executors.balsam_executor import BalsamMPIExecutor
    exctr = BalsamMPIExecutor({{ balsam_exctr_args }})  # Use allow_oversubscribe=False to prevent oversubscription
else:
    from libensemble.executors.mpi_executor import MPIExecutor
    exctr = MPIExecutor({{ mpi_exctr_args }})  # Use allow_oversubscribe=False to prevent oversubscription
exctr.register_calc(full_path=sim_app, calc_type='sim')

# Note: Attributes such as kill_rate are to control forces tests, this would not be a typical parameter.

# State the objective function, its arguments, output, and necessary parameters (and their sizes)
sim_specs = {'sim_f': run_forces,         # Function whose output is being minimized
             'in': ['x'],                 # Name of input for sim_f
             'out': [('energy', float)],  # Name, type of output from sim_f
             'user': {'keys': ['seed'],
                      {%- if cores is defined %} 'cores': {{ cores }}, {% endif %}
                      'sim_particles': {{ num_sim_particles }},
                      'sim_timesteps': 5,
Exemplo n.º 6
0
# sim_app = 'simdir/my_simtask.x'
# gen_app = 'gendir/my_genjob.x'

# temp
sim_app = './my_simtask.x'

if not os.path.isfile(sim_app):
    build_simfunc()

USE_BALSAM = False  # Take as arg
# USE_BALSAM = True # Take as arg

# Create and add exes to registry
if USE_BALSAM:
    from libensemble.executors.balsam_executor import BalsamMPIExecutor
    exctr = BalsamMPIExecutor()
else:
    from libensemble.executors.mpi_executor import MPIExecutor
    exctr = MPIExecutor()

exctr.register_calc(full_path=sim_app, calc_type='sim')

# Alternative to IF could be using eg. fstring to specify: e.g:
# EXECUTOR = 'Balsam'
# registry = f"{EXECUTOR}Register()"

# --------------- Worker: sim func ----------------------------------------
# Should work with Balsam or not


def polling_loop(exctr, task, timeout_sec=20.0, delay=2.0):
    import libensemble.gen_funcs
    libensemble.gen_funcs.rc.aposmm_optimizers = 'nlopt'
    from libensemble.gen_funcs.persistent_aposmm import aposmm as gen_f
    from libensemble.alloc_funcs.persistent_aposmm_alloc \
        import persistent_aposmm_alloc as alloc_f
else:
    print("you shouldn' hit that")
    sys.exit()

from libensemble.tools import parse_args, save_libE_output, \
    add_unique_random_streams
from libensemble import libE_logger

if USE_BALSAM:
    from libensemble.executors.balsam_executor import BalsamMPIExecutor
    exctr = BalsamMPIExecutor(central_mode=True{% if zero_resource_workers is defined %}, zero_resource_workers=[{{ zero_resource_workers }}]{% endif %})
else:
    from libensemble.executors.mpi_executor import MPIExecutor
    exctr = MPIExecutor(central_mode=True{% if zero_resource_workers is defined %}, zero_resource_workers=[{{ zero_resource_workers }}]{% endif %})

libE_logger.set_level('DEBUG')

nworkers, is_master, libE_specs, _ = parse_args()

# Set to full path of warp executable
sim_app = os.path.abspath({{ sim_app }})

# Problem dimension. This is the number of input parameters exposed,
# that LibEnsemble will vary in order to minimize a single output parameter.
n = 4
Exemplo n.º 8
0
    mess_resources = 'TCP comms does not support auto_resources. Auto_resources set to False'
else:
    use_auto_resources = True
    mess_resources = 'Auto_resources set to True'

if is_master:
    print('\nCores req: {} Cores avail: {}\n  {}\n'.format(cores_all_tasks, logical_cores, mess_resources))

sim_app = './my_simtask.x'
if not os.path.isfile(sim_app):
    build_simfunc()
sim_app2 = six_hump_camel.__file__

if USE_BALSAM:
    from libensemble.executors.balsam_executor import BalsamMPIExecutor
    exctr = BalsamMPIExecutor(auto_resources=use_auto_resources)
else:
    from libensemble.executors.mpi_executor import MPIExecutor
    exctr = MPIExecutor(auto_resources=use_auto_resources)
exctr.register_calc(full_path=sim_app, calc_type='sim')  # Default 'sim' app - backward compatible
exctr.register_calc(full_path=sim_app2, app_name='six_hump_camel')  # Named app

# if nworkers == 3:
#    CalcInfo.keep_worker_stat_files = True # Testing this functionality
# else:
#    CalcInfo.keep_worker_stat_files = False # Testing this functionality

sim_specs = {'sim_f': sim_f,
             'in': ['x'],
             'out': [('f', float), ('cstat', int)],
             'user': {'cores': cores_per_task}