From f2e502aaab8c90deeae1633f6e83dfc2d5db71eb Mon Sep 17 00:00:00 2001 From: Astitva Aggarwal Date: Sat, 12 Aug 2023 17:23:39 +0530 Subject: [PATCH] improved Tests --- test/BPINN_Tests.jl | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/test/BPINN_Tests.jl b/test/BPINN_Tests.jl index d0b02abf3..15405036a 100644 --- a/test/BPINN_Tests.jl +++ b/test/BPINN_Tests.jl @@ -69,10 +69,10 @@ luxar = [chainlux(t', θ[i], st)[1] for i in 1:500] luxmean = [mean(vcat(luxar...)[:, i]) for i in eachindex(t)] meanscurve2 = prob.u0 .+ (t .- prob.tspan[1]) .* luxmean -@test mean(abs2.(x̂ .- meanscurve1)) < 5e-4 -@test mean(abs2.(physsol1 .- meanscurve1)) < 1e-5 -@test mean(abs2.(x̂ .- meanscurve2)) < 5e-4 -@test mean(abs2.(physsol1 .- meanscurve2)) < 1e-5 +@test mean(abs.(x̂ .- meanscurve1)) < 0.05 +@test mean(abs.(physsol1 .- meanscurve1)) < 0.005 +@test mean(abs.(x̂ .- meanscurve2)) < 0.05 +@test mean(abs.(physsol1 .- meanscurve2)) < 0.005 println("now parameter estimation problem 1") ## PROBLEM-1 (WITH PARAMETER ESTIMATION) @@ -137,14 +137,14 @@ luxar = [chainlux1(t', θ[i], st)[1] for i in 1:500] luxmean = [mean(vcat(luxar...)[:, i]) for i in eachindex(t)] meanscurve2 = prob.u0 .+ (t .- prob.tspan[1]) .* luxmean -@test mean(abs2.(x̂ .- meanscurve1)) < 5e-4 -@test mean(abs2.(physsol1 .- meanscurve1)) < 5e-5 -@test mean(abs2.(x̂ .- meanscurve2)) < 5e-4 -@test mean(abs2.(physsol1 .- meanscurve2)) < 5e-5 +@test mean(abs.(x̂ .- meanscurve1)) < 5e-2 +@test mean(abs.(physsol1 .- meanscurve1)) < 5e-2 +@test mean(abs.(x̂ .- meanscurve2)) < 5e-2 +@test mean(abs.(physsol1 .- meanscurve2)) < 5e-2 # ESTIMATED ODE PARAMETERS (NN1 AND NN2) -@test abs(p - mean([fhsamples2[i][23] for i in 2000:2500])) < 0.05 -@test abs(p - mean([fhsamples1[i][23] for i in 2000:2500])) < 0.05 +@test abs(p - mean([fhsamples2[i][23] for i in 2000:2500])) < 0.5 +@test abs(p - mean([fhsamples1[i][23] for i in 2000:2500])) < 0.5 ## PROBLEM-2 linear = (u, p, t) -> -u / p[1] + exp(t / p[2]) * cos(t) @@ -237,22 +237,22 @@ yu = [out[i](t') for i in eachindex(out)] fluxmean = [mean(vcat(yu...)[:, i]) for i in eachindex(t)] meanscurve1_1 = prob.u0 .+ (t .- prob.tspan[1]) .* fluxmean -@test mean(abs2.(sol.u .- meanscurve1_1)) < 1e-4 -@test mean(abs2.(physsol1 .- meanscurve1_1)) < 1e-4 +@test mean(abs.(sol.u .- meanscurve1_1)) < 1e-2 +@test mean(abs.(physsol1 .- meanscurve1_1)) < 1e-2 out = re1.([fhsamplesflux22[i][1:61] for i in 1000:1500]) yu = [out[i](t') for i in eachindex(out)] fluxmean = [mean(vcat(yu...)[:, i]) for i in eachindex(t)] meanscurve1_2 = prob.u0 .+ (t .- prob.tspan[1]) .* fluxmean -@test mean(abs2.(sol.u .- meanscurve1_2)) < 5e-3 -@test mean(abs2.(physsol1 .- meanscurve1_2)) < 5e-3 +@test mean(abs.(sol.u .- meanscurve1_2)) < 5e-2 +@test mean(abs.(physsol1 .- meanscurve1_2)) < 5e-2 # estimated parameters(flux chain) param1 = mean(i[62] for i in fhsamplesflux22[1000:1500]) param2 = mean(i[63] for i in fhsamplesflux22[1000:1500]) -@test abs(param1 - p[1]) < abs(0.2 * p[1]) -@test abs(param2 - p[2]) < abs(0.2 * p[2]) +@test abs(param1 - p[1]) < abs(0.3 * p[1]) +@test abs(param2 - p[2]) < abs(0.3 * p[2]) # Mean of last 500 sampled parameter's curves(lux chains)[Ensemble predictions] θ = [vector_to_parameters(fhsampleslux12[i], θinit) for i in 1000:1500] @@ -260,19 +260,19 @@ luxar = [chainlux12(t', θ[i], st)[1] for i in 1:500] luxmean = [mean(vcat(luxar...)[:, i]) for i in eachindex(t)] meanscurve2_1 = prob.u0 .+ (t .- prob.tspan[1]) .* luxmean -@test mean(abs2.(sol.u .- meanscurve2_1)) < 2e-4 -@test mean(abs2.(physsol1 .- meanscurve2_1)) < 2e-4 +@test mean(abs.(sol.u .- meanscurve2_1)) < 1e-2 +@test mean(abs.(physsol1 .- meanscurve2_1)) < 1e-2 θ = [vector_to_parameters(fhsampleslux22[i][1:(end - 2)], θinit) for i in 1000:1500] luxar = [chainlux12(t', θ[i], st)[1] for i in 1:500] luxmean = [mean(vcat(luxar...)[:, i]) for i in eachindex(t)] meanscurve2_2 = prob.u0 .+ (t .- prob.tspan[1]) .* luxmean -@test mean(abs2.(sol.u .- meanscurve2_2)) < 2e-2 -@test mean(abs2.(physsol1 .- meanscurve2_2)) < 2e-2 +@test mean(abs.(sol.u .- meanscurve2_2)) < 5e-2 +@test mean(abs.(physsol1 .- meanscurve2_2)) < 5e-2 # estimated parameters(lux chain) param1 = mean(i[62] for i in fhsampleslux22[1000:1500]) param2 = mean(i[63] for i in fhsampleslux22[1000:1500]) -@test abs(param1 - p[1]) < abs(0.35 * p[1]) -@test abs(param2 - p[2]) < abs(0.35 * p[2]) \ No newline at end of file +@test abs(param1 - p[1]) < abs(0.3 * p[1]) +@test abs(param2 - p[2]) < abs(0.3 * p[2]) \ No newline at end of file