Skip to content

Conversation

@coderbeta1
Copy link
Contributor

@coderbeta1 coderbeta1 commented Feb 23, 2024

Changes Made:

  1. Links Update: The previous link did not work. I updated it to make it work
  2. Run Method: Added a new run method
  3. General Cleaning: Made the code a bit more readable for beginners
  4. Custom Playback: Added a feature to allow user to choose which file they want to playback when replay is true. (Note user cannot choose the save file name, but they can choose what file to playback by changing the model parameter)
  5. Unique_id: Added a unique id to each agent
  6. Doc String: Added details of the model class

Discussion Topic:

While it is possible to now replay models, I feel there are still some things that can be improved,

  1. It is currently not easy to set custom save name for the checkpoint
  2. It is kinda inconvenient to make a new class just to save a file. I think the code could be optimised to make it as simple as something like "pickle.dump". This way it would be easy to save multiple conditional checkpoints in one run. (EDIT: I just noticed it is already under plans in GSOC idea list)

@coderbeta1 coderbeta1 closed this Feb 25, 2024
@coderbeta1 coderbeta1 reopened this Feb 25, 2024
@coderbeta1
Copy link
Contributor Author

pre-commit.ci autofix


self.schedule = mesa.time.RandomActivation(self)
self.grid = mesa.space.SingleGrid(width, height, torus=True)
self.grid = mesa.space.SingleGrid(height, width, torus=True)
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't it be width first?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried to follow the benchmark schelling model, and in that height is first.

But on checking mesa.space.SingleGrid width is indeed first. The change needs to be done in the benchmark code also. I have submitted a PR previously for benchmark, I'll make the change in all the schelling models in this repo and the maine mesa repo

# its contents. (coord_iter)
for cell in self.grid.coord_iter():
x, y = cell[1]
for _cont, pos in self.grid.coord_iter():
Copy link
Contributor

Choose a reason for hiding this comment

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

Unused loop variable should be named just _.

Display an informational text about caching and the status of the cache file (existing versus not existing)
"""
cache_file = Path("./my_cache_file_path.cache")
cache_file = Path("./" + model_params["cache_file_path"])
Copy link
Contributor

Choose a reason for hiding this comment

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

The ./ should be part of model_params["cache_file_path"], given that it is a path instead of a filename.

@rht
Copy link
Contributor

rht commented Feb 25, 2024

Other than the comments, everything else LGTM.

@coderbeta1 coderbeta1 requested a review from rht February 26, 2024 11:36
@rht rht merged commit c5dccc1 into projectmesa:main Feb 26, 2024
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.

2 participants