Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds real metrics for diseases to the log #115

Open
wants to merge 53 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
84c84a4
Adds metrics for diseases in a separate log file
amuller26 Jul 29, 2024
b732c1c
Removes checkActiveDiseases function
amuller26 Jul 30, 2024
6374aa4
Adds function to check for infected agents
amuller26 Jul 30, 2024
b3d9ca8
Adds disease r metrics to logfile
amuller26 Aug 2, 2024
63af412
Modifies disease naming scheme for runtime stats
amuller26 Aug 2, 2024
fa5f20d
Adds metrics for incidence and prevalence
amuller26 Aug 2, 2024
c9405d3
Adds feature to initialize diseases at different timesteps
amuller26 Aug 8, 2024
2b210fb
Fixes sort line error
amuller26 Aug 8, 2024
82c478e
Adds disease stats to main log
amuller26 Aug 8, 2024
b6f5c8c
Adds immune agents disease stat to log
amuller26 Aug 9, 2024
0770f59
Fixes config.json to be the standard config
amuller26 Aug 10, 2024
61af5e2
Adds agentDiseaseProtectionChance to reduce disease infections
amuller26 Aug 12, 2024
d1ba819
Fixes initial disease so it can still infect an agent with complete i…
amuller26 Aug 13, 2024
3afe38c
Removes function to check for active diseases
amuller26 Aug 13, 2024
9725dd9
Adds agent behavior to avoid infected agents
amuller26 Aug 14, 2024
1fa3e8f
Modifies disease initialization so it doesn't infect completely immun…
amuller26 Aug 14, 2024
4c35a91
Modifies disease death stat to count any diseased agents upon death
amuller26 Aug 15, 2024
4056917
Adds disease transmission chance feature
amuller26 Aug 16, 2024
7e0faee
Adds disease incubation period
amuller26 Aug 17, 2024
bfe9c9f
Adds agent reactions to incubation periods
amuller26 Aug 17, 2024
50b3206
Adds new config options to the README
amuller26 Aug 18, 2024
55a92c1
Modified isSick so it only sees symptomatic diseases
amuller26 Aug 18, 2024
a10b51f
Adds boolean function to see if an agent can get infected
amuller26 Aug 20, 2024
b2c06a8
Modifies agent fields
amuller26 Aug 20, 2024
a93bdc5
Adds disease protection to child endowment
amuller26 Aug 20, 2024
e9ce0bf
Modifies checking if agent is already infected
amuller26 Aug 20, 2024
0abc5c0
Removes extra lines of code
amuller26 Aug 20, 2024
cf47939
Fixes disease effects modify agent after incubation
amuller26 Aug 21, 2024
780ee4e
Modfies code for correctness and readability
amuller26 Aug 22, 2024
5be7c08
Modifies disease transmission and protection to be between 0 and 1
amuller26 Aug 23, 2024
afd1d1a
Updates README entries
amuller26 Aug 23, 2024
b5d87db
Adds feature where agent protection gradually lowers after infertilit…
amuller26 Aug 23, 2024
a5a3420
Modifies agent behavior to avoid sick agents
amuller26 Aug 23, 2024
7333ae7
Merge branch 'master' into add-disease
amuller26 Aug 23, 2024
90c30c8
Adds 'diseases' label to agent data gui
amuller26 Aug 23, 2024
927efef
Merge branch 'add-disease' of github.com:amuller26/sugarscape into ad…
amuller26 Aug 23, 2024
bb5b7c1
Modifies default protection and transmission values
amuller26 Aug 24, 2024
1840e26
Merge branch 'master' into add-disease
amuller26 Aug 24, 2024
212d3d9
Fixes merge with master
amuller26 Aug 24, 2024
1e382d6
Fixes merge that removed an agent function
amuller26 Sep 6, 2024
8f51bf5
Fixes randomizeDiseaseEndowments duplication
amuller26 Sep 25, 2024
6a9332d
Comments out agent quarantine behavior
amuller26 Sep 27, 2024
75cd7be
Merge branch 'master' into add-disease
amuller26 Sep 27, 2024
78b435a
Removes agent quarantine feature
amuller26 Oct 2, 2024
1bd7b17
Modifies disease prevalence metric to include incubating diseases
amuller26 Oct 2, 2024
b35399c
Removes isPreyInfected function
amuller26 Oct 14, 2024
2feb3ee
Adds agent.recoveredDiseases list
amuller26 Nov 8, 2024
df9443b
Modifies infected variable to newInfections
amuller26 Nov 13, 2024
8fca89e
Adds disease groups to agents
amuller26 Nov 15, 2024
55f4f5f
Merge branch 'master' into add-disease
amuller26 Nov 15, 2024
32bb035
Updated log with new metrics
amuller26 Nov 18, 2024
a3a58d5
Merge with master
amuller26 Nov 18, 2024
8873214
Merge with updated PR
amuller26 Nov 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,11 @@ agentDepressionPercentage: float
Note: The starting agent population will have this same percentage of depressed agents.
Default: 0.0

agentDiseaseProtectionChance: [float, float]
Sets the chance an agent can get infected by another agent.
Note: a value of 0.0 mean no protection, while a value of 1.0 means complete protection
Default: [0.0, 1.0]

agentFemaleInfertilityAge: [int, int]
Set the timestep age at which female agents become infertile.
Default: [0, 0]
Expand Down Expand Up @@ -301,6 +306,10 @@ diseaseFertilityPenalty: [float, float]
Note: Negative values constitute a fertility decrease.
Default: [0, 0]

diseaseIncubationPeriod: [int, int]
Set the number of timesteps a disease can remain hidden while still infecting other agents.
Default: [0, 0]

diseaseMovementPenalty: [int, int]
Set the impact a disease will have on an agent's movement distance.
Note: Negative values constitute a decrease in movement range.
Expand All @@ -311,6 +320,10 @@ diseaseSpiceMetabolismPenalty: [float, float]
Note: Negative values constitute a decrease in agent spice metabolism.
Default: [0, 0]

diseaseStartTimeframe: [int, int]
Set the timestep a disease can be initialized.
Default: [0, 0]

diseaseSugarMetabolismPenalty: [float, float]
Set the impact a disease will have on an agent's sugar metabolism rate.
Note: Negative values constitute a decrease in agent sugar metabolism.
Expand All @@ -321,6 +334,10 @@ diseaseTagStringLength: [int, int]
The longer the length, the longer an agent will have the disease.
Default: [0, 0]

diseaseTransmissionChance: [float, float]
Set the chance a disease can transmit between agents.
Default: [0.0, 1.0]

diseaseVisionPenalty: [int, int]
Set the impact a disease will have on an agent's vision.
Note: Negative values constitute a decrease in agent vision.
Expand Down
196 changes: 138 additions & 58 deletions agent.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion cell.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import math

class Cell:
def __init__(self, x, y, environment, maxSugar=0, maxSpice=0, growbackRate=0):
def __init__(self, x, y, environment, maxSugar=0, maxSpice=0):
self.x = x
self.y = y
self.environment = environment
Expand Down
8 changes: 6 additions & 2 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"agentDecisionModelLookaheadFactor": 0,
"agentDecisionModelTribalFactor": [-1, -1],
"agentDepressionPercentage": 0,
"agentDiseaseProtectionChance": [0.0, 1.0],
"agentFemaleInfertilityAge": [40, 50],
"agentFemaleFertilityAge": [12, 15],
"agentFertilityFactor": [1, 1],
Expand Down Expand Up @@ -51,10 +52,13 @@
"debugMode": ["none"],
"diseaseAggressionPenalty": [-1, 1],
"diseaseFertilityPenalty": [-1, 1],
"diseaseIncubationPeriod": [0,10],
"diseaseMovementPenalty": [0, 0],
"diseaseSpiceMetabolismPenalty": [1, 3],
"diseaseSugarMetabolismPenalty": [1, 3],
"diseaseStartTimeframe": [0, 0],
"diseaseTagStringLength": [11, 21],
"diseaseTransmissionChance": [0.0, 1.0],
"diseaseVisionPenalty": [-1, 1],
"environmentEquator": -1,
"environmentHeight": 50,
Expand Down Expand Up @@ -87,8 +91,8 @@
"interfaceHeight": 1000,
"interfaceWidth": 900,
"keepAlivePostExtinction": false,
"logfile": "log.json",
"logfileFormat": "json",
"logfile": "log.csv",
"logfileFormat": "csv",
"neighborhoodMode": "vonNeumann",
"profileMode": false,
"screenshots": false,
Expand Down
10 changes: 10 additions & 0 deletions disease.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,21 @@ def __init__(self, diseaseID, configuration):
self.configuration = configuration
self.aggressionPenalty = configuration["aggressionPenalty"]
self.fertilityPenalty = configuration["fertilityPenalty"]
self.incubationPeriod = configuration["incubationPeriod"]
self.movementPenalty = configuration["movementPenalty"]
self.spiceMetabolismPenalty = configuration["spiceMetabolismPenalty"]
self.sugarMetabolismPenalty = configuration["sugarMetabolismPenalty"]
self.tags = configuration["tags"]
self.transmissionChance = configuration["transmissionChance"]
self.visionPenalty = configuration["visionPenalty"]

self.newInfections = 0
self.infectors = set()
self.startingInfectedAgents = 0

def resetRStats(self):
self.newInfections = 0
self.infectors = set()

def __str__(self):
return f"{self.ID}"
6 changes: 4 additions & 2 deletions gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ def configureButtons(self, window):

statsLabel = tkinter.Label(window, text=self.defaultSimulationString, font="Roboto 10", justify=tkinter.CENTER)
statsLabel.grid(row=1, column=0, columnspan=self.menuTrayColumns, sticky="nsew")
# need to add diseases to default agent string
cellLabel = tkinter.Label(window, text=f"{self.defaultCellString}\n{self.defaultAgentString}", font="Roboto 10", justify=tkinter.CENTER)
cellLabel.grid(row=2, column=0, columnspan=self.menuTrayColumns, sticky="nsew")

Expand Down Expand Up @@ -476,7 +477,7 @@ def drawLines(self):
elif self.activeNetwork.get() == "Disease":
for agent in self.sugarscape.agents:
if agent.isSick() == True:
for diseaseRecord in agent.diseases:
for diseaseRecord in agent.symptomaticDiseases:
# Starting diseases without an infector are not considered
if "infector" not in diseaseRecord:
continue
Expand Down Expand Up @@ -596,7 +597,7 @@ def lookupFillColor(self, cell):
elif self.activeColorOptions["agent"] == "Depression":
return self.colors["sick"] if agent.depressed == True else self.colors["healthy"]
elif self.activeColorOptions["agent"] == "Disease":
return self.colors["sick"] if len(agent.diseases) > 0 else self.colors["healthy"]
return self.colors["sick"] if agent.isSick() else self.colors["healthy"]
elif self.activeColorOptions["agent"] == "Metabolism":
return self.colors["metabolism"][agent.sugarMetabolism + agent.spiceMetabolism]
elif self.activeColorOptions["agent"] == "Movement":
Expand Down Expand Up @@ -679,6 +680,7 @@ def updateHighlightedCellStats(self):
agentStats = f"Agent: {str(agent)} | Age: {agent.age} | Vision: {round(agent.findVision(), 2)} | Movement: {round(agent.findMovement(), 2)} | "
agentStats += f"Sugar: {round(agent.sugar, 2)} | Spice: {round(agent.spice, 2)} | "
agentStats += f"Metabolism: {round(((agent.findSugarMetabolism() + agent.findSpiceMetabolism()) / 2), 2)} | Decision Model: {agent.decisionModel} | Tribe: {agent.tribe}"
# add disease to end
else:
agentStats = self.defaultAgentString
cellStats += f"\n{agentStats}"
Expand Down
Loading