Skip to content

Commit

Permalink
DFlee move rules enforcement of location weights. #81
Browse files Browse the repository at this point in the history
  • Loading branch information
djgroen committed Aug 27, 2023
1 parent 218eb88 commit fe276e5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions flee/moving.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ def getEndPointScore(agent, link) -> float:
base *= 1.0/(max(1.0,link.endpoint.calculateDistance(agent.location))**power_factor)


# DFlee Flood Location Weight implementation
if SimulationSettings.move_rules["FloodRulesEnabled"] is True:
flood_level = link.endpoint.attributes.get("flood_level",0)
if flood_level > 0:
base *= float(SimulationSettings.move_rules["FloodLocWeights"][flood_level])


if link.endpoint.camp is True:
if SimulationSettings.move_rules["MatchCampEthnicity"]:
base *= (spawning.getAttributeRatio(link.endpoint, "ethnicity") * 10.0)
Expand Down
2 changes: 2 additions & 0 deletions tests/test_dflee.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ def test_flood_level_location_attribute():

flee.SimulationSettings.ReadFromYML("empty.yml")
flee.SimulationSettings.move_rules["FloodRulesEnabled"] = True
flee.SimulationSettings.move_rules["FloodLocWeights"] = [0.0,1.0,1.0,1.0,1.0]
flee.SimulationSettings.move_rules["FloodMoveChances"] = [0.0,1.0,1.0,1.0,1.0]

e = flee.Ecosystem()

Expand Down

0 comments on commit fe276e5

Please sign in to comment.