Simulation Specs

Used to specify the simulation function, its inputs and outputs, and user data.

Can be constructed and passed to libEnsemble as a Python class or a dictionary.

 1...
 2from libensemble import SimSpecs
 3from simulator import sim_find_sine
 4
 5...
 6
 7sim_specs = SimSpecs(
 8    sim_f=sim_find_sine,
 9    inputs=["x"],
10    outputs=[("y", float)],
11    user={"batch": 1234},
12)
13...
pydantic model libensemble.specs.SimSpecs

Specifications for configuring a Simulation Function.

Fields:
field globus_compute_endpoint: str | None = ''

A Globus Compute (https://www.globus.org/compute) ID corresponding to an active endpoint on a remote system. libEnsemble’s workers will submit simulator function instances to this endpoint instead of calling them locally.

field inputs: List[str] | None = [] (alias 'in')

List of field names out of the complete history to pass into the simulation function upon calling.

field outputs: List[Tuple[str, Any] | Tuple[str, Any, int | Tuple]] | None = [] (alias 'out')

List of 2- or 3-tuples corresponding to NumPy dtypes. e.g. ("dim", int, (3,)), or ("path", str). Typically used to initialize an output array within the simulation function: out = np.zeros(100, dtype=sim_specs["out"]). Also necessary to construct libEnsemble’s history array.

field persis_in: List[str] | None = []

List of field names to send to a persistent simulation function throughout the run, following initialization.

field sim_f: Callable = None

Python function matching the sim_f interface. Evaluates parameters produced by a generator function.

field threaded: bool | None = False

Instruct Worker process to launch user function to a thread.

field user: dict | None = {}

A user-data dictionary to place bounds, constants, settings, or other parameters for customizing the simulator function.

 1...
 2from simulator import six_hump_camel
 3
 4...
 5
 6sim_specs = {
 7    "sim_f": six_hump_camel,
 8    "in": ["x"],
 9    "out": [("y", float)],
10    "user": {"batch": 1234},
11}
12...
    sim_specs = {
        "sim_f": six_hump_camel,  # Function whose output is being minimized
        "in": ["x"],  # Keys to be given to sim_f
        "out": [("f", float)],  # Name of the outputs from sim_f
    }
    "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"],
        "cores": 2,
        "sim_particles": 1e3,
        "sim_timesteps": 5,
        "sim_kill_minutes": 10.0,
        "particle_variance": 0.2,
        "kill_rate": 0.5,
        "fail_on_sim": False,
        "fail_on_submit": False,  # Won't occur if 'fail_on_sim' True
    },
}