Complexity Explorer Santa Few Institute

Introduction to Renormalization

Lead instructor: Simon DeDeo

Your progress is not being saved! Enroll now or log in to track your progress or submit homework.

All posts

Rosa Brand
07 Jan 2025 2:24pm UTC
2
in Lecture: What is Complexity?

Thanks for this helpful lecture. I had a question regarding David's discussion on dynamical sufficiency. He mentions that "every single level is necessary and sufficient to predict its own future". I understand the argument on sufficiency (and he goes into this in quite a bit of detail), but I'm not sure I follow regarding the necessity. Are we saying that we can not predict the system's future by looking at the level below, but have to look at the emergent level? Wouldn't this imply that there is some inconsistency between both levels, ie something is "added" to the system at the higher level that does not exist at the level below and therefore predictions at the lower level will be wrong? Or are we saying prediction is simply not possible at the lower level (perhaps because of computational complexity given the multiple variables)? Thanks a lot in advance!

Simon Crase
19 Feb 2025 9:32pm UTC
in Lecture: What is Complexity?

Rosa, I wonder about sensitive dependence on initial conditions. Imagine what would happen if we were playing tennis. Suppose that you have just hit the ball towards my end of the court, and you were wondering what I will do with it. Imagine that you know the position and velocity of every atom in my body, my tennis racquet and the ball; can you predict the impact on the ball, and its future trajectory? OTOH, assuming you are an experienced player, can you do a better job at the emergent level of tennis? I'm sure you could...

Rosa Brand
21 Feb 2025 3:56pm UTC
in Lecture: What is Complexity?

Thanks a lot Simon! I'm not a physicist and am appalling at tennis so want to make sure I understand this correctly :) If i use the weather/climate as an example, are we saying that:
(1) the lower level exhibits sensitive dependence on initial conditions, but the emergent level does not; ie we cannot predict the weather but we can predict the climate (which is just the average weather over larger areas and longer periods)? This would be a pretty meaningful finding because it would mean that we can "trick" a chaotic system into becoming predictable by looking at the macro rather than micro level, right?
Or are we saying that:
(2) the system as a whole (irrespective of which level you look at) exhibits sensitive dependence on initial conditions, but we can look at the patterns of the attractor over time and thus make some general predictions on the behavior of the system. Ie we can't predict the weather, but we can make informed statements on how the climate is likely to change over time based on certain variables.
Thanks again!

Tom Youngman
16 Oct 2024 3:16pm UTC
10
in Agent-Based Models with Python: An Introduction to Mesa

I'm running the code as shown in session 5 but getting the follow error - any ideas?

---------------------------------------------------------------------------

ValueError Traceback (most recent call last)

in ()
----> 1 model = SugarscapeG1mt()

in __init__(self, width, height)
19
20 agent_id = 0
---> 21 for (x,y) in self.grid.coord_iter():
22 max_sugar = sugar_distribution[x,y]
23 if max_sugar > 0:

ValueError: too many values to unpack (expected 2)

Tom Youngman
16 Oct 2024 3:44pm UTC
in Agent-Based Models with Python: An Introduction to Mesa

I've not figured out the error:
for _,(x,y) in self.grid.coord_iter():

needs the brackets around (x,y) removed to become:
for _,x,y in self.grid.coord_iter():

I have forked the session 5 on GitHub and suggested the change

Eka Putri Difayanti
10 Nov 2024 10:37pm UTC
in Agent-Based Models with Python: An Introduction to Mesa

I have the same problem. Did you find a solution?

Kai Greenlees
26 Nov 2024 12:18pm UTC
in Agent-Based Models with Python: An Introduction to Mesa

I've had the same problem as well, did anyone come across a solution?

Tom Youngman
26 Nov 2024 12:21pm UTC
in Agent-Based Models with Python: An Introduction to Mesa

Did this fix not work?
for _,(x,y) in self.grid.coord_iter():

needs the brackets around (x,y) removed to become:
for _,x,y in self.grid.coord_iter():

Kai Greenlees
26 Nov 2024 12:56pm UTC
in Agent-Based Models with Python: An Introduction to Mesa

Hi Tom, actually I am struggling with another issue when I try to run the last step in the fifth session I get this error about the number of arguments being incorrect with the __init__() function in the Sugar agent parameters, but the code I've used is a direct copy of the Session 5 code provided. Any thoughts on how to troubleshoot would be greatly appreciated. I am new to Python & ABM so the syntax is still new to me

Error message:
TypeError Traceback (most recent call last)
in ()
----> 1 model = SugarscapeG1mt()

2 frames
/usr/local/lib/python3.10/dist-packages/mesa/agent.py in __init__(self, model, *args, **kwargs)
62
63 """
---> 64 super().__init__(*args, **kwargs)
65
66 self.model: Model = model

TypeError: object.__init__() takes exactly one argument (the instance to initialize)

Martina Umlauft
04 Dec 2024 12:54pm UTC
in Agent-Based Models with Python: An Introduction to Mesa

Hi Kai,
the problem is that in the current version of Mesa the mesa.Agent does not take the unique_id argument anymore. You do not set the id anymore, the agents do that themselves when they are created. So, when you call super().__init__(...) in your Sugar class, it should NOT pass the unique_id as an argument. If you do that, python thinks this is not for mesa.Agent - becase mesa.Agent's constructor doesn't take that argument anymore - and searches up the class hierarchy for a class that has a constructor that takes both, the unique_id and model as arguments. And then ends up at the top level of the class hierarchy at object - which also takes only one argument.
It took me a while to understand what was going on there (also because the AI generated "explain this error" explanations were simply wrong). I tried installing a older versions of Mesa but couldn't find the correct one - when I tried the versions mentioned in the first videos - 0.8 and 1.1 other stuff broke, like mesa.space.MultiGrid... idk what version they are really using for this tutorial.

Anyway, the solution to fix this is to do just
super().__init__(model)
in your Sugar class and to not do anything with this unique_id and agent_id. That stuff is automatic in the agent now.

You also need to do this in your SugarscapeG1mt model class now:

def __init__(self, width=50, height=50):
# Initialize the random number generator
self.random = np.random.default_rng(seed=123) # set seed

because these when these agents now try to register with the model, the model needs to have a random generator.

In an ideal world, they'd update the tutorial to reflect the changes but I'd be already happy if anybody could tell me what version of mesa the tutorial is supposed to use because it seems a lot has changed and it does NOT work with the versions they mentioned (0.8. and 1.1 respectively) either.

Peter Breithaupt
16 Jan 2025 10:19pm UTC
in Agent-Based Models with Python: An Introduction to Mesa

Hi, I could solve the issues of tutorial 5.1 and happy to share to code which works for Mesa 3.1.3. Unfortunately, the console is still receiving Warnings "UserWarning: Agent 4138 is being placed with place_agent() despite already having the position (49, 29). In most cases, you'd want to clear the current position with remove_agent() before placing the agent again.
I wrote a 2 path test including remove_agent(), unfortunately no improvement. I am stuck.
Let me know where I can share code (Github)? or should I raise an issue on Github?

ASfozx
31 Jan 2025 9:26pm UTC
in Agent-Based Models with Python: An Introduction to Mesa

Hi everyone,

I'm struggling with the last part of the session 5. I was having the same issue as Kai and made the correction suggested by Martina but I'm having this problema right now:

Sugar class

class Sugar(mesa.Agent):
def __init__(self, unique_id, model, pos, max_sugar):
super().__init__(model)
self.pos = pos
self.amount = max_sugar
self.max_sugar = max_sugar

Model class

class SugarscapeG1mt(mesa.Model):

def __init__(self, width = 50, height = 50):

self.width = width
self.height = height

self.random = np.random.default_rng(seed=123) # set seed
self.grid = mesa.space.MultiGrid(self.width, self.height, torus = False)

sugar_distribution = np.genfromtxt("sugar-map.txt")
spice_distribution = np.flip(sugar_distribution, 1)

agent_id = 0
for _, (x,y) in self.grid.coord_iter():
max_sugar = sugar_distribution[x,y]
if max_sugar > 0:
sugar = Sugar(agent_id, self, (x,y), max_sugar)
self.grid.place_agent(sugar, (x,y))
agent_id += 1

for _, (x,y) in self.grid.coord_iter():
print(_, (x,y))

And I receive this error when running the model:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
in ()
----> 1 model = SugarscapeG1mt()

3 frames
/usr/local/lib/python3.11/dist-packages/mesa/model.py in register_agent(self, agent)
156
157 """
--> 158 self._agents[agent] = None
159
160 # because AgentSet requires model, we cannot use defaultdict

AttributeError: 'SugarscapeG1mt' object has no attribute '_agents'

Does someone knows how to fix it??

ASfozx
31 Jan 2025 9:30pm UTC
in Agent-Based Models with Python: An Introduction to Mesa

Mesa version: 3.1.3

Zaidibeth
21 Feb 2025 3:14pm UTC
in Agent-Based Models with Python: An Introduction to Mesa

This is how the code should be

class Sugar(mesa.Agent):
def __init__(self, unique_id, model, pos, max_sugar):
super().__init__(model)
self.pos = pos
self.amount = max_sugar
self.max_sugar = max_sugar

class SugarScapeG1mt(mesa.Model):
def __init__(self, width=50, height=50):
super().__init__()
self.width = width
self.height = height
self.grid = mesa.space.MultiGrid(self.width, self.height, torus=False)

# read in landscape file from supplementary material
sugar_distribution = np.genfromtxt('sugar-map.txt')
spice_distribution = np.flip(sugar_distribution, 1)

agent_id = 0
for _, (x, y) in self.grid.coord_iter():
max_sugar = sugar_distribution[x][y]
if max_sugar > 0:
sugar = Sugar(agent_id, self, (x, y), max_sugar)
agent_id += 1

for _, (x,y) in self.grid.coord_iter():
print(_, (x, y))

The issue is that when you instantiate the sugar agent, you are already giving it a position on the grid, and if you place it somewhere else, or in the same place, you accidentally are creating 2 agents in the same place. If you want to move the agent, you have to use the move function. I hope this helps!

Geoff Evamy Hill
16 Oct 2024 11:21am UTC
2
in Agent-Based Models with Python: An Introduction to Mesa

Hi there,
I am getting this error when I run the code from step 7.
"""
self.grid.place_agent(trader, (x,y))
:83: UserWarning: Agent 4139 is being placed with
place_agent() despite already having the position (30, 30). In most
cases, you'd want to clear the current position with remove_agent()
before placing the agent again.
"""

It seems to happen with the code from the github as well. Any ideas?

Zhaohan
28 Nov 2024 12:41am UTC
in Agent-Based Models with Python: An Introduction to Mesa

Hi Geoff,
place_agent method checks whether the agent already has a position before placing it. You could simply solve this issue by setting pos = None when creating a new agent. Here is the source code.
@warn_if_agent_has_position_already
def place_agent(self, agent: Agent, pos: Coordinate) -> None:
"""Place the agent at the specified location, and set its pos variable."""
x, y = pos
if agent.pos is None or agent not in self._grid[x][y]:
self._grid[x][y].append(agent)
agent.pos = pos
if self._empties_built:
self._empties.discard(pos)
self._empty_mask[agent.pos] = True

Martina Umlauft
04 Dec 2024 1pm UTC
in Agent-Based Models with Python: An Introduction to Mesa

Hi Geoff,
the current version of Mesa seems to do quite a bit of things differently to the version they used for the tutorial. I just commented out the call to place_agent() because the x,y coordinates are already given when you instantiate the agent. So, I basically just did it like this:
for _,(x,y) in self.grid.coord_iter():
max_sugar = sugar_distribution[x,y]
if max_sugar > 0:
sugar = Sugar(self, (x,y), max_sugar) # already placed
#self.grid.place_agent(sugar, (x,y)) # do NOT re-place without removing from old location
print(sugar.unique_id, sugar.pos, sugar.max_sugar)

Juhi
05 Nov 2024 5:24pm UTC
in Random Walks

COVID-19, caused by the novel coronavirus SARS-CoV-2, emerged in Wuhan, China, in late 2019 and quickly became a global pandemic. The disease primarily affects the respiratory system, causing symptoms ranging from mild (fever, cough, and fatigue) to severe (pneumonia, difficulty breathing, and organ failure). Older adults and individuals with underlying health conditions are at higher risk of severe illness.

COVID-19 spreads mainly through respiratory droplets when an infected person coughs, sneezes, or talks. It can also spread by touching surfaces contaminated with the virus and then touching the face. Governments worldwide implemented measures like lockdowns, social distancing, mask mandates, and vaccination campaigns to control the spread of the virus.

The development of vaccines by companies like Pfizer-BioNTech, Moderna, and AstraZeneca marked a significant step in controlling COVID-19. Vaccines have been shown to reduce the severity of symptoms and lower the risk of severe illness or death. However, the virus has continued to mutate, leading to new variants such as Delta and Omicron, which pose ongoing challenges in vaccine effectiveness and public health strategies.

Public health organizations, including the World Health Organization (WHO) and the Centers for Disease Control and Prevention (CDC), continue to monitor the virus, adapt guidelines, and promote vaccination. While many countries have lifted strict restrictions, COVID-19 remains a health concern globally, highlighting the importance of continued vigilance, vaccination, and investment in healthcare infrastructure.

Max
07 Aug 2024 10:49pm UTC
in Fundamentals of NetLogo

Hi! I really enjoyed the tutorial and wanted to try tackle the homework. I got stuck at part 3, especially the part regarding establishing new connections, and I wanted to check the solutions but I coulndt find any solution after part 1? The titles are clickable but no file is downloaded or accessed. Any help woulde be appreciated!

Kind regards!

Niyar Prabhat Kalita
18 Apr 2024 1:22pm UTC
in Introduce Yourself

1) For the case of shrinking steps, we have, step length ~ (lambda)^n with (lambda less than 1). Sor, for negative value of n, step length should approach infinity always, but in the plots shown in the video, P as a function of lambda goes to 0 as n tends to negative infinity. What is the reason behind that?

2) How, for the case d=0, the expression of rho becomes ln(t)?