def test_cmaes_stop_fitness_variance(): opt = CMAESOptimizer(n_samples_per_update=5) opt.init(2) params = np.empty(2) it = 0 while not opt.is_behavior_learning_done(): opt.get_next_parameters(params) opt.set_evaluation_feedback([0.0]) it += 1 assert_equal(it, 6)
def test_cmaes_stop_conditioning(): def objective(x): return -1e10 * x[1] ** 2 opt = CMAESOptimizer(random_state=0) opt.init(2) params = np.empty(2) it = 0 while not opt.is_behavior_learning_done(): opt.get_next_parameters(params) opt.set_evaluation_feedback(objective(params)) it += 1 assert_less(it, 600)