From 20de7b27ab9d6b1524fa336dbb5f0597a1b181db Mon Sep 17 00:00:00 2001 From: Jonathan Fischer Date: Wed, 31 Jan 2024 18:43:40 -0500 Subject: [PATCH 1/3] Fixed `store_trace=true` bug --- lib/OptimizationEvolutionary/src/OptimizationEvolutionary.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/OptimizationEvolutionary/src/OptimizationEvolutionary.jl b/lib/OptimizationEvolutionary/src/OptimizationEvolutionary.jl index 02663f1e5..95776f2aa 100644 --- a/lib/OptimizationEvolutionary/src/OptimizationEvolutionary.jl +++ b/lib/OptimizationEvolutionary/src/OptimizationEvolutionary.jl @@ -90,7 +90,7 @@ function SciMLBase.__solve(cache::OptimizationCache{ u = curr_u, objective = x[1], original = trace) - cb_call = cache.callback(opt_state, trace.value...) + cb_call = cache.callback(opt_state, decompose_trace(trace).value...) if !(cb_call isa Bool) error("The callback should return a boolean `halt` for whether to stop the optimization process.") end From 3658458137eec1fd4daf990f9f4a9e7ec4cd5534 Mon Sep 17 00:00:00 2001 From: Jonathan Fischer PEPE Date: Thu, 1 Feb 2024 18:48:18 -0500 Subject: [PATCH 2/3] added test for `store_trace=true`. Passes on my branch, fails with error on origin master. --- lib/OptimizationEvolutionary/test/runtests.jl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/OptimizationEvolutionary/test/runtests.jl b/lib/OptimizationEvolutionary/test/runtests.jl index 72b9c19ab..18f22ebca 100644 --- a/lib/OptimizationEvolutionary/test/runtests.jl +++ b/lib/OptimizationEvolutionary/test/runtests.jl @@ -42,4 +42,10 @@ Random.seed!(1234) return false end sol = solve(prob, CMAES(μ = 40, λ = 100), callback = cb, maxiters = 100) + + #test that `store_trace=true` throws error. This should fail now that it is fixed + # @test_throws "type Array has no field value" solve(prob, CMAES(μ = 40, λ = 100), store_trace = true) + + #test that `store_trace=true` works now. + solve(prob, CMAES(μ = 40, λ = 100), store_trace = true) end From 985184b6ae703b7391d667f80e39297e19a7ce79 Mon Sep 17 00:00:00 2001 From: Jonathan Fischer Date: Thu, 1 Feb 2024 18:59:06 -0500 Subject: [PATCH 3/3] removed commented out test_throws --- lib/OptimizationEvolutionary/test/runtests.jl | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/OptimizationEvolutionary/test/runtests.jl b/lib/OptimizationEvolutionary/test/runtests.jl index 18f22ebca..32a07c7ee 100644 --- a/lib/OptimizationEvolutionary/test/runtests.jl +++ b/lib/OptimizationEvolutionary/test/runtests.jl @@ -42,10 +42,7 @@ Random.seed!(1234) return false end sol = solve(prob, CMAES(μ = 40, λ = 100), callback = cb, maxiters = 100) - - #test that `store_trace=true` throws error. This should fail now that it is fixed - # @test_throws "type Array has no field value" solve(prob, CMAES(μ = 40, λ = 100), store_trace = true) - #test that `store_trace=true` works now. + #test that `store_trace=true` works now. Threw ""type Array has no field value" before. solve(prob, CMAES(μ = 40, λ = 100), store_trace = true) end