Skip to content
Open
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from mesa.experimental.cell_space import CellAgent
from mesa.discrete_space import CellAgent


class MoneyAgent(CellAgent):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import mesa
import networkx as nx
from mesa.experimental.cell_space import Network
from mesa.discrete_space import Network
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be "mesa.discrete_space.network import Network"


from .agent import MoneyAgent

Expand All @@ -19,7 +19,16 @@ class BoltzmannWealthModelNetwork(mesa.Model):
def __init__(self, num_agents=10, num_nodes=10):
super().__init__()
self.num_agents = num_agents
self.num_nodes = num_nodes if num_nodes >= self.num_agents else self.num_agents
if self.num_agents > num_nodes:
self.num_nodes = self.num_agents
print("""
╔═══════════════════════════════════ Warning ════════════════════════════════════════╗
║ Number of agents > Number of nodes. ║
║ Since each node can hold only one agent, so num_nodes has been set to num_agents. ║
╚════════════════════════════════════════════════════════════════════════════════════╝
""")
else:
self.num_nodes = num_nodes
self.G = nx.erdos_renyi_graph(n=self.num_nodes, p=0.5)
self.grid = Network(self.G, random=self.random, capacity=1)

Expand Down
2 changes: 1 addition & 1 deletion examples/boltzmann_wealth_model_network/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mesa==3.1.4
mesa
solara
networkx
matplotlib
Expand Down
Loading