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, )
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`.")
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
def local_minimizer(): bounds = Bounds(shape=(2,), high=10, low=-5, dtype=float) env = Function(function=sphere, bounds=bounds) return MinimizerWrapper(env)
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
def det_cmaes(): bs = Bounds(low=-10, high=10, shape=(5, )) return DeterministicCMAES(bounds=bs, sigma=0.3)
def cmaes(): bs = Bounds(low=-10, high=10, shape=(5, )) return CMAES(bounds=bs, sigma=0.3)