-
Notifications
You must be signed in to change notification settings - Fork 988
Dynamic Discrete Spaces #2754
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
Comments
Can I ask how does caching prevent the dynamic nature of these spaces? |
The neighborhood of a given cell is cached. If you next change the neigborhood by either removing or adding a cell to it, you have invalidated the cache. |
Does the cache not update with the new neighborhood? |
no caching takes whatever was the return of the first ever time the function was called. |
Would it be beneficial in any way that we build our own caching function that automatically updates according to the necessary neighbor or is it too time consuming (performance wise)? |
Why implement something ourselves that is well covered by an existing library? Also, how would any cache know it needs to be updated? The Separately, thinking about the issue a bit more, my hunch is to implement the add_cell, remove_cell, add_edge and remove_edge (probably these need to be renamed to something a bit more generic) at the level of DiscreteSpace. In this way, all subclasses are automatically dynamic. For example, a while ago someone wanted to add walls to a space. With a |
Thanks for this discussion, I think I kind of get it now! |
I opened a PR: #2755 so let's move further discussion to there. |
Currently, all DiscreteSpace subclasses rely on
@cache
and@cached_property
for neighborhood-related functionality. This is critical for performance. However, if you want to represent a dynamically changing discrete space (e.g., a dynamic network), this is currently not possible.It seems that
functools
offers aclear_cache
function that can be called on anything decorated with a caching decorator. This means that it is possible to retain the performance benefits of caching while also being able to clear it on specific parts of the DiscreteSpace.Something like the following is roughly what would be needed. Note that this is not tested and just quickly put together based on some docs.
The text was updated successfully, but these errors were encountered: