From e98dee70220c55f5bb466cc1372b05a7db1cae94 Mon Sep 17 00:00:00 2001 From: Vaibhav Kumar Dixit Date: Sat, 17 Feb 2024 08:48:00 -0500 Subject: [PATCH 01/10] Update regularization_test.jl --- test/tests_on_odes/regularization_test.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/tests_on_odes/regularization_test.jl b/test/tests_on_odes/regularization_test.jl index 3351fc6..79e06ce 100644 --- a/test/tests_on_odes/regularization_test.jl +++ b/test/tests_on_odes/regularization_test.jl @@ -21,13 +21,13 @@ cost_function_3 = build_loss_objective(prob3, Tsit5(), L2Loss(t, data), println("Use Optim BFGS to fit the parameter") optprob = Optimization.OptimizationProblem(cost_function_1, [1.0]) -result = solve(optprob, Optim.BFGS()) +result = solve(optprob, Optim.BFGS(), maxiters = 500) @test result.u[1]≈1.5 atol=3e-1 optprob = Optimization.OptimizationProblem(cost_function_2, [1.2, 2.7]) -result = solve(optprob, Optim.BFGS()) +result = solve(optprob, Optim.BFGS(), maxiters = 500) @test result.minimizer≈[1.5; 3.0] atol=3e-1 optprob = Optimization.OptimizationProblem(cost_function_3, [1.3, 0.8, 2.8, 1.2]) -result = solve(optprob, Optim.BFGS()) +result = solve(optprob, Optim.BFGS(), maxiters = 500) @test result.minimizer≈[1.5; 1.0; 3.0; 1.0] atol=5e-1 From a624d95aa92be271f3eccf423bc9ed141e6a8f5d Mon Sep 17 00:00:00 2001 From: Vaibhav Kumar Dixit Date: Sat, 17 Feb 2024 09:20:09 -0500 Subject: [PATCH 02/10] Update blackboxoptim_test.jl --- test/tests_on_odes/blackboxoptim_test.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/tests_on_odes/blackboxoptim_test.jl b/test/tests_on_odes/blackboxoptim_test.jl index 7752730..1508f00 100644 --- a/test/tests_on_odes/blackboxoptim_test.jl +++ b/test/tests_on_odes/blackboxoptim_test.jl @@ -4,17 +4,17 @@ println("Use BlackBoxOptim to fit the parameter") cost_function = build_loss_objective(prob1, Tsit5(), L2Loss(t, data), maxiters = 10000, verbose = false) bound1 = Tuple{Float64, Float64}[(1, 2)] -result = bboptimize(cost_function; SearchRange = bound1, MaxSteps = 11e3) +result = bboptimize(cost_function; SearchRange = bound1, MaxSteps = 1e3) @test result.archive_output.best_candidate[1]≈1.5 atol=3e-1 cost_function = build_loss_objective(prob2, Tsit5(), L2Loss(t, data), maxiters = 10000, verbose = false) bound2 = Tuple{Float64, Float64}[(1, 2), (2, 4)] -result = bboptimize(cost_function; SearchRange = bound2, MaxSteps = 11e3) +result = bboptimize(cost_function; SearchRange = bound2, MaxSteps = 1e3) @test result.archive_output.best_candidate≈[1.5; 3.0] atol=3e-1 cost_function = build_loss_objective(prob3, Tsit5(), L2Loss(t, data), maxiters = 10000, verbose = false) bound3 = Tuple{Float64, Float64}[(1, 2), (0, 2), (2, 4), (0, 2)] -result = bboptimize(cost_function; SearchRange = bound3, MaxSteps = 11e3) +result = bboptimize(cost_function; SearchRange = bound3, MaxSteps = 1e3) @test result.archive_output.best_candidate≈[1.5; 1.0; 3.0; 1.0] atol=5e-1 From c90d887f569acdf16557a049a6ebc654b9ee5504 Mon Sep 17 00:00:00 2001 From: Vaibhav Kumar Dixit Date: Sat, 17 Feb 2024 09:41:51 -0500 Subject: [PATCH 03/10] Apply suggestions from code review --- test/tests_on_odes/regularization_test.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/tests_on_odes/regularization_test.jl b/test/tests_on_odes/regularization_test.jl index 79e06ce..87e58c0 100644 --- a/test/tests_on_odes/regularization_test.jl +++ b/test/tests_on_odes/regularization_test.jl @@ -21,13 +21,13 @@ cost_function_3 = build_loss_objective(prob3, Tsit5(), L2Loss(t, data), println("Use Optim BFGS to fit the parameter") optprob = Optimization.OptimizationProblem(cost_function_1, [1.0]) -result = solve(optprob, Optim.BFGS(), maxiters = 500) +result = solve(optprob, Optim.LBFGS(), maxiters = 500) @test result.u[1]≈1.5 atol=3e-1 optprob = Optimization.OptimizationProblem(cost_function_2, [1.2, 2.7]) -result = solve(optprob, Optim.BFGS(), maxiters = 500) +result = solve(optprob, Optim.LBFGS(), maxiters = 500) @test result.minimizer≈[1.5; 3.0] atol=3e-1 optprob = Optimization.OptimizationProblem(cost_function_3, [1.3, 0.8, 2.8, 1.2]) -result = solve(optprob, Optim.BFGS(), maxiters = 500) +result = solve(optprob, Optim.LBFGS(), maxiters = 500) @test result.minimizer≈[1.5; 1.0; 3.0; 1.0] atol=5e-1 From 89d062e0bd1058816cdba63fdb6afbe5e06a90e3 Mon Sep 17 00:00:00 2001 From: Vaibhav Kumar Dixit Date: Sun, 18 Feb 2024 03:20:50 -0500 Subject: [PATCH 04/10] Update regularization_test.jl --- test/tests_on_odes/regularization_test.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/tests_on_odes/regularization_test.jl b/test/tests_on_odes/regularization_test.jl index 87e58c0..9877acc 100644 --- a/test/tests_on_odes/regularization_test.jl +++ b/test/tests_on_odes/regularization_test.jl @@ -21,13 +21,13 @@ cost_function_3 = build_loss_objective(prob3, Tsit5(), L2Loss(t, data), println("Use Optim BFGS to fit the parameter") optprob = Optimization.OptimizationProblem(cost_function_1, [1.0]) -result = solve(optprob, Optim.LBFGS(), maxiters = 500) +result = solve(optprob, Optim.LBFGS()) @test result.u[1]≈1.5 atol=3e-1 optprob = Optimization.OptimizationProblem(cost_function_2, [1.2, 2.7]) -result = solve(optprob, Optim.LBFGS(), maxiters = 500) +result = solve(optprob, Optim.LBFGS()) @test result.minimizer≈[1.5; 3.0] atol=3e-1 optprob = Optimization.OptimizationProblem(cost_function_3, [1.3, 0.8, 2.8, 1.2]) -result = solve(optprob, Optim.LBFGS(), maxiters = 500) +result = solve(optprob, Optim.LBFGS()) @test result.minimizer≈[1.5; 1.0; 3.0; 1.0] atol=5e-1 From bdb5cb88b4bcf4eed676f71270321edbeaee5271 Mon Sep 17 00:00:00 2001 From: Vaibhav Kumar Dixit Date: Sun, 18 Feb 2024 03:21:35 -0500 Subject: [PATCH 05/10] Update blackboxoptim_test.jl --- test/tests_on_odes/blackboxoptim_test.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/tests_on_odes/blackboxoptim_test.jl b/test/tests_on_odes/blackboxoptim_test.jl index 1508f00..f768315 100644 --- a/test/tests_on_odes/blackboxoptim_test.jl +++ b/test/tests_on_odes/blackboxoptim_test.jl @@ -4,17 +4,17 @@ println("Use BlackBoxOptim to fit the parameter") cost_function = build_loss_objective(prob1, Tsit5(), L2Loss(t, data), maxiters = 10000, verbose = false) bound1 = Tuple{Float64, Float64}[(1, 2)] -result = bboptimize(cost_function; SearchRange = bound1, MaxSteps = 1e3) +result = bboptimize(cost_function; SearchRange = bound1, MaxSteps = 5e3) @test result.archive_output.best_candidate[1]≈1.5 atol=3e-1 cost_function = build_loss_objective(prob2, Tsit5(), L2Loss(t, data), maxiters = 10000, verbose = false) bound2 = Tuple{Float64, Float64}[(1, 2), (2, 4)] -result = bboptimize(cost_function; SearchRange = bound2, MaxSteps = 1e3) +result = bboptimize(cost_function; SearchRange = bound2, MaxSteps = 5e3) @test result.archive_output.best_candidate≈[1.5; 3.0] atol=3e-1 cost_function = build_loss_objective(prob3, Tsit5(), L2Loss(t, data), maxiters = 10000, verbose = false) bound3 = Tuple{Float64, Float64}[(1, 2), (0, 2), (2, 4), (0, 2)] -result = bboptimize(cost_function; SearchRange = bound3, MaxSteps = 1e3) +result = bboptimize(cost_function; SearchRange = bound3, MaxSteps = 5e3) @test result.archive_output.best_candidate≈[1.5; 1.0; 3.0; 1.0] atol=5e-1 From 6283d1908a8626703ef7889c07169283a1242f7c Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Sun, 18 Feb 2024 05:33:41 -0500 Subject: [PATCH 06/10] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 19aae4c..1e9678d 100644 --- a/Project.toml +++ b/Project.toml @@ -25,7 +25,7 @@ PreallocationTools = "0.2, 0.3, 0.4" RecursiveArrayTools = "1.0, 2.0, 3" SciMLBase = "1.69, 2" SciMLSensitivity = "7" -julia = "1.6" +julia = "1.10" [extras] BlackBoxOptim = "a134a8b2-14d6-55f6-9291-3336d3ab0209" From 9dbeb8a5c76ad954a327ea29328575692fcae56a Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Sun, 18 Feb 2024 05:33:56 -0500 Subject: [PATCH 07/10] Update CI.yml --- .github/workflows/CI.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index a64f30a..a8e4805 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -19,7 +19,6 @@ jobs: - All version: - '1' - - '1.6' steps: - uses: actions/checkout@v4 - uses: julia-actions/setup-julia@v1 From 91089a5c865b44897200c9d7d8033cd0837f0b93 Mon Sep 17 00:00:00 2001 From: Vaibhav Dixit Date: Sun, 25 Feb 2024 08:58:30 -0500 Subject: [PATCH 08/10] More lower iterations --- test/likelihood.jl | 18 +++++++++--------- test/multiple_shooting_objective_test.jl | 2 +- test/tests_on_odes/blackboxoptim_test.jl | 12 ++++++------ test/tests_on_odes/genetic_algorithm_test.jl | 6 +++--- test/tests_on_odes/l2_colloc_grad_test.jl | 8 ++++---- test/tests_on_odes/l2loss_test.jl | 8 ++++---- test/tests_on_odes/nlopt_test.jl | 10 +++++----- test/tests_on_odes/optim_test.jl | 2 +- test/tests_on_odes/regularization_test.jl | 12 ++++++------ test/tests_on_odes/weighted_loss_test.jl | 2 +- 10 files changed, 40 insertions(+), 40 deletions(-) diff --git a/test/likelihood.jl b/test/likelihood.jl index f6a3e8d..242aea1 100644 --- a/test/likelihood.jl +++ b/test/likelihood.jl @@ -19,12 +19,12 @@ end aggregate_data = convert(Array, VectorOfArray([generate_data(sol, t) for i in 1:100])) distributions = [fit_mle(Normal, aggregate_data[i, j, :]) for i in 1:2, j in 1:200] -obj = build_loss_objective(prob1, Tsit5(), LogLikeLoss(t, distributions), maxiters = 10000, +obj = build_loss_objective(prob1, Tsit5(), LogLikeLoss(t, distributions), maxiters = 1000, verbose = false) optprob = Optimization.OptimizationProblem(obj, [2.0, 2.0], lb = [0.5, 0.5], ub = [5.0, 5.0]) -result = solve(optprob, BBO_adaptive_de_rand_1_bin_radiuslimited(), maxiters = 11e3) +result = solve(optprob, BBO_adaptive_de_rand_1_bin_radiuslimited(), maxiters = 1e3) @test result.original.archive_output.best_candidate≈[1.5, 1.0] atol=1e-1 data_distributions = [fit_mle(Normal, aggregate_data[i, j, :]) for i in 1:2, j in 1:200] @@ -33,11 +33,11 @@ diff_distributions = [fit_mle(Normal, for j in 2:200, i in 1:2] obj = build_loss_objective(prob1, Tsit5(), LogLikeLoss(t, data_distributions, diff_distributions), - Optimization.AutoForwardDiff(), maxiters = 10000, + Optimization.AutoForwardDiff(), maxiters = 1000, verbose = false) optprob = Optimization.OptimizationProblem(obj, [2.0, 2.0], lb = [0.5, 0.5], ub = [5.0, 5.0]) -result = solve(optprob, BBO_adaptive_de_rand_1_bin_radiuslimited(), maxiters = 11e3) +result = solve(optprob, BBO_adaptive_de_rand_1_bin_radiuslimited(), maxiters = 1e3) @test result.original.archive_output.best_candidate≈[1.5, 1.0] atol=1e-1 data_distributions = [fit_mle(Normal, aggregate_data[i, j, :]) for i in 1:2, j in 1:200] @@ -46,14 +46,14 @@ diff_distributions = [fit_mle(Normal, for j in 2:200, i in 1:2] obj = build_loss_objective(prob1, Tsit5(), LogLikeLoss(t, data_distributions, diff_distributions, 0.3), - Optimization.AutoForwardDiff(), maxiters = 10000, + Optimization.AutoForwardDiff(), maxiters = 1000, verbose = false) optprob = Optimization.OptimizationProblem(obj, [2.0, 2.0], lb = [0.5, 0.5], ub = [5.0, 5.0]) -result = solve(optprob, BBO_adaptive_de_rand_1_bin_radiuslimited(), maxiters = 11e3) +result = solve(optprob, BBO_adaptive_de_rand_1_bin_radiuslimited(), maxiters = 1e3) @test result.u≈[1.5, 1.0] atol=1e-1 using OptimizationBBO.BlackBoxOptim -result = bboptimize(obj, SearchRange = [(0.5, 5.0), (0.5, 5.0)], MaxSteps = 11e3) +result = bboptimize(obj, SearchRange = [(0.5, 5.0), (0.5, 5.0)], MaxSteps = 1e3) @test result.archive_output.best_candidate≈[1.5, 1.0] atol=1e-1 distributions = [fit_mle(MvNormal, aggregate_data[:, j, :]) for j in 1:200] @@ -63,9 +63,9 @@ diff_distributions = [fit_mle(MvNormal, priors = [Truncated(Normal(1.5, 0.1), 0, 2), Truncated(Normal(1.0, 0.1), 0, 1.5)] obj = build_loss_objective(prob1, Tsit5(), LogLikeLoss(t, distributions, diff_distributions), - Optimization.AutoForwardDiff(), maxiters = 10000, + Optimization.AutoForwardDiff(), maxiters = 1000, verbose = false, priors = priors) optprob = Optimization.OptimizationProblem(obj, [2.0, 2.0], lb = [0.5, 0.5], ub = [5.0, 5.0]) -result = solve(optprob, BBO_adaptive_de_rand_1_bin_radiuslimited(), maxiters = 11e3) +result = solve(optprob, BBO_adaptive_de_rand_1_bin_radiuslimited(), maxiters = 1e3) @test result.u≈[1.5, 1.0] atol=1e-1 diff --git a/test/multiple_shooting_objective_test.jl b/test/multiple_shooting_objective_test.jl index 5155a57..d206c15 100644 --- a/test/multiple_shooting_objective_test.jl +++ b/test/multiple_shooting_objective_test.jl @@ -18,7 +18,7 @@ ms_obj = multiple_shooting_objective(ms_prob, Tsit5(), L2Loss(t, data), Optimization.AutoZygote(); discontinuity_weight = 1.0, abstol = 1e-12, reltol = 1e-12) -result = bboptimize(ms_obj; SearchRange = bound, MaxSteps = 21e3) +result = bboptimize(ms_obj; SearchRange = bound, MaxSteps = 1e3) @test result.archive_output.best_candidate[(end - 1):end]≈[1.5, 1.0] atol=2e-1 priors = [Truncated(Normal(1.5, 0.5), 0, 2), Truncated(Normal(1.0, 0.5), 0, 1.5)] diff --git a/test/tests_on_odes/blackboxoptim_test.jl b/test/tests_on_odes/blackboxoptim_test.jl index f768315..01f881f 100644 --- a/test/tests_on_odes/blackboxoptim_test.jl +++ b/test/tests_on_odes/blackboxoptim_test.jl @@ -2,19 +2,19 @@ using BlackBoxOptim println("Use BlackBoxOptim to fit the parameter") cost_function = build_loss_objective(prob1, Tsit5(), L2Loss(t, data), - maxiters = 10000, verbose = false) + maxiters = 1000, verbose = false) bound1 = Tuple{Float64, Float64}[(1, 2)] -result = bboptimize(cost_function; SearchRange = bound1, MaxSteps = 5e3) +result = bboptimize(cost_function; SearchRange = bound1, MaxSteps = 1e3) @test result.archive_output.best_candidate[1]≈1.5 atol=3e-1 cost_function = build_loss_objective(prob2, Tsit5(), L2Loss(t, data), - maxiters = 10000, verbose = false) + maxiters = 1000, verbose = false) bound2 = Tuple{Float64, Float64}[(1, 2), (2, 4)] -result = bboptimize(cost_function; SearchRange = bound2, MaxSteps = 5e3) +result = bboptimize(cost_function; SearchRange = bound2, MaxSteps = 1e3) @test result.archive_output.best_candidate≈[1.5; 3.0] atol=3e-1 cost_function = build_loss_objective(prob3, Tsit5(), L2Loss(t, data), - maxiters = 10000, verbose = false) + maxiters = 1000, verbose = false) bound3 = Tuple{Float64, Float64}[(1, 2), (0, 2), (2, 4), (0, 2)] -result = bboptimize(cost_function; SearchRange = bound3, MaxSteps = 5e3) +result = bboptimize(cost_function; SearchRange = bound3, MaxSteps = 11e3) @test result.archive_output.best_candidate≈[1.5; 1.0; 3.0; 1.0] atol=5e-1 diff --git a/test/tests_on_odes/genetic_algorithm_test.jl b/test/tests_on_odes/genetic_algorithm_test.jl index ddfc47e..c698a89 100644 --- a/test/tests_on_odes/genetic_algorithm_test.jl +++ b/test/tests_on_odes/genetic_algorithm_test.jl @@ -14,7 +14,7 @@ println("Use Genetic Algorithm to fit the parameter") # Floating number specifies fraction of population. cost_function = build_loss_objective(prob1, Tsit5(), L2Loss(t, data), - maxiters = 10000, verbose = false) + maxiters = 1000, verbose = false) N = 1 result, fitness, cnt = ga(cost_function, N; initPopulation = Float64[1.2], @@ -26,7 +26,7 @@ result, fitness, cnt = ga(cost_function, N; @test result[1]≈1.5 atol=3e-1 cost_function = build_loss_objective(prob2, Tsit5(), L2Loss(t, data), - maxiters = 10000) + maxiters = 1000) N = 2 result, fitness, cnt = ga(cost_function, N; initPopulation = Float64[1.2, 2.8], @@ -38,7 +38,7 @@ result, fitness, cnt = ga(cost_function, N; @test result≈[1.5; 3.0] atol=3e-1 cost_function = build_loss_objective(prob3, Tsit5(), L2Loss(t, data), - maxiters = 10000) + maxiters = 1000) N = 4 result, fitness, cnt = ga(cost_function, N; initPopulation = Float64[1.3, 0.8, 2.8, 1.2], diff --git a/test/tests_on_odes/l2_colloc_grad_test.jl b/test/tests_on_odes/l2_colloc_grad_test.jl index 10c8cb7..7c87177 100644 --- a/test/tests_on_odes/l2_colloc_grad_test.jl +++ b/test/tests_on_odes/l2_colloc_grad_test.jl @@ -2,7 +2,7 @@ weight = 1.0e-6 cost_function = build_loss_objective(prob1, Tsit5(), L2Loss(t, data, colloc_grad = colloc_grad(t, data)), - maxiters = 10000, verbose = false) + maxiters = 1000, verbose = false) result = Optim.optimize(cost_function, 1.0, 2.0) @test result.minimizer≈1.5 atol=3e-1 @@ -10,7 +10,7 @@ cost_function = build_loss_objective(prob2, Tsit5(), L2Loss(t, data, differ_weight = weight, data_weight = weight, colloc_grad = colloc_grad(t, data)), - maxiters = 10000, verbose = false) + maxiters = 1000, verbose = false) result = Optim.optimize(cost_function, [1.3, 2.8], Optim.BFGS()) @test result.minimizer≈[1.5; 3.0] atol=3e-1 @@ -18,7 +18,7 @@ cost_function = build_loss_objective(prob3, Tsit5(), L2Loss(t, data, differ_weight = weight, colloc_grad = colloc_grad(t, data)), - maxiters = 10000, verbose = false) + maxiters = 1000, verbose = false) result = Optim.optimize(cost_function, [1.4, 0.9, 2.9, 1.2], Optim.BFGS()) @test result.minimizer≈[1.5, 1.0, 3.0, 1.0] atol=3e-1 @@ -26,6 +26,6 @@ cost_function = build_loss_objective(prob1, Tsit5(), L2Loss(t, data, data_weight = weight, colloc_grad = colloc_grad(t, data)), - maxiters = 10000, verbose = false) + maxiters = 1000, verbose = false) result = Optim.optimize(cost_function, 1.0, 2) @test result.minimizer≈1.5 atol=3e-1 diff --git a/test/tests_on_odes/l2loss_test.jl b/test/tests_on_odes/l2loss_test.jl index 65bcb52..8801217 100644 --- a/test/tests_on_odes/l2loss_test.jl +++ b/test/tests_on_odes/l2loss_test.jl @@ -3,7 +3,7 @@ using BlackBoxOptim, Optim cost_function = build_loss_objective(prob1, Tsit5(), L2Loss(t, data), maxiters = 10000, verbose = false) bound1 = Tuple{Float64, Float64}[(1, 2)] -result = bboptimize(cost_function; SearchRange = bound1, MaxSteps = 11e3) +result = bboptimize(cost_function; SearchRange = bound1, MaxSteps = 1e3) @test result.archive_output.best_candidate[1]≈1.5 atol=3e-1 cost_function = build_loss_objective(prob2, Tsit5(), @@ -11,13 +11,13 @@ cost_function = build_loss_objective(prob2, Tsit5(), data_weight = 1.0), maxiters = 10000, verbose = false) bound2 = Tuple{Float64, Float64}[(1, 2), (1, 4)] -result = bboptimize(cost_function; SearchRange = bound2, MaxSteps = 11e3) +result = bboptimize(cost_function; SearchRange = bound2, MaxSteps = 1e3) @test result.archive_output.best_candidate≈[1.5; 3.0] atol=3e-1 cost_function = build_loss_objective(prob3, Tsit5(), L2Loss(t, data, differ_weight = 10), maxiters = 10000, verbose = false) bound3 = Tuple{Float64, Float64}[(1, 2), (0, 2), (2, 4), (0, 2)] -result = bboptimize(cost_function; SearchRange = bound3, MaxSteps = 11e3) +result = bboptimize(cost_function; SearchRange = bound3, MaxSteps = 1e3) @test result.archive_output.best_candidate≈[1.5; 1.0; 3.0; 1.0] atol=5e-1 cost_function = build_loss_objective(prob3, Tsit5(), @@ -25,5 +25,5 @@ cost_function = build_loss_objective(prob3, Tsit5(), data_weight = 0.7), maxiters = 10000, verbose = false) bound3 = Tuple{Float64, Float64}[(1, 2), (0, 2), (1, 4), (0, 2)] -result = bboptimize(cost_function; SearchRange = bound3, MaxSteps = 11e3) +result = bboptimize(cost_function; SearchRange = bound3, MaxSteps = 1e3) @test result.archive_output.best_candidate≈[1.5; 1.0; 3.0; 1.0] atol=5e-1 diff --git a/test/tests_on_odes/nlopt_test.jl b/test/tests_on_odes/nlopt_test.jl index afd7076..9da6460 100644 --- a/test/tests_on_odes/nlopt_test.jl +++ b/test/tests_on_odes/nlopt_test.jl @@ -3,7 +3,7 @@ using OptimizationNLopt, Zygote println("Use NLOpt to fit the parameter") obj = build_loss_objective(prob1, Tsit5(), L2Loss(t, data), Optimization.AutoZygote(), - maxiters = 10000, verbose = false) + maxiters = 1000, verbose = false) opt = Opt(:LN_COBYLA, 1) optprob = OptimizationNLopt.OptimizationProblem(obj, [1.4]) @@ -14,7 +14,7 @@ opt = Opt(:GN_ESCH, 1) lower_bounds!(opt, [1.0]) upper_bounds!(opt, [3.0]) xtol_rel!(opt, 1e-3) -maxeval!(opt, 10000) +maxeval!(opt, 1000) res = solve(optprob, opt) @test res.u[1]≈1.5 atol=1e-1 @@ -22,17 +22,17 @@ opt = Opt(:GN_ISRES, 1) lower_bounds!(opt, [1.0]) upper_bounds!(opt, [3.0]) xtol_rel!(opt, 1e-4) -maxeval!(opt, 100 - 000) +maxeval!(opt, 1000) res = solve(optprob, opt) @test res.u[1]≈1.5 atol=1e-1 # test differentiation obj = build_loss_objective(prob1, Tsit5(), L2Loss(t, data), Optimization.AutoForwardDiff(); - maxiters = 10000) #zygote behaves weirdly here + maxiters = 1000) #zygote behaves weirdly here opt = Opt(:LD_MMA, 1) xtol_rel!(opt, 1e-3) -maxeval!(opt, 10000) +maxeval!(opt, 1000) optprob = OptimizationNLopt.OptimizationProblem(obj, [1.3]) res = solve(optprob, opt) @test res.u[1]≈1.5 atol=1e-1 diff --git a/test/tests_on_odes/optim_test.jl b/test/tests_on_odes/optim_test.jl index b57141a..f6c5356 100644 --- a/test/tests_on_odes/optim_test.jl +++ b/test/tests_on_odes/optim_test.jl @@ -1,6 +1,6 @@ using Optim, Random obj = build_loss_objective(prob1, Tsit5(), L2Loss(t, data), - maxiters = 10000, verbose = false) + maxiters = 1000, verbose = false) ### Optim Method diff --git a/test/tests_on_odes/regularization_test.jl b/test/tests_on_odes/regularization_test.jl index 9877acc..7edefd1 100644 --- a/test/tests_on_odes/regularization_test.jl +++ b/test/tests_on_odes/regularization_test.jl @@ -2,7 +2,7 @@ using PenaltyFunctions, OptimizationOptimJL, LinearAlgebra, SciMLSensitivity cost_function_1 = build_loss_objective(prob1, Tsit5(), L2Loss(t, data), Optimization.AutoZygote(), - Regularization(0.6, L2Penalty()), maxiters = 10000, + Regularization(0.6, L2Penalty()), maxiters = 1000, verbose = false, abstol = 1e-8, reltol = 1e-8) cost_function_2 = build_loss_objective(prob2, Tsit5(), L2Loss(t, data), Optimization.AutoZygote(), @@ -10,24 +10,24 @@ cost_function_2 = build_loss_objective(prob2, Tsit5(), L2Loss(t, data), MahalanobisPenalty(Matrix(1.0I, 2, 2))), verbose = false, abstol = 1e-8, reltol = 1e-8, - maxiters = 10000) + maxiters = 1000) cost_function_3 = build_loss_objective(prob3, Tsit5(), L2Loss(t, data), Optimization.AutoZygote(), Regularization(0.1, MahalanobisPenalty(Matrix(1.0I, 4, 4))), verbose = false, abstol = 1e-8, reltol = 1e-8, - maxiters = 10000) + maxiters = 1000) println("Use Optim BFGS to fit the parameter") optprob = Optimization.OptimizationProblem(cost_function_1, [1.0]) -result = solve(optprob, Optim.LBFGS()) +result = solve(optprob, Optim.BFGS()) @test result.u[1]≈1.5 atol=3e-1 optprob = Optimization.OptimizationProblem(cost_function_2, [1.2, 2.7]) -result = solve(optprob, Optim.LBFGS()) +result = solve(optprob, Optim.BFGS()) @test result.minimizer≈[1.5; 3.0] atol=3e-1 optprob = Optimization.OptimizationProblem(cost_function_3, [1.3, 0.8, 2.8, 1.2]) -result = solve(optprob, Optim.LBFGS()) +result = solve(optprob, Optim.BFGS()) @test result.minimizer≈[1.5; 1.0; 3.0; 1.0] atol=5e-1 diff --git a/test/tests_on_odes/weighted_loss_test.jl b/test/tests_on_odes/weighted_loss_test.jl index 3acb60a..5641f50 100644 --- a/test/tests_on_odes/weighted_loss_test.jl +++ b/test/tests_on_odes/weighted_loss_test.jl @@ -22,7 +22,7 @@ weighted_data = original_solution_matrix_form + error weighted_cost_function = build_loss_objective(prob1, Tsit5(), L2Loss(t, weighted_data, data_weight = weight), - maxiters = 10000, verbose = false) + maxiters = 1000, verbose = false) opt = Opt(:LN_COBYLA, 1) min_objective!(opt, weighted_cost_function) (minf, minx, ret) = NLopt.optimize(opt, [1.3]) From 756e04b20f178da31748a74ab883aa03af662a49 Mon Sep 17 00:00:00 2001 From: Vaibhav Dixit Date: Mon, 26 Feb 2024 12:13:03 -0500 Subject: [PATCH 09/10] Separate tests to groups --- .github/workflows/CI.yml | 1 + test/runtests.jl | 68 +++++++++++++++++++++------------------- 2 files changed, 37 insertions(+), 32 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index a8e4805..ca008a5 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -16,6 +16,7 @@ jobs: strategy: matrix: group: + - ODEs - All version: - '1' diff --git a/test/runtests.jl b/test/runtests.jl index 0eaad8c..528b474 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,36 +1,40 @@ using DiffEqParamEstim, Test -@time @testset "Tests on ODEs" begin - include("tests_on_odes/test_problems.jl") - include("tests_on_odes/l2loss_test.jl") - include("tests_on_odes/optim_test.jl") - include("tests_on_odes/nlopt_test.jl") - include("tests_on_odes/two_stage_method_test.jl") - include("tests_on_odes/regularization_test.jl") - include("tests_on_odes/blackboxoptim_test.jl") - include("tests_on_odes/weighted_loss_test.jl") - include("tests_on_odes/l2_colloc_grad_test.jl") - #include("tests_on_odes/genetic_algorithm_test.jl") # Not updated to v0.6 -end +const GROUP = get(ENV, "GROUP", "All") -@time @testset "Multiple Shooting Objective" begin - include("multiple_shooting_objective_test.jl") -end -@time @testset "Likelihood Loss" begin - include("likelihood.jl") -end -@time @testset "Out-of-place ODE Tests" begin - include("out_of_place_odes.jl") -end -@time @testset "Steady State Tests" begin - include("steady_state_tests.jl") -end -@time @testset "DAE Tests" begin - include("dae_tests.jl") -end -@time @testset "DDE Tests" begin - include("dde_tests.jl") -end -@time @testset "Test on Monte" begin - include("test_on_monte.jl") +if GROUP == "ODEs" + @time @testset "Tests on ODEs" begin + include("tests_on_odes/test_problems.jl") + include("tests_on_odes/l2loss_test.jl") + include("tests_on_odes/optim_test.jl") + include("tests_on_odes/nlopt_test.jl") + include("tests_on_odes/two_stage_method_test.jl") + include("tests_on_odes/regularization_test.jl") + include("tests_on_odes/blackboxoptim_test.jl") + include("tests_on_odes/weighted_loss_test.jl") + include("tests_on_odes/l2_colloc_grad_test.jl") + #include("tests_on_odes/genetic_algorithm_test.jl") # Not updated to v0.6 + end +else + @time @testset "Multiple Shooting Objective" begin + include("multiple_shooting_objective_test.jl") + end + @time @testset "Likelihood Loss" begin + include("likelihood.jl") + end + @time @testset "Out-of-place ODE Tests" begin + include("out_of_place_odes.jl") + end + @time @testset "Steady State Tests" begin + include("steady_state_tests.jl") + end + @time @testset "DAE Tests" begin + include("dae_tests.jl") + end + @time @testset "DDE Tests" begin + include("dde_tests.jl") + end + @time @testset "Test on Monte" begin + include("test_on_monte.jl") + end end From 95ecfae3085084764ea1ad5d5e82bf79bbbee074 Mon Sep 17 00:00:00 2001 From: Vaibhav Dixit Date: Mon, 26 Feb 2024 15:29:09 -0500 Subject: [PATCH 10/10] fix --- test/runtests.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/runtests.jl b/test/runtests.jl index 528b474..c7814b7 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,4 +1,4 @@ -using DiffEqParamEstim, Test +using DiffEqParamEstim, Test, Optimization, BlackBoxOptim, Optim const GROUP = get(ENV, "GROUP", "All")