-
-
Notifications
You must be signed in to change notification settings - Fork 209
fix: add adaptive risk agents example with relative-import tests #306
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
base: main
Are you sure you want to change the base?
Conversation
|
@quaquel Thanks for the guidance earlier — moved this example to mesa-examples as suggested. |
EwoutH
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. Few comments. I'm a bit in doubt about the general usefulness of this example. On the one hand simple is good, but maybe this is too simple.
Even without a space, some sort of visualisation would be useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you fix the forced newlines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch — I’ll fix the forced line breaks in the README and push an update.
| def choose_action(self) -> str: | ||
| """Choose between a safe or risky action.""" | ||
| if self.model.random.random() < self.risk_preference: | ||
| return "risky" | ||
| return "safe" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically this is adaptive, since they update their risk_preference, but I don't know how much value this example actually shows.
@quaquel any opinions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That’s a fair concern.
The intent of this example is not to showcase a sophisticated learning algorithm, but to isolate where adaptation, memory, and decision logic currently live in a Mesa agent.
If you feel it would be more useful with a minimal visualization or a slightly richer signal (e.g. payoff distribution), I’m happy to extend it — or we can treat it as a purely didactic example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we avoid using GPT to write responses? It feels a bit strange to read. Let's try making Mesa a better package without using AI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair point — thanks for calling that out.
I’ll keep responses concise and in my own words going forward.
Appreciate the feedback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@EwoutH
Sorry but this person seems like a bot. Final decision is up on your hands.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i am a real person
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@darshi1337 what i am doing is that i write in hinglish and give it to chatgpt than it change it into english ,and than i gave response ,because. i am not confident with my english that's why you fell like this ,i am sorry for that i definetly try not to use next time
| ) -> None: | ||
| super().__init__(model) | ||
| self.risk_preference = initial_risk_preference | ||
| self.memory: deque[int] = deque(maxlen=memory_size) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@colinfrisch you're the expert on Agent memory, could you check how this is implemented here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do these tests do? They are not in our standard structure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are intentionally lightweight smoke tests, meant only to ensure the example initializes and steps without errors.
If there’s a preferred structure for example tests in mesa-examples, I’m happy to refactor them accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mesa-examples testing is basically a hacky mess. Any improvements are welcome. See #137 among other issues.
Edit: Mesa itself has something new, maybe that could also be applied to mesa-examples mesa/mesa#2767
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the context — that helps a lot.
I’ll keep the tests lightweight for now and avoid over-engineering, but I’m happy to iterate later if there’s a clearer direction (e.g. aligning with mesa/mesa#2767).
For this PR, I’ll treat the tests as minimal smoke checks unless you’d prefer a different baseline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the pointer.
The approach used in mesa/mesa#2767 looks like a good reference for improving visualization tests here as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep them out of this PR, but if you have a specific proposal be sure to open a discussion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay Ewouth thank's for your guidance ,i will definetly do as you say
for more information, see https://pre-commit.ci
Thanks for opening a PR! Please click the
Previewtab and select a PR template:Summary
This PR adds a new diagnostic example demonstrating adaptive risk-taking agents.
Each agent:
The example is intentionally minimal and uses only core Mesa primitives.
Motivation
Many adaptive agent models in Mesa end up concentrating:
inside a single
agent.step()method.This example is designed to make that complexity explicit, rather than hide it,
and to serve as a concrete, example-first input for discussions around
richer behavioral abstractions in Mesa.
Scope
model.randomfor reproducibilityTesting
Notes
This example is exploratory and educational by design.
It does not propose new abstractions or patterns,
but highlights current modeling constraints through a working example.