Add new GIS example: Solar Adoption model#381
Conversation
|
Thanks for the PR, looks like a cool model. Could you:
|
5462cec to
b5c8936
Compare
for more information, see https://pre-commit.ci
ShreyasN707
left a comment
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
This suppresses an error which leads to uniform economic viability.
| @@ -0,0 +1,43 @@ | |||
| import mesa_geo as mg | |||
There was a problem hiding this comment.
This should preferably be under gis/solar_adoption/solar_adoption. Then the app.py should import these with import solar_adoption.agents for example.
| ) | ||
|
|
||
| # Append the example's directory to sys.path so its absolute imports work | ||
| sys.path.insert(0, os.path.abspath(root)) |
There was a problem hiding this comment.
Should be able to import without this hack.
| geopandas | ||
| rasterio | ||
| numpy | ||
| solara |
There was a problem hiding this comment.
Shouldn't need this dependency
| ) | ||
| economic_viability = self.solar_radiation | ||
|
|
||
| prob_adopt = (self.model.social_weight * social_influence) + ( |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
Does it belong?
Is it correct and current?
unique_id, dict portrayals, etc.)rngseedIs it clean?
What this example demonstrates
Using
GeoSpaceto manage spatial relationships between agentsLoading environmental data with
RasterLayer.from_file()Creating agents from GeoJSON using
AgentCreatorVisualizing the simulation with a Solara dashboard using
make_geospace_component, where households change color as they adopt solarImplementation notes
A
data/generate_data.pyscript generates synthetichouseholds.geojsonandsolar_radiation.tiffiles 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.pytest suite.