From 7e09cb51e1fefeadaa8e46cf149a8fb76627dda5 Mon Sep 17 00:00:00 2001 From: Alexey Stukalov Date: Thu, 22 Sep 2016 13:53:09 +0200 Subject: [PATCH] ParallelEvaluator: multi-objective tests --- test/test_evaluator.jl | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/test_evaluator.jl b/test/test_evaluator.jl index a8733212..c3245519 100644 --- a/test/test_evaluator.jl +++ b/test/test_evaluator.jl @@ -79,6 +79,24 @@ end using Distributed evaluator_tests(() -> BlackBoxOptim.ParallelEvaluator(p, pids=workers())) + + @testset "multi-objective problem" begin + schaffer1(x) = (sum(abs2, x), sum(xx -> abs2(xx - 2.0), x)) + p = BlackBoxOptim.FunctionBasedProblem(schaffer1, "Schaffer1", ParetoFitnessScheme{2}(is_minimizing=true), + symmetric_search_space(5, (-10.0, 10.0))) + a = EpsBoxArchive(EpsBoxDominanceFitnessScheme(fitness_scheme(p)), max_size=100) + + e = BlackBoxOptim.ParallelEvaluator(p, a, pids=workers()) + fit1 = fitness([0.0, 1.0, 2.0, 3.0, 4.0], e) + @test BlackBoxOptim.num_evals(e) == 1 + @test BlackBoxOptim.last_fitness(e) == fit1.orig + + fit2 = fitness([0.0, -1.0, -2.0, -3.0, -4.0], e) + @test BlackBoxOptim.num_evals(e) == 2 + @test BlackBoxOptim.last_fitness(e) == fit2.orig + + BlackBoxOptim.shutdown!(e) + end end end