I am currently trying to write some code to simulate a Lotka-Volterra model about a population of preyes and predators.
I have written this code:
function PP_gen(N_prey::Int128, N_pred::Int128, max_time::Int128, λ_breed::Float64, λ_interaction::Float64, λ_death::Float64)::Vector{Int128}
Prey_list = Vector{Int128}([N_prey])
Pred_list = Vector{Int128}([N_pred])
t = 1
while t < max_time
t += 1
new_Prey = Int128(0)
new_Pred = Int128(0)
breed = Int128(rand(Binomial(N_prey, λ_breed)));
new_Prey = breed
interaction = Int128(rand(Binomial(N_pred, λ_interaction)));
new_Pred = interaction
new_Prey -= interaction
death = Int128(rand(Binomial(N_pred, λ_death)));
new_Pred -= death
N_prey += new_Prey
N_pred += new_Pred
if N_prey <= 0
push!(Prey_list, 0);
push!(Pred_list, N_pred)
return Prey_list, Pred_list
end
if N_pred <= 0
push!(Pred_list, 0);
push!(Prey_list, N_prey)
return Prey_list, Pred_list
end
push!(Prey_list, N_prey)
push!(Pred_list, N_pred)
end
return Prey_list, Pred_list
end
I need to try a high number of iteration (for example 1000) but I can only manage to obtain the variables Prey_list and Pred_list as Vector{Int64}, which is a problem since Int64 incurs in stack overflow too soon. How can I manage to obtain an object of the type Vector{Int128}?