-
Notifications
You must be signed in to change notification settings - Fork 17
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
base: main
Are you sure you want to change the base?
Changes from 27 commits
df26a23
7afe600
1d75987
d26561e
94daca7
4bd0533
25e3baf
4859e2c
a9d9e8f
06ac4eb
ab6f845
fc6be7c
3f7c26d
002a5d9
08c927d
ec10744
0747f98
8cd426b
5b8f8db
3d28340
20b3968
3a2dc16
891f296
04246e8
f278e56
56fdabc
efc65e7
f437548
90351ba
02e49c2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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_sets.values(): | ||
|
||
| 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
Member
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 | ||
|
|
||
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