Skip to content
Snippets Groups Projects
abm.jl 1.18 KiB

const population = 14.57e6 #population of ontario
const workschool_mixing, rest_mixing = load_mixing_matrices()
const age_bins = [(0.0, 25.0),(25.0,65.0),(65.0,Inf)]  
const household_data = read_household_data()
default(dpi = 300)
default(framestyle = :box)
import LightGraphs.neighbors
export DebugRecorder,mean_solve,plot_model, get_parameters
"""
    bench()

Runs the model with default parameters.
"""
function bench()
    p = get_parameters()
    model_sol = ModelSolution(p.sim_length,p,p.num_households)
    recording = DebugRecorder(p.sim_length)
    output = solve!(model_sol,recording)
    return recording
end


"""
Runs the model 8 times using all threads.
"""
function threaded_bench()
    ThreadsX.map(t -> bench(),1:8)
end


"""
Runs the model 8 times using processes.
"""
function dist_bench()
    pmap(t -> bench(),1:8)
end

"""
Run the model with given parameter tuple and output recorder. See `get_parameters` for list of parameters. See `output.jl` for the list of recorders. Currently just 'DebugRecorder`.
"""
function abm(parameters, recorder)
    model_sol = ModelSolution(parameters.sim_length,parameters,5000)
    output = solve!(model_sol,recorder )
    return model_sol
end