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.

PublicAPI (beta): This API is in beta and may change before becoming stable.

Methods

__init__(*[, capacity, ...])

Initializes a PolicyMap instance.

clear()

copy()

fromkeys([value])

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(k[,d])

If key is not found, d is returned if given, otherwise KeyError is raised

popitem()

2-tuple; but raise KeyError if D is empty.

setdefault(key[, default])

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

values()

Returns all valid values, even the stashed ones.