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

96 Fix RailEnvPersister incomplete. #97

Draft
wants to merge 24 commits into
base: main
Choose a base branch
from

Conversation

chenkins
Copy link
Contributor

@chenkins chenkins commented Dec 4, 2024

Changes

  • Add hashable state implementation to support == which is also human-inspectable (RailEnv.__getstate__) dictionaries.
  • Extended RailEnvPersister for missing items.
  • Persistence benchmarks
  • TODO lru cache problem
  • TODO regression tests.
  • TODO documentation comparison (feature completeness and performance).

Related issues

Fixes #96.

Checklist

  • Tests are included for relevant behavior changes.
  • Documentation is added in the docs folder for relevant behavior changes. If you made important user-facing
    changes, describe them under the [Unreleased] tag in CHANGELOG.md.
  • New package dependencies are declared in the pyproject.toml file.
    Requirement files have been updated by running tox -e requirements.
  • Code works with all supported Python versions (3.10, 3.11 and 3.12). Checks run with all three version and are
    required to run successfully.
  • Code is formatted according to PEP 8 (an IDE like PyCharm can do this for you).
  • Technical guidelines listed in CONTRIBUTING.md are followed.

@@ -774,3 +773,51 @@ def close(self):
except Exception as e:
print("Could Not close window due to:", e)
self.renderer = None

Copy link
Contributor

@SergeCroise SergeCroise Dec 4, 2024

Choose a reason for hiding this comment

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

see a few lines above:
def close(self):
"""
This method closes any renderer window.
The same in :
def render(self, ...

@chenkins chenkins changed the title Fix RailEnvPersister incomplete. 96 Fix RailEnvPersister incomplete. Dec 9, 2024
@chenkins
Copy link
Contributor Author

Provisional results bench_persistence.py for 200 x 200 grid with 100 agents:

## Matrix                                real    [01]    [02]    [03]    [04]    [05]
[01] RailEnvPersister                  0.1689   100.0   119.9   378.4   916.5  1437.2
[02] SerializationDeserializion        0.2024    83.4   100.0   315.7   764.7  1199.1
[03] get_state+msgpack                 0.6389    26.4    31.7   100.0   242.2   379.8
[04] get_state+pickle                  1.5475    10.9    13.1    41.3   100.0   156.8
[05] get_state+json                    2.4267     7.0     8.3    26.3    63.8   100.0

=========================================
{'RailEnvPersister': '122.175MB', 'get_state+pickle': '163.011MB', 'get_state+msgpack': '163.124MB', 'get_state+json': '163.127MB', 'SerializationDeserializion': '122.415MB'}

@chenkins
Copy link
Contributor Author

chenkins commented Dec 17, 2024

Results same setup bench_persistence.py for 200 x 200 grid with 100 agents.
after profiling -> fc48262

## Matrix                                real    [01]    [02]    [03]    [04]    [05]
[01] get_state+msgpack                 0.0944   100.0   176.7   182.6   254.7   404.2
[02] RailEnvPersister                  0.1668    56.6   100.0   103.3   144.1   228.7
[03] SerializationDeserializion        0.1724    54.8    96.8   100.0   139.5   221.4
[04] get_state+pickle                  0.2405    39.3    69.4    71.7   100.0   158.7
[05] get_state+json                    0.3816    24.7    43.7    45.2    63.0   100.0

=========================================
{'RailEnvPersister': '122.175MB', 'get_state+pickle': '40.941MB', 'get_state+msgpack': '41.054MB', 'get_state+json': '41.057MB', 'SerializationDeserializion': '122.404MB'}

@chenkins
Copy link
Contributor Author

Results same setup bench_persistence.py for 200 x 200 grid with 100 agents.
after adding dev_obs_dict 0527f69

## Matrix                                real    [01]    [02]    [03]    [04]
[01] SerializationDeserializion        0.1199   100.0   108.0   134.5   187.5
[02] RailEnvPersister                  0.1294    92.6   100.0   124.5   173.7
[03] get_state+msgpack                 0.1612    74.4    80.3   100.0   139.5
[04] get_state+pickle                  0.2248    53.3    57.6    71.7   100.0

=========================================
{'RailEnvPersister': '122.424MB', 'get_state+pickle': '41.190MB', 'get_state+msgpack': '42.059MB', 'SerializationDeserializion': '122.400MB'}

tests/test_lru_cache_problem.py Show resolved Hide resolved
tests/test_lru_cache_problem.py Show resolved Hide resolved
tests/test_lru_cache_problem.py Outdated Show resolved Hide resolved
tests/test_lru_cache_problem.py Outdated Show resolved Hide resolved
@chenkins chenkins added this to the 4.0.4 milestone Jan 17, 2025
@chenkins chenkins modified the milestones: 4.0.4, 4.0.5 Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RailEnvPersister incomplete.
2 participants