@@ -26,15 +26,20 @@ using Test
26
26
@test 10 * sol. objective < l1
27
27
28
28
fitness_progress_history = []
29
+ fitness_progress_history_orig = []
30
+ loss_history = []
29
31
function cb (state, fitness)
30
- push! (fitness_progress_history, [deepcopy (state), fitness])
32
+ push! (fitness_progress_history, state. objective)
33
+ push! (fitness_progress_history_orig, BlackBoxOptim. best_fitness (state. original))
34
+ push! (loss_history, fitness)
31
35
return false
32
36
end
33
37
sol = solve (prob, BBO_adaptive_de_rand_1_bin_radiuslimited (), callback = cb)
34
38
# println(fitness_progress_history)
35
39
@test ! isempty (fitness_progress_history)
36
40
fp1 = fitness_progress_history[1 ]
37
- @test BlackBoxOptim. best_fitness (fp1[1 ]. original) == fp1[1 ]. objective == fp1[2 ]
41
+ fp2 = fitness_progress_history_orig[1 ]
42
+ @test fp2 == fp1 == loss_history[1 ]
38
43
39
44
@test_logs begin
40
45
(Base. LogLevel (- 1 ), " loss: 0.0" )
@@ -87,19 +92,23 @@ using Test
87
92
end
88
93
89
94
fitness_progress_history = []
95
+ fitness_progress_history_orig = []
90
96
function cb (state, fitness)
91
- push! (fitness_progress_history, deepcopy (state))
97
+ push! (fitness_progress_history, state. objective)
98
+ push! (fitness_progress_history_orig, BlackBoxOptim. best_fitness (state. original))
92
99
return false
93
100
end
94
101
95
102
mof_1 = MultiObjectiveOptimizationFunction (multi_obj_func_1)
96
103
prob_1 = Optimization. OptimizationProblem (mof_1, u0; lb = lb, ub = ub)
97
104
sol_1 = solve (prob_1, opt, NumDimensions = 2 ,
98
- FitnessScheme = ParetoFitnessScheme {2} (is_minimizing = true ), callback= cb)
105
+ FitnessScheme = ParetoFitnessScheme {2} (is_minimizing = true ),
106
+ callback= cb)
99
107
100
108
fp1 = fitness_progress_history[1 ]
101
- @test BlackBoxOptim. best_fitness (fp1. original). orig == fp1. objective
102
- @test length (fp1. objective) == 2
109
+ fp2 = fitness_progress_history_orig[1 ]
110
+ @test fp2. orig == fp1
111
+ @test length (fp1) == 2
103
112
104
113
@test sol_1 ≠ nothing
105
114
println (" Solution for Sphere and Rastrigin: " , sol_1)
0 commit comments