From 0c6366cb0d6bfa9dd23dc8e68a86a25bfd1f0738 Mon Sep 17 00:00:00 2001 From: Ewout ter Hoeven Date: Sat, 17 Aug 2024 23:08:09 +0200 Subject: [PATCH] bank_reserves/charts: Don't make Bank an Agent It doesn't have a step function and there is only one, so it shouldn't be an Agent, just an Python object. --- examples/bank_reserves/bank_reserves/agents.py | 9 +++------ examples/bank_reserves/bank_reserves/model.py | 2 +- examples/bank_reserves/batch_run.py | 4 ++-- examples/charts/charts/agents.py | 9 +++------ examples/charts/charts/model.py | 2 +- 5 files changed, 10 insertions(+), 16 deletions(-) diff --git a/examples/bank_reserves/bank_reserves/agents.py b/examples/bank_reserves/bank_reserves/agents.py index 6ff9b8a8..02a4562e 100644 --- a/examples/bank_reserves/bank_reserves/agents.py +++ b/examples/bank_reserves/bank_reserves/agents.py @@ -10,15 +10,12 @@ Northwestern University, Evanston, IL. """ -import mesa - from .random_walk import RandomWalker -class Bank(mesa.Agent): - def __init__(self, unique_id, model, reserve_percent=50): - # initialize the parent class with required parameters - super().__init__(unique_id, model) +class Bank: + def __init__(self, model, reserve_percent=50): + self.model = model # for tracking total value of loans outstanding self.bank_loans = 0 """percent of deposits the bank must keep in reserves - this is set via diff --git a/examples/bank_reserves/bank_reserves/model.py b/examples/bank_reserves/bank_reserves/model.py index 6e5fd3ee..f7aab4cb 100644 --- a/examples/bank_reserves/bank_reserves/model.py +++ b/examples/bank_reserves/bank_reserves/model.py @@ -136,7 +136,7 @@ def __init__( ) # create a single bank for the model - self.bank = Bank(1, self, self.reserve_percent) + self.bank = Bank(self, self.reserve_percent) # create people for the model according to number of people set by user for i in range(self.init_people): diff --git a/examples/bank_reserves/batch_run.py b/examples/bank_reserves/batch_run.py index 9562660f..9b06ce3c 100644 --- a/examples/bank_reserves/batch_run.py +++ b/examples/bank_reserves/batch_run.py @@ -148,8 +148,8 @@ def __init__( agent_reporters={"Wealth": "wealth"}, ) - # create a single bank for the model - self.bank = Bank(1, self, self.reserve_percent) + # create a single bank object for the model + self.bank = Bank(self, self.reserve_percent) # create people for the model according to number of people set by user for i in range(self.init_people): diff --git a/examples/charts/charts/agents.py b/examples/charts/charts/agents.py index 6ff9b8a8..02a4562e 100644 --- a/examples/charts/charts/agents.py +++ b/examples/charts/charts/agents.py @@ -10,15 +10,12 @@ Northwestern University, Evanston, IL. """ -import mesa - from .random_walk import RandomWalker -class Bank(mesa.Agent): - def __init__(self, unique_id, model, reserve_percent=50): - # initialize the parent class with required parameters - super().__init__(unique_id, model) +class Bank: + def __init__(self, model, reserve_percent=50): + self.model = model # for tracking total value of loans outstanding self.bank_loans = 0 """percent of deposits the bank must keep in reserves - this is set via diff --git a/examples/charts/charts/model.py b/examples/charts/charts/model.py index 2a739728..616cf8be 100644 --- a/examples/charts/charts/model.py +++ b/examples/charts/charts/model.py @@ -119,7 +119,7 @@ def __init__( ) # create a single bank for the model - self.bank = Bank(1, self, self.reserve_percent) + self.bank = Bank(self, self.reserve_percent) # create people for the model according to number of people set by user for i in range(self.init_people):