Skip to content

Add new GIS example: Solar Adoption model#381

Open
ShreyasN707 wants to merge 9 commits into
mesa:mainfrom
ShreyasN707:feature/solar-adoption-example
Open

Add new GIS example: Solar Adoption model#381
ShreyasN707 wants to merge 9 commits into
mesa:mainfrom
ShreyasN707:feature/solar-adoption-example

Conversation

@ShreyasN707

@ShreyasN707 ShreyasN707 commented Mar 12, 2026

Copy link
Copy Markdown
Contributor

Does it belong?

  • No significant overlap with an existing example, or if there is, the overlap is justified
  • The model is well-scoped: the simplest model that demonstrates its idea
  • It showcases Mesa features not already well-covered by other examples
  • It showcases interesting ABM mechanics, dynamics, or phenomena

Is it correct and current?

  • Uses current Mesa APIs (no deprecated schedulers, manual unique_id, dict portrayals, etc.)
  • Runs and visualizes out of the box
  • Deterministic with a fixed rng seed

Is it clean?

  • Minimal: no dead code, unused imports, or unnecessary complexity
  • Clear naming; logic readable without deep domain knowledge
  • README explains what it does, what it demonstrates, and how to run it (concise, links to references for theory)
  • PR follows the template, commits are clean, and there are no unrelated changes

What this example demonstrates

  • Using GeoSpace to manage spatial relationships between agents

  • Loading environmental data with RasterLayer.from_file()

  • Creating agents from GeoJSON using AgentCreator

  • Visualizing the simulation with a Solara dashboard using make_geospace_component, where households change color as they adopt solar

Implementation notes

A data/generate_data.py script generates synthetic households.geojson and solar_radiation.tif files so the example can run without external datasets.

The code follows the standard Mesa example structure and uses the built-in random generator.

The example runs successfully with the existing test_gis_examples.py test suite.

Screenshot from 2026-03-12 18-38-55 Screenshot from 2026-03-12 18-40-11 Screenshot from 2026-03-12 18-40-34 Screenshot from 2026-03-12 18-40-39

@EwoutH

EwoutH commented Mar 15, 2026

Copy link
Copy Markdown
Member

Thanks for the PR, looks like a cool model.

Could you:

  • Checkout the test failure
  • Request a peer-review (and maybe do one or two yourself)

@ShreyasN707 ShreyasN707 force-pushed the feature/solar-adoption-example branch 2 times, most recently from 5462cec to b5c8936 Compare March 16, 2026 04:35

@ShreyasN707 ShreyasN707 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

since no one was ready to give a peer review to my PR i reviewed it myself

  • There is no overlap with other examples
  • It showcases interesting ABM mechanics, dynamics or phenomena
  • It showcases Mesa features not already well-covered by other examples
  • Uses current Mesa APIs
  • I tested the running and visualizatoin of it
  • There are no dead code, unused imports, or unnecessary complexity
  • The README explains what it does, what it demonstrates, and how to run it
  • This PR follows the template and commits are clean

agent.unique_id = ind
x, y = agent.geometry.x, agent.geometry.y

try:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This suppresses an error which leads to uniform economic viability.

@@ -0,0 +1,43 @@
import mesa_geo as mg

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should preferably be under gis/solar_adoption/solar_adoption. Then the app.py should import these with import solar_adoption.agents for example.

Comment thread test_gis_examples.py
)

# Append the example's directory to sys.path so its absolute imports work
sys.path.insert(0, os.path.abspath(root))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should be able to import without this hack.

geopandas
rasterio
numpy
solara

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shouldn't need this dependency

)
economic_viability = self.solar_radiation

prob_adopt = (self.model.social_weight * social_influence) + (

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Personal opinion here: Since you re-evaluate at each step, these probabilities are a bit too high. Ends up with total adoption even with extremely low social + economic weights in a short number of steps. It may help visually to pad this a bit more.

economic_viability = self.solar_radiation

prob_adopt = (self.model.social_weight * social_influence) + (
self.model.economic_weight * economic_viability

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Adding two probabilities together doesn't make a ton of sense from a generative perspective IMO. Might be worth structuring it as a mixture model where each agent chooses to make an economic vs. social vs. noop decision, and then subsequently evaluating the social vs. economic probability. That way you're guaranteed to stay within 0 - 1 and you have a more proper probabilistic model to describe the "solar adoption" decision.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants