gen_specs

Generation function specifications to be set in user calling script and passed to main libE() routine:

gen_specs: [dict]:

    'gen_f' [func]:
        generates inputs to sim_f
    'in' [list]:
        field names (as strings) that will be given to gen_f function when
        it is called (if not present, then no fields will be passed).
    'persis_in' [list]:
        field names (as strings) that will be given back to a persistent gen_f
    'out' [list of tuples (field name, data type, [size])]:
        gen_f outputs that will be stored in the libEnsemble history
    'user' [dict]:
        Data structure to contain problem specific constants and/or input data

Note

  • The user may define fields only in 'user' to be passed to the generator function.

  • The tuples defined in the ‘out’ list are entered into the manager’s history array.

  • The generator 'out' field will usually include variable(s) appearing as a simulator ‘in’ field, in which case only the variable name is required for the simulator 'in' field. The example below, matches the corresponding sim_specs example, where 'x' is defined in the gen_specs 'out' field to give two-dimensional floats.

See also

  • test_uniform_sampling.py In this example, the generation function uniform_random_sample in sampling.py will generate 500 random points uniformly over the 2D domain defined by gen_specs['ub'] and gen_specs['lb'].

    gen_specs = {
        "gen_f": uniform_random_sample,  # Function generating sim_f input
        "out": [("x", float, (2,))],  # Tell libE gen_f output, type, size
        "user": {
            "gen_batch_size": 500,  # Used by this specific gen_f
            "lb": np.array([-3, -2]),  # Used by this specific gen_f
            "ub": np.array([3, 2]),  # Used by this specific gen_f
        },
    }

See also

  • test_persistent_aposmm_nlopt.py shows an example where gen_specs['in'] is empty, but gen_specs['persis_in'] specifies values to return to the persistent generator.

  • test_persistent_aposmm_with_grad.py shows a similar example where an H0 is used to provide points from a previous run. In this case, gen_specs['in'] is populated to provide the generator with data for the initial points.

  • In some cases you might be able to give different (perhaps fewer) fields in 'persis_in' than 'in'; you may not need to give x for example, as the persistent generator already has x for those points. See more example uses of persis_in.