def test_crossentropy_sphere(): optimizer = crossentropy.CrossEntropy(32, population_size=20) optimizer.optimize(problems.sphere_binary, max_iterations=1000, logging_func=lambda *args: optimize._print_fitnesses( *args, frequency=100)) assert optimizer.solution_found
def test_gsa_sphere(): optimizer = GSA(2, [-5.0] * 2, [5.0] * 2) optimizer.optimize(problems.sphere_real, max_iterations=1000, logging_func=lambda *args: optimize._print_fitnesses( *args, frequency=100)) assert optimizer.solution_found
def test_genalg_problems(): # Attempt to solve various problems # Assert that the optimizer can find the solutions optimizer = genalg.GenAlg(examplefunctions.ackley, 32, decode_func=examplefunctions.ackley_binary) optimizer._logging_func = lambda x, y, z : optimize._print_fitnesses(x, y, z, frequency=100) optimizer.optimize() assert optimizer.solution_found
def test_genalg_problems(): # Attempt to solve various problems # Assert that the optimizer can find the solutions optimizer = GenAlg(32) optimizer.optimize(problems.ackley_binary, logging_func=lambda *args: optimize._print_fitnesses( *args, frequency=100)) assert optimizer.solution_found
def test_crossentropy_sphere(): optimizer = crossentropy.CrossEntropy(32, population_size=20) optimizer.optimize( problems.sphere_binary, max_iterations=1000, logging_func= lambda *args: optimize._print_fitnesses(*args, frequency=100)) assert optimizer.solution_found
def test_gsa_sphere(): optimizer = GSA(2, [-5.0] * 2, [5.0] * 2) optimizer.optimize( problems.sphere_real, max_iterations=1000, logging_func= lambda *args: optimize._print_fitnesses(*args, frequency=100)) assert optimizer.solution_found
def test_gsa_sphere(): optimizer = gsa.GSA(examplefunctions.sphere, 2, [-5.0] * 2, [5.0] * 2, max_iterations=1000, decode_func=examplefunctions.decode_real) optimizer._logging_func = lambda x, y, z: optimize._print_fitnesses( x, y, z, frequency=100) optimizer.optimize() assert optimizer.solution_found
def test_gsa_problems(): # Attempt to solve various problems # Assert that the optimizer can find the solutions optimizer = GSA(2, [-5.0] * 2, [5.0] * 2) optimizer.optimize(problems.ackley_real, max_iterations=1000, logging_func=lambda *args: optimize._print_fitnesses( *args, frequency=100)) assert optimizer.solution_found
def test_genalg_problems(): # Attempt to solve various problems # Assert that the optimizer can find the solutions optimizer = GenAlg(32) optimizer.optimize( problems.ackley_binary, logging_func= lambda *args: optimize._print_fitnesses(*args, frequency=100)) assert optimizer.solution_found
def test_gsa_problems(): # Attempt to solve various problems # Assert that the optimizer can find the solutions optimizer = GSA(2, [-5.0] * 2, [5.0] * 2) optimizer.optimize( problems.ackley_real, max_iterations=1000, logging_func= lambda *args: optimize._print_fitnesses(*args, frequency=100)) assert optimizer.solution_found
def test_crossentropy_problems(): # Attempt to solve various problems # Assert that the optimizer can find the solutions # NOTE: since crossentropy is not very effective, we give it simpler problems optimizer = crossentropy.CrossEntropy(32, population_size=20) optimizer.optimize(problems.sphere_binary, max_iterations=1000, logging_func=lambda *args: optimize._print_fitnesses( *args, frequency=100)) assert optimizer.solution_found
def test_gsa_problems(): # Attempt to solve various problems # Assert that the optimizer can find the solutions optimizer = gsa.GSA(examplefunctions.ackley, 2, [-5.0] * 2, [5.0] * 2, max_iterations=1000, decode_func=examplefunctions.decode_real) optimizer._logging_func = lambda x, y, z: optimize._print_fitnesses( x, y, z, frequency=100) optimizer.optimize() assert optimizer.solution_found
def test_crossentropy_problems(): # Attempt to solve various problems # Assert that the optimizer can find the solutions # NOTE: since crossentropy is not very effective, we give it simpler problems optimizer = crossentropy.CrossEntropy(32, population_size=20) optimizer.optimize( problems.sphere_binary, max_iterations=1000, logging_func= lambda *args: optimize._print_fitnesses(*args, frequency=100)) assert optimizer.solution_found
def test_crossentropy_sphere(): optimizer = crossentropy.CrossEntropy( examplefunctions.sphere, 32, population_size=20, max_iterations=1000, decode_func=examplefunctions.ackley_binary) optimizer._logging_func = lambda x, y, z: optimize._print_fitnesses( x, y, z, frequency=100) optimizer.optimize() assert optimizer.solution_found
def test_crossentropy_problems(): # Attempt to solve various problems # Assert that the optimizer can find the solutions # NOTE: since crossentropy is not very effective, we give it simpler problems optimizer = crossentropy.CrossEntropy( examplefunctions.sphere, 32, population_size=20, max_iterations=1000, decode_func=examplefunctions.ackley_binary) optimizer._logging_func = lambda x, y, z: optimize._print_fitnesses( x, y, z, frequency=100) optimizer.optimize() print(1.0 / optimizer.best_fitness) assert optimizer.solution_found
def test_metaoptimize_genalg(): optimizer = genalg.GenAlg(examplefunctions.ackley, 32, decode_func=examplefunctions.ackley_binary) optimizer._logging_func = lambda x, y, z : optimize._print_fitnesses(x, y, z, frequency=100) prev_hyperparameters = optimizer._get_hyperparameters() # Test without metaoptimize, save iterations to solution optimizer.optimize() iterations_to_solution = optimizer.iteration # Test with metaoptimize, assert that iterations to solution is lower optimizer.optimize_hyperparameters(smoothing=1, _meta_optimizer=genalg.GenAlg(None, None, 1, 1)) optimizer.optimize() assert optimizer._get_hyperparameters() != prev_hyperparameters #assert optimizer.iteration < iterations_to_solution # Improvements are made
def test_metaoptimize_gsa(): optimizer = gsa.GSA(examplefunctions.ackley, 2, [-5.0] * 2, [5.0] * 2, max_iterations=1000, decode_func=examplefunctions.decode_real) optimizer._logging_func = lambda x, y, z: optimize._print_fitnesses( x, y, z, frequency=100) prev_hyperparameters = optimizer._get_hyperparameters() # Test without metaoptimize, save iterations to solution optimizer.optimize() iterations_to_solution = optimizer.iteration # Test with metaoptimize, assert that iterations to solution is lower optimizer.optimize_hyperparameters(smoothing=1, _meta_optimizer=genalg.GenAlg( None, None, 1, 1)) optimizer.optimize() assert optimizer._get_hyperparameters() != prev_hyperparameters
def test_genalg_sphere(): optimizer = genalg.GenAlg(examplefunctions.sphere, 32, decode_func=examplefunctions.ackley_binary) optimizer._logging_func = lambda x, y, z : optimize._print_fitnesses(x, y, z, frequency=100) optimizer.optimize() assert optimizer.solution_found
def _check_optimizer(optimizer): optimizer.optimize(problems.sphere_binary, logging_func=lambda *args: optimize._print_fitnesses( *args, frequency=100)) assert optimizer.solution_found
def _check_optimizer(optimizer): optimizer.optimize( problems.sphere_binary, logging_func= lambda *args: optimize._print_fitnesses(*args, frequency=100)) assert optimizer.solution_found