Skip to content

Commit

Permalink
make boltzmann-wealth-model standards-compliant
Browse files Browse the repository at this point in the history
  • Loading branch information
djmitche committed May 14, 2018
1 parent 3c69896 commit 8ddf2cb
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ def compute_gini(model):
return (1 + (1 / N) - 2 * B)


class MoneyModel(Model):
class BoltzmannWealthModel(Model):
"""A simple model of an economy where agents exchange currency at random.
All the agents begin with one unit of currency, and each time step can give
a unit of currency to another agent. Note how, over time, this produces a
highly skewed distribution of wealth.
"""

def __init__(self, N, width, height):
def __init__(self, N=100, width=10, height=10):
self.num_agents = N
self.grid = MultiGrid(height, width, True)
self.schedule = RandomActivation(self)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from mesa.visualization.ModularVisualization import ModularServer
from .model import MoneyModel
from .model import BoltzmannWealthModel

from mesa.visualization.modules import CanvasGrid
from mesa.visualization.modules import ChartModule
Expand Down Expand Up @@ -34,5 +34,5 @@ def agent_portrayal(agent):
"height": 10
}

server = ModularServer(MoneyModel, [grid, chart], "Money Model", model_params)
server = ModularServer(BoltzmannWealthModel, [grid, chart], "Money Model", model_params)
server.port = 8521
2 changes: 1 addition & 1 deletion examples/boltzmann_wealth_model/run.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from wealth_model.server import server
from boltzmann_wealth_model.server import server

server.launch()
6 changes: 0 additions & 6 deletions tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,6 @@ def test_examples(self):
model = Model()
(model.step() for _ in range(100))

def test_boltzmann_wealth_model(self):
with self.active_example_dir('boltzmann_wealth_model'):
from wealth_model.model import MoneyModel
model = MoneyModel(100, 20, 20)
(model.step() for _ in range(100))

def test_boltzmann_wealth_model_network(self):
with self.active_example_dir('boltzmann_wealth_model_network'):
from wealth_model.model import MoneyModel
Expand Down

0 comments on commit 8ddf2cb

Please sign in to comment.