ray.rllib.policy.policy_map.PolicyMap#
- class ray.rllib.policy.policy_map.PolicyMap(*, capacity: int = 100, policy_states_are_swappable: bool = False, worker_index=None, num_workers=None, policy_config=None, session_creator=None, seed=None)[source]#
Bases:
dict
Maps policy IDs to Policy objects.
Thereby, keeps n policies in memory and - when capacity is reached - writes the least recently used to disk. This allows adding 100s of policies to a Algorithm for league-based setups w/o running out of memory.
Methods
Initializes a PolicyMap instance.
Create a new dictionary with keys from iterable and values set to value.
Iterates over all policies, even the stashed ones.
Returns all valid keys, even the stashed ones.
If the key is not found, return the default if given; otherwise, raise a KeyError.
Remove and return a (key, value) pair as a 2-tuple.
Insert key with a value of default if key is not in the dictionary.
Returns all valid values, even the stashed ones.