Skip to content

Commit

Permalink
draft event system II (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
mhinsch committed May 24, 2024
1 parent 5b3eccb commit a888db1
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 18 deletions.
3 changes: 2 additions & 1 deletion mainHelpers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ include("lib/loadLibsPath.jl")

addToLoadPath!(String(@__DIR__) * "/.",
String(@__DIR__) * "/lib",
String(@__DIR__) * "/src")
String(@__DIR__) * "/src",
String(@__DIR__) * "/src/simulate")

using ArgParse

Expand Down
12 changes: 8 additions & 4 deletions src/DemographyModel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,28 @@ include("setup/population.jl")
include("setup/mapPop.jl")
include("setup/mapBenefits.jl")


using Age, Social, TasksCare, Dependencies


include("simulate/allocate.jl")
include("simulate/death.jl")
include("simulate/birth.jl")
include("simulate/divorce.jl")
include("simulate/ageTransition.jl")
include("simulate/socialTransition.jl")
include("simulate/jobtransition.jl")
include("simulate/relocate.jl")
include("simulate/marriages.jl")
include("simulate/dependencies.jl")
include("simulate/socialCareTransition.jl")
include("simulate/care.jl")
include("simulate/income.jl")
include("simulate/jobmarket.jl")
include("simulate/benefits.jl")
include("simulate/wealth.jl")
include("simulate/housing_topdown.jl")
include("simulate/taskscare.jl")


include("demoEvents.jl")


using Utilities

Expand Down
7 changes: 4 additions & 3 deletions src/simulate/events.jl → src/demoEvents.jl
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
using ChangeEvents
using Age
using Dependencies
using TasksCareT
using TasksCare
using Social


function trigger!(c::ChangeAge1Yr, args...)
function ChangeEvents.trigger!(c::ChangeAge1Yr, args...)
process!(c, DependenciesT(), args...)
process!(c, SocialT(), args...)
process!(c, TasksCareT(), args...)
end


function trigger!(c::ChangeStatus, args...)
function ChangeEvents.trigger!(c::ChangeStatus, args...)
process!(c, TasksCareT(), args...)
end
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Dependencies


using Age
using Events
using ChangeEvents


export selectAssignGuardian, assignGuardian!, findFamilyGuardian, findOtherGuardian
Expand Down
6 changes: 3 additions & 3 deletions src/simulate/socialTransition.jl → src/simulate/Social.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ module Social
using Distributions: Normal, LogNormal

using Age
using Events
using ChangeEvents

export socialTransition!, selectSocialTransition
export socialTransition!, selectSocialTransition, SocialCache, changeStatus!
export ChangeStatus, SocialT


Expand All @@ -29,7 +29,7 @@ end

struct SocialT end

function process!(::ChangeAge1Yr, ::SocialT, person, model, pars)
function ChangeEvents.process!(::ChangeAge1Yr, ::SocialT, person, model, pars)
if person.age == pars.ageTeenagers
changeStatus!(person, WorkStatus.teenager, pars)
# all agents first become students, start working in social transition
Expand Down
12 changes: 6 additions & 6 deletions src/simulate/taskscare.jl → src/simulate/TasksCare.jl
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
module TasksCareT
module TasksCare

using Age, Social
using Events

export weeklyCareSupply, availableCareTime, TasksCareT
using ChangeEvents

export weeklyCareSupply, availableCareTime
export TasksCareT

struct TasksCareT end


function process!(::ChangeAge1Yr, ::TasksCareT, person, model, pars)
function ChangeEvents.process!(::ChangeAge1Yr, ::TasksCareT, person, model, pars)
# child ages out of care need this time step
if person.age == pars.stopBabyCareAge || person.age == pars.stopChildCareAge
careNeedChanged!(person, pars)
end
end

function process!(::ChangeStatus, ::TasksCareT, person, oldStatus, pars)
function ChangeEvents.process!(::ChangeStatus, ::TasksCareT, person, oldStatus, pars)
careSupplyChanged!(person, pars)
end

Expand Down

0 comments on commit a888db1

Please sign in to comment.