Commit b6004ca0 authored by Victor's avatar Victor
Browse files

multiple reflections are now supported!

parent 66637f59
......@@ -107,18 +107,17 @@ function increment_x!(a::Agent{Float64},p::Dict)
"""
get_inc_reflected(x::Float64,inc::Float64,s=-1,e=1)
Here we increment the trajectory of trait 1 such that it follows a reflected brownian motion (1D)
Careful though, we do not implement reflections
"""
function get_inc_reflected(x::Float64,inc::Float64,s=-1,e=1)
if x + inc < s
return 2 * ( s - x ) - inc
inc = 2 * ( s - x ) - inc
elseif x + inc > e
return 2 * ( e - x ) - inc
inc = 2 * ( e - x ) - inc
else
return inc
end
get_inc_reflected(x,inc,s,e)
end
# need to make sure that this is working correctly
......
......@@ -4,4 +4,11 @@ using ABMEv, Test, JLD2,Random
include("gillepsie.jl")
include("wrightfisher.jl")
include("metrics.jl")
# we might want to put this in a separate file at some point
@testset "Reflection" begin
@test get_inc_reflected(0.,2.0) .0
@test get_inc_reflected(0.,-2.0) .0
@test get_inc_reflected(0.,4.0) .0
@test get_inc_reflected(0.,1.1) 1 - .1
end
end
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment