Esempio n. 1
0
def mapper():
    def potential_well(x):
        return numpy.sum((x - 1)**2, 1) - 1

    bounds = Bounds.from_tuples([(-10, 10), (-5, 5)])

    def model(x):
        return NormalContinuous(bounds=bounds, env=x)

    return FunctionMapper.from_function(
        n_vectors=5,
        function=potential_well,
        bounds=bounds,
        model=model,
        shape=(2, ),
        n_walkers=10,
        reward_scale=1,
        accumulate_rewards=False,
    )
Esempio n. 2
0
def create_model(name="es_model"):
    if name == "es_model":
        bs = Bounds(low=-10, high=10, shape=(BATCH_SIZE,))
        return lambda: ESModel(bounds=bs)
    raise ValueError("Invalid param `name`.")
Esempio n. 3
0
def custom_domain_function():
    bounds = Bounds(shape=(2,), high=10, low=-5, dtype=float)
    env = Function(
        function=sphere, bounds=bounds, custom_domain_check=lambda x: numpy.linalg.norm(x) < 5.0
    )
    return env
Esempio n. 4
0
def local_minimizer():
    bounds = Bounds(shape=(2,), high=10, low=-5, dtype=float)
    env = Function(function=sphere, bounds=bounds)
    return MinimizerWrapper(env)
Esempio n. 5
0
 def test_minimizer_getattr(self):
     bounds = Bounds(shape=(2,), high=10, low=-5, dtype=float)
     env = Function(function=sphere, bounds=bounds)
     minim = MinimizerWrapper(env)
     assert minim.shape == env.shape
Esempio n. 6
0
def det_cmaes():
    bs = Bounds(low=-10, high=10, shape=(5, ))
    return DeterministicCMAES(bounds=bs, sigma=0.3)
Esempio n. 7
0
def cmaes():
    bs = Bounds(low=-10, high=10, shape=(5, ))
    return CMAES(bounds=bs, sigma=0.3)