def test_aeo_production(): new_aeo = aeo.AEO() search_space = search.SearchSpace( n_agents=10, n_variables=2, lower_bound=[0, 0], upper_bound=[10, 10] ) a = new_aeo._production(search_space.agents[0], search_space.best_agent, 1, 10) assert type(a).__name__ == "Agent"
def test_aeo_update(): def square(x): return np.sum(x**2) new_aeo = aeo.AEO() search_space = search.SearchSpace( n_agents=10, n_variables=2, lower_bound=[0, 0], upper_bound=[10, 10] ) new_aeo.update(search_space, square, 1, 10)
def test_aeo_update_decomposition(): def square(x): return np.sum(x**2) new_aeo = aeo.AEO() search_space = search.SearchSpace( n_agents=10, n_variables=2, lower_bound=[0, 0], upper_bound=[10, 10] ) new_aeo._update_decomposition(search_space.agents, search_space.best_agent, square)
def test_aeo_carnivore_consumption(): new_aeo = aeo.AEO() search_space = search.SearchSpace( n_agents=10, n_variables=2, lower_bound=[0, 0], upper_bound=[10, 10] ) a = new_aeo._carnivore_consumption( search_space.agents[0], search_space.agents[1], 0.5 ) assert type(a).__name__ == "Agent"
def test_aeo_run(): def square(x): return np.sum(x**2) def hook(optimizer, space, function): return new_function = function.Function(pointer=square) new_aeo = aeo.AEO() search_space = search.SearchSpace(n_agents=10, n_iterations=30, n_variables=2, lower_bound=[0, 0], upper_bound=[10, 10]) history = new_aeo.run(search_space, new_function, pre_evaluation=hook) assert len(history.agents) > 0 assert len(history.best_agent) > 0 best_fitness = history.best_agent[-1][1] assert best_fitness <= constants.TEST_EPSILON, 'The algorithm aeo failed to converge.'
def test_aeo_build(): new_aeo = aeo.AEO() assert new_aeo.built == True