-
Notifications
You must be signed in to change notification settings - Fork 14
Adds move_to_optimal function in DiscreteSpaceDF class #118
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
Open
suryanshgargbpgc
wants to merge
30
commits into
projectmesa:main
Choose a base branch
from
suryanshgargbpgc:optimizefunction
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 28 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
df26a23
test commit
suryanshgargbpgc 7afe600
Added move_to function in DiscreteSpaceDF class
suryanshgargbpgc 1d75987
Merge branch 'main' into optimizefunction
suryanshgargbpgc d26561e
Revert "test commit"
suryanshgargbpgc 94daca7
moving type hint to types_ module
adamamer20 4bd0533
tests for move_to function
suryanshgargbpgc 25e3baf
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 4859e2c
Update test_grid_polars.py
suryanshgargbpgc a9d9e8f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 06ac4eb
Update test_grid_polars.py
suryanshgargbpgc ab6f845
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] fc6be7c
Update space.py
suryanshgargbpgc 3f7c26d
Merge branch 'optimizefunction' of https://github.com/suryanshgargbpg…
suryanshgargbpgc 002a5d9
Update space.py
suryanshgargbpgc 08c927d
Update agents.py
suryanshgargbpgc ec10744
adds blank line
suryanshgargbpgc 0747f98
Update test_grid_polars.py
suryanshgargbpgc 8cd426b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 5b8f8db
adds tests for move_to_optimal
suryanshgargbpgc 3d28340
Update test_grid_polars.py
suryanshgargbpgc 20b3968
Revert "Update test_grid_polars.py"
suryanshgargbpgc 3a2dc16
update test_grid_polars
suryanshgargbpgc 891f296
resolve conflicts
suryanshgargbpgc 04246e8
Fix whitespace in AgentSetPandas docstring
suryanshgargbpgc f278e56
Fix docstring conflict in _prepare_cells method with proper format
suryanshgargbpgc 56fdabc
Merge branch 'main' into optimizefunction
suryanshgargbpgc efc65e7
Merge branch 'main' into optimizefunction
adamamer20 f437548
update agenets.py
suryanshgargbpgc 90351ba
Merge upstream changes and resolve conflicts
suryanshgargbpgc 02e49c2
Revert "Merge upstream changes and resolve conflicts"
suryanshgargbpgc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -616,6 +616,19 @@ | |
""" | ||
... | ||
|
||
@abstractmethod | ||
def move_to_optimal( | ||
self, | ||
attr_names: str | list[str], | ||
rank_order: str | list[str] = "max", | ||
radius: int | Series | None = None, | ||
include_center: bool = True, | ||
shuffle: bool = True, | ||
inplace: bool = True, | ||
) -> Self: | ||
"""Move agents to optimal cells based on neighborhood ranking.""" | ||
... | ||
|
||
@property | ||
def model(self) -> ModelDF: | ||
"""The model that the AgentContainer belongs to. | ||
|
@@ -1039,6 +1052,31 @@ | |
def __reversed__(self) -> Iterator: | ||
return reversed(self._agents) | ||
|
||
def move_to_optimal( | ||
self, | ||
attr_names: str | list[str], | ||
rank_order: str | list[str] = "max", | ||
radius: int | Series | None = None, | ||
include_center: bool = True, | ||
shuffle: bool = True, | ||
inplace: bool = True, | ||
) -> Self: | ||
"""Move all agent sets to optimal cells based on neighborhood ranking.""" | ||
obj = self._get_obj(inplace) | ||
|
||
# Apply move_to_optimal to each agent set in the container | ||
for agent_set in obj: | ||
agent_set.move_to_optimal( | ||
attr_names=attr_names, | ||
rank_order=rank_order, | ||
radius=radius, | ||
include_center=include_center, | ||
shuffle=shuffle, | ||
inplace=True, | ||
) | ||
|
||
return obj | ||
Comment on lines
+1068
to
+1078
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. again, no actual implementation should go here becuase it's an abstract interface. remove it completely. For the AgentSet you should do the implementation for AgentSetPolars. |
||
|
||
@property | ||
def agents(self) -> DataFrame: | ||
return self._agents | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create a complete docstring like you did for GridPolars