Skip to content

Commit

Permalink
Remove debugginb stuff.
Browse files Browse the repository at this point in the history
  • Loading branch information
TorkelE committed Jul 28, 2020
1 parent bdd30a2 commit 13540b8
Showing 1 changed file with 17 additions and 21 deletions.
38 changes: 17 additions & 21 deletions test/solve_SDEs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,11 @@ end
push!(identical_networks, reaction_networks_constraint[9] => (real_f_3,real_g_3,zeros(7,6)))

for (i,networks) in enumerate(identical_networks)
println(i)
for factor in [1e-1, 1e0, 1e1], repeat in 1:3
println(repeat, " ", factor)
u0 = 100. .+ factor*rand(length(networks[1].states))
p = 0.01 .+ factor*rand(length(networks[1].ps))
(i==2) && (u0[1] += 1000.)
(i==3) ? (p[2:2:6] .*= 1000.; u0 .+= 1000) : (p[1] += 500.)
println(u0)
println(p)
prob1 = SDEProblem(networks[1],u0,(0.,100.),p)
sol1 = solve(prob1,ImplicitEM(),saveat=0.01,maxiters=1e7)
prob2 = SDEProblem(networks[2][1],networks[2][2],u0,(0.,100.),p,noise_rate_prototype=networks[2][3])
Expand All @@ -115,23 +111,23 @@ end
### Compares level of noise with noise scalling. ###

# Tests with a single noise scaling parameter.
#noise_scaling_network = @reaction_network begin
# (k1,k2), X1 ↔ X2
#end k1 k2
#for repeat = 1:5
# p = 1. .+ rand(2)
# u0 = 10000*(1. .+ rand(2))
# sol001 = solve(SDEProblem(noise_scaling_network,u0,(0.,1000.),vcat(p,0.01),noise_scaling=(@variables η1)[1]),ImplicitEM())
# sol01 = solve(SDEProblem(noise_scaling_network,u0,(0.,1000.),vcat(p,0.1),noise_scaling=(@variables η1)[1]),ImplicitEM())
# sol1 = solve(SDEProblem(noise_scaling_network,u0,(0.,1000.),vcat(p,1.),noise_scaling=(@variables η2)[1]),ImplicitEM())
# sol10 = solve(SDEProblem(noise_scaling_network,u0,(0.,1000.),vcat(p,10.),noise_scaling=(@variables η3)[1]),ImplicitEM())
# @test 2*std(first.(sol001.u)[100:end]) < std(first.(sol01.u)[100:end])
# @test 2*std(last.(sol001.u)[100:end]) < std(last.(sol01.u)[100:end])
# @test 2*std(first.(sol01.u)[100:end]) < std(first.(sol1.u)[100:end])
# @test 2*std(last.(sol01.u)[100:end]) < std(last.(sol1.u)[100:end])
# @test 2*std(first.(sol1.u)[100:end]) < std(first.(sol10.u)[100:end])
# @test 2*std(last.(sol1.u)[100:end]) < std(last.(sol10.u)[100:end])
#end
noise_scaling_network = @reaction_network begin
(k1,k2), X1 X2
end k1 k2
for repeat = 1:5
p = 1. .+ rand(2)
u0 = 10000*(1. .+ rand(2))
sol001 = solve(SDEProblem(noise_scaling_network,u0,(0.,1000.),vcat(p,0.01),noise_scaling=(@variables η1)[1]),ImplicitEM())
sol01 = solve(SDEProblem(noise_scaling_network,u0,(0.,1000.),vcat(p,0.1),noise_scaling=(@variables η1)[1]),ImplicitEM())
sol1 = solve(SDEProblem(noise_scaling_network,u0,(0.,1000.),vcat(p,1.),noise_scaling=(@variables η2)[1]),ImplicitEM())
sol10 = solve(SDEProblem(noise_scaling_network,u0,(0.,1000.),vcat(p,10.),noise_scaling=(@variables η3)[1]),ImplicitEM())
@test 2*std(first.(sol001.u)[100:end]) < std(first.(sol01.u)[100:end])
@test 2*std(last.(sol001.u)[100:end]) < std(last.(sol01.u)[100:end])
@test 2*std(first.(sol01.u)[100:end]) < std(first.(sol1.u)[100:end])
@test 2*std(last.(sol01.u)[100:end]) < std(last.(sol1.u)[100:end])
@test 2*std(first.(sol1.u)[100:end]) < std(first.(sol10.u)[100:end])
@test 2*std(last.(sol1.u)[100:end]) < std(last.(sol10.u)[100:end])
end


### Tries to create a large number of problem, ensuring there are no errors (cannot solve as solution likely to go into negatives). ###
Expand Down

0 comments on commit 13540b8

Please sign in to comment.