diff --git a/test/optprob_fix.jl b/test/optprob_fix.jl deleted file mode 100644 index f1c218d..0000000 --- a/test/optprob_fix.jl +++ /dev/null @@ -1,29 +0,0 @@ -using Optimization -using ForwardDiff -using LikelihoodProfiler, Plots -using OrdinaryDiffEq - -# objective function -rosenbrock(x,p) = (1.0 - x[1])^2 + 100.0*(x[2] - x[1]^2)^2 - -# initial values -x0 = zeros(2) - -# solving optimization problem -optf = OptimizationFunction(rosenbrock, AutoForwardDiff()) -optprob = OptimizationProblem(optf, x0) -sol = solve(optprob, Optimization.LBFGS()) - -# optimal values of the parameters -optpars = sol.u - -# profile likelihood problem -plprob = PLProblem(optprob, optpars, (-10.,10.); threshold = 4.0) - -method = OptimizationProfiler(optimizer = Optimization.LBFGS(), stepper = FixedStep(; initial_step=0.15)) -sol = profile(plprob, method) -plot(sol, size=(800,350), margin=5Plots.mm) - -method = IntegrationProfiler(integrator = Tsit5(), integrator_opts = (dtmax=0.3,), matrix_type = :hessian) -sol = profile(plprob, method) -plot(sol, size=(800,350), margin=5Plots.mm) \ No newline at end of file diff --git a/test/problems/jak-stat_model.jl b/test/problems/jak-stat_model.jl index 22aa3cb..4e7b8f1 100644 --- a/test/problems/jak-stat_model.jl +++ b/test/problems/jak-stat_model.jl @@ -117,22 +117,3 @@ function jakstat_obj_component(sim,data,σ) end return loss_i end - -#= -optf = OptimizationFunction(loss_func, Optimization.AutoForwardDiff()) -#optf = OptimizationFunction(lsq_func, Optimization.AutoFiniteDiff()) -_prob = OptimizationProblem(optf, p_best, lb=fill(-Inf,p_len), ub=fill(Inf,p_len)) - - -maxiters = 1000 -scan_bounds = (1e-4, 1e4) -Δθ = 0.2 - -identity_profiler = IntegrationProfiler(integrator=FBDF(autodiff=false), matrix_type=:identity, integrator_opts=(reltol=1e-3, abstol=1e-6, adaptive=false, dt=0.1), gamma = 100.) -hess_profiler = IntegrationProfiler(integrator=FBDF(autodiff=false), matrix_type=:hessian, integrator_opts=(reltol=1e-3, abstol=1e-6, adaptive=false, dt=0.1), gamma = 1.) -opt_profiler = OptimizationProfiler(NLopt.LN_NELDERMEAD, (reltol=1e-3,), :fixed, Δθ, maxiters) - -@time opt_prof = profile_parameter(_prob, opt_profiler, 1; scan_bounds, verbose=true) -@time hess_prof = profile_parameter(_prob, hess_profiler, 1; scan_bounds, threashold=threshold, verbose=true) -@time identity_prof = profile_parameter(_prob, identity_profiler, 1; scan_bounds, threashold=threshold, verbose=true) -=# \ No newline at end of file diff --git a/test/problems/taxol_model.jl b/test/problems/taxol_model.jl index 12afe9b..06e95e3 100644 --- a/test/problems/taxol_model.jl +++ b/test/problems/taxol_model.jl @@ -121,63 +121,3 @@ end # https://github.com/marisae/cancer-chemo-identifiability/blob/master/Profile%20Likelihood/testa0_fit.m#L40-L41 sigmasq = (mean([(Cerr005/C005); (Cerr010/C010); (Cerr040/C040); (Cerr100/C100)]))^2 -#= -pid = 2 -maxiters = 1000 -scan_bounds = ((1 - 0.05*14)*p0[pid], (1 + 0.05*60)*p0[pid]) -Δθ = 0.2 - -identity_profiler = IntegrationProfiler(integrator=Rodas4(autodiff=false), matrix_type=:identity, integrator_opts=(reltol=1e-3, abstol=1e-6), gamma = 1.) -hess_profiler = IntegrationProfiler(integrator=Rodas4(autodiff=false), matrix_type=:hessian, integrator_opts=(reltol=1e-3, abstol=1e-6), gamma = 1.) - -opt_profiler0 = OptimizationProfiler(NLopt.LN_NELDERMEAD, (reltol=1e-3,), :fixed, Δθ, maxiters) -opt_profiler1 = OptimizationProfiler(NLopt.LN_NELDERMEAD, (reltol=1e-3,), :linear, Δθ, maxiters) - -@time opt_prof0 = profile_parameter(_prob, opt_profiler0, pid; scan_bounds, threashold=threshold, verbose=true) -@time opt_prof1 = profile_parameter(_prob, opt_profiler1, pid; scan_bounds, threashold=threshold, verbose=true) - -@time hess_prof = profile_parameter(_prob, hess_profiler, pid; scan_bounds, threashold=threshold, verbose=true) -@time identity_prof = profile_parameter(_prob, identity_profiler, pid; scan_bounds, threashold=threshold, verbose=true) - -plot(identity_prof, dpi=400, legend=:top, xlabel="ka", ylabel="L(θ)") -plot!(hess_prof, alpha=0, conf_level=false, steps=false) - -plot(opt_prof0, dpi=400, legend = :bottomleft, xlabel="ka", ylabel="L(θ)") -plot(opt_prof1, dpi=400, legend=:bottomleft, xlabel="ka", ylabel="L(θ)") - -endp = LikelihoodProfiler.ProfileSolution( - nothing, - nothing, - hess_prof.θopt, - [[0., 4.92292246374492, 0., 0., 0.], [0., 10.778706398866387, 0., 0., 0.]], - [hess_prof.flevel, hess_prof.flevel], - 2, - #syms:: - hess_prof.flevel, - nothing, - nothing - -) - -df = CSV.read("./lp_ka.csv", DataFrame) -rename!(df, :f=>:obj) - -ka_full = LikelihoodProfiler.ProfileSolution( - nothing, - nothing, - hess_prof.θopt, - [[df.ka[i]] for i in 1:64], - [df.obj[i] for i in 1:64], - 1, - #syms:: - hess_prof.flevel, - nothing, - nothing - -) - -plot(endp, xticks=[4, 6,7,8,9,10, 4.99, 10.73, 12], xlims=(4.5,11), -dpi=400, legend=:top, xlabel="ka", ylabel="L(θ)", endpoints=true) -scatter!((8.0959,0.538146855), label="optim") -plot!(ka_full, alpha=0.2, conf_level=false) -=# \ No newline at end of file diff --git a/test/test_jak-stat_model.jl b/test/test_jak-stat_model.jl index 0d5b363..a6caa5a 100644 --- a/test/test_jak-stat_model.jl +++ b/test/test_jak-stat_model.jl @@ -69,7 +69,7 @@ end # TODO Fix -@testset "JAK2-STAT5 model. Fixed-step OptimizationProfiler with derivative-free optimizer" begin +@testset "JAK2-STAT5 model. Fixed-step OptimizationProfiler with gradient-based optimizer" begin idxs = 1:9 profile_step(p0, i) = abs(p0[i]) * 0.05