We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The example below fails ~ 1 in every 10 times on Julia master, with the following error:
using StableRNGs using Random using Test using Evolutionary rng = StableRNG(42) N = 3 P = 100 initState = ()->rand(rng, N) function test_result(result::Evolutionary.EvolutionaryOptimizationResults, N::Int, tol::Float64) fitness = minimum(result) extremum = Evolutionary.minimizer(result) if round(fitness) == 0 @test extremum ≈ zeros(N) atol=tol @test fitness ≈ 0.0 atol=tol else # @warn("Found local minimum!!!") @test sum(abs, extremum) < N end end # Objective function function rastrigin(x::AbstractVector{T}) where {T <: AbstractFloat} n = length(x) return 10n + sum([ x[i]^2 - 10cos(convert(T,2π*x[i])) for i in 1:n ]) end selections = [:rand=>random, :perm=>permutation, :rndoff=>randomoffset, :best=>best] mutations = [:exp=>EXPX(0.5), :bin=>BINX(0.5)] opts = Evolutionary.Options(rng=rng, successive_f_tol=25) @testset "DE settings" for (sn,ss) in selections, (mn,ms) in mutations, n in 1:2 Random.seed!(rng, 1) result = Evolutionary.optimize( rastrigin, initState, DE( populationSize = P, n=n, selection = ss, recombination = ms, F = 0.9 ), opts ) println("DE/$sn/$n/$mn(F=0.9,Cr=0.5) => F: $(minimum(result)), C: $(Evolutionary.iterations(result))") #println(Evolutionary.minimizer(result)) test_result(result, N, 1e-4) end
Error:
Test Summary: | Pass Total Time DE settings | 2 2 0.4s DE/rndoff/2/exp(F=0.9,Cr=0.5) => F: 0.00038250130044303887, C: 61 DE settings: Test Failed at REPL[9]:5 Expression: ≈(extremum, zeros(N), atol = tol) Evaluated: [-0.0008353205026887522, 0.0007904746949007734, 0.0026797512063458733] ≈ [0.0, 0.0, 0.0] (atol=0.0001) Stacktrace: [1] macro expansion @ ~/master/usr/share/julia/stdlib/v1.9/Test/src/Test.jl:464 [inlined] [2] test_result(result::Evolutionary.EvolutionaryOptimizationResults{DE{typeof(randomoffset), Evolutionary.var"#expxvr#152"{Evolutionary.var"#expxvr#151#153"{Float64}}}, Vector{Float64}, Float64}, N::Int64, tol::Float64) @ Main ./REPL[9]:5 DE settings: Test Failed at REPL[9]:6 Expression: ≈(fitness, 0.0, atol = tol) Evaluated: 0.00038250130044303887 ≈ 0.0 (atol=0.0001) Stacktrace: [1] macro expansion @ ~/master/usr/share/julia/stdlib/v1.9/Test/src/Test.jl:464 [inlined] [2] test_result(result::Evolutionary.EvolutionaryOptimizationResults{DE{typeof(randomoffset), Evolutionary.var"#expxvr#152"{Evolutionary.var"#expxvr#151#153"{Float64}}}, Vector{Float64}, Float64}, N::Int64, tol::Float64) @ Main ./REPL[9]:6 Test Summary: | Fail Total Time DE settings | 2 2 0.5s Test Summary: | Fail Total Time DE settings | 2 2 0.6s
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The example below fails ~ 1 in every 10 times on Julia master, with the following error:
Error:
The text was updated successfully, but these errors were encountered: