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

__init__

Initializes a PolicyMap instance.

clear

copy

fromkeys

Create a new dictionary with keys from iterable and values set to value.

items

Iterates over all policies, even the stashed ones.

keys

Returns all valid keys, even the stashed ones.

pop

If the key is not found, return the default if given; otherwise, raise a KeyError.

popitem

Remove and return a (key, value) pair as a 2-tuple.

setdefault

Insert key with a value of default if key is not in the dictionary.

values

Returns all valid values, even the stashed ones.