From b02a49c18cecde4ef3b619ee0194a023424a43dd Mon Sep 17 00:00:00 2001 From: Andrea Zunino Date: Mon, 13 Apr 2026 15:04:08 +0200 Subject: [PATCH] remove compat --- Project.toml | 12 +--------- test/optim_tests.jl | 54 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 11 deletions(-) create mode 100644 test/optim_tests.jl diff --git a/Project.toml b/Project.toml index 2562998..6f246ee 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "InverseAlgos" uuid = "64ff6778-433b-4901-a403-25308785a0c4" authors = ["Andrea Zunino "] -version = "0.2.4" +version = "0.2.5" [deps] Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" @@ -16,14 +16,4 @@ REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" [compat] -Dates = "1.11.0" -Distributed = "1.11.0" -DocStringExtensions = "0.9.3" -HDF5 = "0.17.2" -JLD2 = "0.5.10" -LinearAlgebra = "1.11.0" -Logging = "1.11.0" -Printf = "1.11.0" -REPL = "1.11.0" -UUIDs = "1.11.0" julia = ">=1.10" diff --git a/test/optim_tests.jl b/test/optim_tests.jl new file mode 100644 index 0000000..2d187d6 --- /dev/null +++ b/test/optim_tests.jl @@ -0,0 +1,54 @@ + + +using InverseAlgos.Optimizers +using NonlinearOptimizationTestFunctions + + +function test_bfgs_testfunc() + + N = 10 + test_funcs = ["rosenbrock","himmelblau","styblinski_tang","sphere", + "ackley"] # Failing on this one... + + allpass = true + for tf in test_funcs + testfun = fixed(TEST_FUNCTIONS[tf],n=N) + pass = optimtestfun(testfun,N) + allpass = allpass && pass + end + + @show allpass + return allpass +end + + +function optimtestfun(testfun,N) + + println("\n##===>>> Testing $(testfun.name) function, $N dimensions ") + minval = min_value(testfun) + minpos = min_position(testfun) + + function fh!(g,x) + phi = testfun.f(x) + testfun.gradient!(g,x) + return phi + end + + x0 = start(testfun) + @show x0 + @show minpos + + xout,misfout = lmbfgs(fh!,x0, + mem=20, + maxiter=50, + saveres=false) + + ce1 = isapprox(xout[end],minpos,atol=1e-8) + ce2 = isapprox(misfout[end],minval,atol=1e-8) + + # @show ce1,ce2 + # @show minval,misfout[end] + # @show xout[end].-minpos + out = ce1 && ce2 + return out +end