Skip to content
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

RasterLayer creates Cells, Cells inherit from Agents, Agents need model input, but RasterLayer doesn't have access to model #236

Closed
EwoutH opened this issue Aug 26, 2024 · 4 comments · Fixed by #240
Labels
bug Release notes label

Comments

@EwoutH
Copy link
Member

EwoutH commented Aug 26, 2024

Currently, Mesa-Geo can create agents in it's RasterLayer's from_file() method.

obj = cls(width, height, dataset.crs, total_bounds, cell_cls)

To create an Mesa Agent, you are required to pass a Model parameter:

https://github.com/projectmesa/mesa/blob/0b2d250cf2d3be79b266a04c0c91612880e28f0a/mesa/agent.py#L40

However, the RasterLayer or it's from_file() method don't have access to a Model variable.


Why this previously worked, I don't know exactly. I think because there was previously a "hack" in which you inherited from Agent, but not properly set the agent up with super().__init__().

I think this might require a rethink about how Cells integrate with the Mesa (with the AgentSet and experimental cell_space specifically.

@EwoutH EwoutH added the bug Release notes label label Aug 26, 2024
@projectmesa projectmesa deleted a comment Aug 26, 2024
@projectmesa projectmesa deleted a comment Aug 26, 2024
@EwoutH
Copy link
Member Author

EwoutH commented Aug 26, 2024

(I deleted two spam posts from spam bots)

Edit: Three

@wang-boyu
Copy link
Member

wang-boyu commented Aug 29, 2024

It's probably introduced as mentioned here: https://github.com/projectmesa/mesa-geo/pull/212/files#r1730417300

A model parameter was added to class constructor, but it wasn't added into the from_file class method:

obj = cls(width, height, dataset.crs, total_bounds, cell_cls)

Moving forward, it's better to refactor RasterLayer based on PropertyLayer as mentioned in this ticket #201.

But I'll submit a fix for this first.

@EwoutH
Copy link
Member Author

EwoutH commented Aug 29, 2024

Thanks for looking into this!

It sparked me to finally write up an example model using the PropertyLayer: projectmesa/mesa-examples#182

@wang-boyu
Copy link
Member

Great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Release notes label
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants