Skip to content

Add examples/experimental group and move alliance_formation into it - #3785

Merged
tpike3 merged 1 commit into
mesa:mainfrom
codebreaker32:refactor/examples/experimental
Aug 6, 2026
Merged

tpike3 merged 1 commit into
mesa:mainfrom
codebreaker32:refactor/examples/experimental

Conversation

@codebreaker32

@codebreaker32 codebreaker32 commented Aug 5, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adds a third example group, mesa/examples/experimental/, alongside basic/ and
advanced/, and moves the entire alliance_formation example into it.

Motive

alliance_formation is built on mesa.experimental.meta_agents. Everything under
mesa/experimental/ explicitly carries no semver guarantees and may change without
notice, but the example demonstrating it lived in examples/advanced/, which reads
as core, maintained, stable-API territory.

That mismatch is misleading in both directions: users browsing the advanced examples
have no signal that this one rests on an unstable API, and the example is liable to
break on any meta_agents change, which makes it look like a regression in a core
example rather than expected churn in an experimental one.

Rather than special-case a single example, this splits the examples into three tiers
so the directory a user is browsing tells them what stability to expect.

This also gives future experimental-API examples an obvious home instead of accreting
into advanced/ or basic/.

No public API change.

Usage Examples

# unchanged, the public export is the same
from mesa.examples import MultiLevelAllianceModel

# deep import path, if you need the scenario or app
from mesa.examples.experimental.alliance_formation.model import AllianceScenario

model = MultiLevelAllianceModel(scenario=AllianceScenario(n=50, rng=42))
model.run_model()

The alliance formation example is built on `mesa.experimental.meta_agents`,
which carries no semver guarantees, so it doesn't belong alongside the
advanced examples. Add a third `mesa/examples/experimental/` group and move
the example there in full.

Also fixes the package's `__init__ .py` (leading space), which meant the
example directory had no real `__init__.py`, and adds the example to
examples/README.md under a new Experimental section.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@codebreaker32

Copy link
Copy Markdown
Collaborator Author

Hi @tpike3, I went ahead and implemented the refactor as we discussed. Would appreciate if you or @jackiekazil could give a quick review

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

Performance benchmarks:

Model Size Init time [95% CI] Run time [95% CI]
BoltzmannWealth small 🟢 -4.9% [-5.5%, -4.2%] 🟢 -4.3% [-4.6%, -4.0%]
BoltzmannWealth large 🔵 -3.7% [-4.5%, -2.9%] 🟢 -7.0% [-9.2%, -4.8%]
Schelling small 🔵 -0.5% [-1.1%, +0.1%] 🔵 +0.9% [+0.0%, +1.7%]
Schelling large 🔵 -1.1% [-2.2%, +0.0%] 🔵 -4.7% [-7.8%, -1.4%]
WolfSheep small 🔵 -0.8% [-1.4%, -0.2%] 🔵 +0.0% [-3.6%, +3.6%]
WolfSheep large 🔵 -3.2% [-4.0%, -2.4%] 🔵 -5.0% [-7.9%, -2.1%]
SugarscapeG1mt small 🟢 -5.2% [-5.9%, -4.5%] 🔵 -3.9% [-5.4%, -2.3%]
SugarscapeG1mt large 🔵 -0.4% [-1.6%, +0.9%] 🔵 -0.6% [-2.2%, +1.0%]
BoidFlockers small 🔵 +1.0% [+0.4%, +1.5%] 🔵 +0.6% [+0.1%, +1.0%]
BoidFlockers large 🔵 -0.7% [-1.5%, +0.1%] 🔵 -1.2% [-1.5%, -0.9%]

@tpike3 tpike3 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks great thanks!

@tpike3
tpike3 merged commit d7346ed into mesa:main Aug 6, 2026
12 of 13 checks passed
@EwoutH

EwoutH commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Hi @codebreaker32 and @tpike3, I'm coming back to this one with a question.

Some history: when the core examples moved back into Mesa in #2358 (October 2024), based on this discussion (#2330 (comment)), they were split into basic and advanced, following quaquel's breakdown. From the start, the README said advanced examples "may use experimental Mesa features", while basic ones only use stable features. That line is still in the README, and the developer guide (#3975) now states the same rule.

This PR added a third tier because advanced/ "reads as core, maintained, stable-API territory", which is close to the opposite of how it was set up. Since then, #3811 moved alliance_formation back to advanced/, so experimental/ now only holds the tram model (#3796).

I'm curious what the considerations were. The PR mentions an earlier conversation; is that written down somewhere I can read? I'm about to add an example that uses mesa.experimental.locations (#3940), so I'd like to understand where it should go, and what our example tiering and policy now is.

CC @mesa/maintainers

EwoutH added a commit to EwoutH/mesa that referenced this pull request Nov 9, 2026
The example lives in advanced/, which may use experimental features, so
list it there rather than under the experimental examples. What that tier
is for is discussed in mesa#3785.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
EwoutH added a commit to EwoutH/mesa that referenced this pull request Nov 15, 2026
The example lives in advanced/, which may use experimental features, so
list it there rather than under the experimental examples. What that tier
is for is discussed in mesa#3785.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
EwoutH added a commit to EwoutH/mesa that referenced this pull request Nov 15, 2026
The example lives in advanced/, which may use experimental features, so
list it there rather than under the experimental examples. What that tier
is for is discussed in mesa#3785.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants