id
int64
0
328k
repository_name
stringlengths
7
58
file_path
stringlengths
9
302
class_name
stringlengths
5
256
human_written_code
stringlengths
16
2.16M
class_skeleton
stringlengths
18
1.49M
⌀
total_program_units
int64
1
1.76k
total_doc_str
int64
0
771
AvgCountLine
float64
0
7.89k
AvgCountLineBlank
float64
0
297
AvgCountLineCode
float64
0
7.89k
AvgCountLineComment
float64
0
7.89k
AvgCyclomatic
float64
0
130
CommentToCodeRatio
float64
0
168
CountClassBase
float64
0
40
CountClassCoupled
float64
0
583
CountClassCoupledModified
float64
0
575
CountClassDerived
float64
0
5.35k
CountDeclInstanceMethod
float64
0
529
CountDeclInstanceVariable
float64
0
296
CountDeclMethod
float64
0
599
CountDeclMethodAll
float64
0
1.12k
CountLine
float64
1
40.4k
CountLineBlank
float64
0
8.16k
CountLineCode
float64
1
25.7k
CountLineCodeDecl
float64
1
8.15k
CountLineCodeExe
float64
0
24.2k
CountLineComment
float64
0
16.5k
CountStmt
float64
1
9.71k
CountStmtDecl
float64
1
8.15k
CountStmtExe
float64
0
9.69k
MaxCyclomatic
float64
0
759
MaxInheritanceTree
float64
0
16
MaxNesting
float64
0
34
SumCyclomatic
float64
0
2.9k
11,400
ray-project/ray
rllib/examples/_old_api_stack/models/centralized_critic_models.py
rllib.examples._old_api_stack.models.centralized_critic_models.TorchCentralizedCriticModel
from ray.rllib.models.torch.fcnet import FullyConnectedNetwork as TorchFC from ray.rllib.utils.annotations import override from ray.rllib.models.torch.misc import SlimFC from ray.rllib.models.torch.torch_modelv2 import TorchModelV2 from ray.rllib.models.modelv2 import ModelV2 class TorchCentralizedCriticModel(TorchMod...
class TorchCentralizedCriticModel(TorchModelV2, nn.Module): '''Multi-agent model that implements a centralized VF.''' def __init__(self, obs_space, action_space, num_outputs, model_config, name): pass @override(ModelV2) def forward(self, input_dict, state, seq_lens): pass def cent...
7
1
8
1
7
1
1
0.17
2
0
0
0
4
2
4
4
38
6
29
12
22
5
15
10
10
1
1
0
4
11,401
ray-project/ray
rllib/examples/_old_api_stack/models/centralized_critic_models.py
rllib.examples._old_api_stack.models.centralized_critic_models.YetAnotherCentralizedCriticModel
from ray.rllib.models.tf.tf_modelv2 import TFModelV2 from gymnasium.spaces import Box from ray.rllib.models.tf.fcnet import FullyConnectedNetwork from ray.rllib.models.torch.fcnet import FullyConnectedNetwork as TorchFC class YetAnotherCentralizedCriticModel(TFModelV2): """Multi-agent model that implements a centr...
class YetAnotherCentralizedCriticModel(TFModelV2): '''Multi-agent model that implements a centralized value function. It assumes the observation is a dict with 'own_obs' and 'opponent_obs', the former of which can be used for computing actions (i.e., decentralized execution), and the latter for optimiz...
4
1
8
1
7
0
1
0.45
1
1
0
0
3
3
3
3
38
7
22
7
18
10
10
7
6
1
1
0
3
11,402
ray-project/ray
rllib/examples/_old_api_stack/models/centralized_critic_models.py
rllib.examples._old_api_stack.models.centralized_critic_models.YetAnotherTorchCentralizedCriticModel
from ray.rllib.models.torch.fcnet import FullyConnectedNetwork as TorchFC from ray.rllib.models.torch.torch_modelv2 import TorchModelV2 from gymnasium.spaces import Box class YetAnotherTorchCentralizedCriticModel(TorchModelV2, nn.Module): """Multi-agent model that implements a centralized value function. It a...
class YetAnotherTorchCentralizedCriticModel(TorchModelV2, nn.Module): '''Multi-agent model that implements a centralized value function. It assumes the observation is a dict with 'own_obs' and 'opponent_obs', the former of which can be used for computing actions (i.e., decentralized execution), and the...
4
1
9
1
8
1
1
0.44
2
0
0
0
3
3
3
3
42
7
25
8
21
11
13
8
9
1
1
0
3
11,403
ray-project/ray
rllib/examples/_old_api_stack/models/custom_loss_model.py
rllib.examples._old_api_stack.models.custom_loss_model.CustomLossModel
from ray.rllib.models.tf.fcnet import FullyConnectedNetwork from ray.rllib.utils.annotations import override from ray.rllib.models.torch.fcnet import FullyConnectedNetwork as TorchFC from ray.rllib.offline import JsonReader from ray.rllib.models.tf.tf_action_dist import Categorical from ray.rllib.models.modelv2 import ...
class CustomLossModel(TFModelV2): '''Custom model that adds an imitation loss on top of the policy loss.''' def __init__(self, obs_space, action_space, num_outputs, model_config, name): pass @override(ModelV2) def forward(self, input_dict, state, seq_lens): pass @override(ModelV2) ...
9
1
7
1
5
1
1
0.21
1
1
0
0
5
5
5
5
43
8
29
18
20
6
19
14
13
1
1
0
5
11,404
ray-project/ray
rllib/examples/_old_api_stack/models/custom_loss_model.py
rllib.examples._old_api_stack.models.custom_loss_model.TorchCustomLossModel
import numpy as np from ray.rllib.utils.annotations import override from ray.rllib.models.torch.fcnet import FullyConnectedNetwork as TorchFC from ray.rllib.models.modelv2 import ModelV2, restore_original_dimensions from ray.rllib.models.torch.torch_modelv2 import TorchModelV2 from ray.rllib.models.torch.torch_action_d...
class TorchCustomLossModel(TorchModelV2, nn.Module): '''PyTorch version of the CustomLossModel above.''' def __init__(self, obs_space, action_space, num_outputs, model_config, name, input_files): pass @override(ModelV2) def forward(self, input_dict, state, seq_lens): pass @override...
9
2
13
1
7
5
1
0.6
2
1
0
0
5
7
5
5
75
11
40
22
29
24
22
16
16
1
1
0
5
11,405
ray-project/ray
rllib/examples/_old_api_stack/models/fast_model.py
rllib.examples._old_api_stack.models.fast_model.FastModel
from ray.rllib.utils.annotations import override from ray.rllib.models.modelv2 import ModelV2 from ray.rllib.models.tf.tf_modelv2 import TFModelV2 class FastModel(TFModelV2): """An example for a non-Keras ModelV2 in tf that learns a single weight. Defines all network architecture in `forward` (not `__init__` ...
class FastModel(TFModelV2): '''An example for a non-Keras ModelV2 in tf that learns a single weight. Defines all network architecture in `forward` (not `__init__` as it's usually done for Keras-style TFModelV2s). ''' def __init__(self, obs_space, action_space, num_outputs, model_config, name): ...
6
1
9
1
8
1
1
0.23
1
1
0
0
3
2
3
3
37
6
26
10
20
6
15
8
11
2
1
1
4
11,406
ray-project/ray
rllib/examples/_old_api_stack/models/fast_model.py
rllib.examples._old_api_stack.models.fast_model.TorchFastModel
from ray.rllib.models.modelv2 import ModelV2 from ray.rllib.models.torch.torch_modelv2 import TorchModelV2 from ray.rllib.models.torch.misc import SlimFC from ray.rllib.utils.annotations import override class TorchFastModel(TorchModelV2, nn.Module): """Torch version of FastModel (tf).""" def __init__(self, ob...
class TorchFastModel(TorchModelV2, nn.Module): '''Torch version of FastModel (tf).''' def __init__(self, obs_space, action_space, num_outputs, model_config, name): pass @override(ModelV2) def forward(self, input_dict, state, seq_lens): pass @override(ModelV2) def value_function...
6
1
7
1
6
1
1
0.14
2
0
0
0
3
3
3
3
29
5
21
9
15
3
13
7
9
1
1
0
3
11,407
ray-project/ray
rllib/examples/_old_api_stack/models/mobilenet_v2_encoder.py
rllib.examples._old_api_stack.models.mobilenet_v2_encoder.MobileNetV2Encoder
from ray.rllib.core.models.torch.base import TorchModel from ray.rllib.core.models.base import Encoder, ENCODER_OUT class MobileNetV2Encoder(TorchModel, Encoder): """A MobileNet v2 encoder for RLlib.""" def __init__(self, config): super().__init__(config) self.net = torch.hub.load('pytorch/vis...
class MobileNetV2Encoder(TorchModel, Encoder): '''A MobileNet v2 encoder for RLlib.''' def __init__(self, config): pass def _forward(self, input_dict, **kwargs): pass
3
1
6
0
5
1
2
0.18
2
1
0
0
2
1
2
2
15
2
11
5
8
2
9
5
6
3
1
2
4
11,408
ray-project/ray
rllib/examples/_old_api_stack/models/mobilenet_v2_encoder.py
rllib.examples._old_api_stack.models.mobilenet_v2_encoder.MobileNetV2EncoderConfig
from ray.rllib.core.models.configs import ModelConfig class MobileNetV2EncoderConfig(ModelConfig): output_dims = (1000,) freeze = True def build(self, framework): assert framework == 'torch', 'Unsupported framework `{}`!'.format(framework) return MobileNetV2Encoder(self)
class MobileNetV2EncoderConfig(ModelConfig): def build(self, framework): pass
2
0
3
0
3
0
1
0.17
1
1
1
0
1
0
1
1
8
1
6
4
4
1
6
4
4
1
1
0
1
11,409
ray-project/ray
rllib/examples/_old_api_stack/models/mobilenet_v2_with_lstm_models.py
rllib.examples._old_api_stack.models.mobilenet_v2_with_lstm_models.MobileV2PlusRNNModel
from ray.rllib.models.torch.recurrent_net import RecurrentNetwork as TorchRNN from ray.rllib.utils.annotations import override from ray.rllib.models.modelv2 import ModelV2 import numpy as np from ray.rllib.models.tf.recurrent_net import RecurrentNetwork class MobileV2PlusRNNModel(RecurrentNetwork): """A conv. + re...
class MobileV2PlusRNNModel(RecurrentNetwork): '''A conv. + recurrent keras net example using a pre-trained MobileNet.''' def __init__(self, obs_space, action_space, num_outputs, model_config, name, cnn_shape): pass @override(RecurrentNetwork) def forward_rnn(self, inputs, state, seq_lens): ...
8
1
16
2
14
1
1
0.05
1
1
0
0
4
4
4
4
74
13
58
26
48
3
27
20
22
1
1
0
4
11,410
ray-project/ray
rllib/examples/_old_api_stack/models/mobilenet_v2_with_lstm_models.py
rllib.examples._old_api_stack.models.mobilenet_v2_with_lstm_models.TorchMobileV2PlusRNNModel
from ray.rllib.models.torch.recurrent_net import RecurrentNetwork as TorchRNN from ray.rllib.models.modelv2 import ModelV2 from ray.rllib.utils.annotations import override from ray.rllib.models.torch.misc import SlimFC class TorchMobileV2PlusRNNModel(TorchRNN, nn.Module): """A conv. + recurrent torch net example u...
class TorchMobileV2PlusRNNModel(TorchRNN, nn.Module): '''A conv. + recurrent torch net example using a pre-trained MobileNet.''' def __init__(self, obs_space, action_space, num_outputs, model_config, name, cnn_shape): pass @override(TorchRNN) def forward_rnn(self, inputs, state, seq_lens): ...
8
1
15
1
12
2
1
0.2
2
1
0
0
4
9
4
4
70
9
51
24
41
10
29
19
24
2
1
1
5
11,411
ray-project/ray
rllib/examples/_old_api_stack/models/neural_computer.py
rllib.examples._old_api_stack.models.neural_computer.DNCMemory
from ray.rllib.models.torch.misc import SlimFC from ray.rllib.utils.typing import ModelConfigDict, TensorType from ray.rllib.models.torch.torch_modelv2 import TorchModelV2 from collections import OrderedDict import gymnasium as gym from typing import Union, Dict, List, Tuple class DNCMemory(TorchModelV2, nn.Module): ...
class DNCMemory(TorchModelV2, nn.Module): '''Differentiable Neural Computer wrapper around ixaxaar's DNC implementation, see https://github.com/ixaxaar/pytorch-dnc''' def __init__(self, obs_space: gym.spaces.Space, action_space: gym.spaces.Space, num_outputs: int, model_config: ModelConfigDict, name: str,...
9
4
23
2
19
2
2
0.18
2
8
0
0
8
9
8
8
228
29
175
68
145
31
75
47
66
4
1
2
13
11,412
ray-project/ray
rllib/examples/_old_api_stack/models/parametric_actions_model.py
rllib.examples._old_api_stack.models.parametric_actions_model.ParametricActionsModel
from ray.rllib.algorithms.dqn.distributional_q_tf_model import DistributionalQTFModel from gymnasium.spaces import Box from ray.rllib.models.torch.fcnet import FullyConnectedNetwork as TorchFC from ray.rllib.models.tf.fcnet import FullyConnectedNetwork class ParametricActionsModel(DistributionalQTFModel): """Param...
class ParametricActionsModel(DistributionalQTFModel): '''Parametric action model that handles the dot product and masking. This assumes the outputs are logits for a single Categorical action dist. Getting this to work with a more complex output (e.g., if the action space is a tuple of several distribut...
4
1
14
1
10
2
1
0.38
1
1
0
0
3
1
3
3
52
8
32
21
18
12
14
11
10
1
1
0
3
11,413
ray-project/ray
rllib/examples/_old_api_stack/models/parametric_actions_model.py
rllib.examples._old_api_stack.models.parametric_actions_model.ParametricActionsModelThatLearnsEmbeddings
from gymnasium.spaces import Box from ray.rllib.algorithms.dqn.distributional_q_tf_model import DistributionalQTFModel from ray.rllib.models.tf.fcnet import FullyConnectedNetwork from ray.rllib.models.torch.fcnet import FullyConnectedNetwork as TorchFC class ParametricActionsModelThatLearnsEmbeddings(DistributionalQTF...
class ParametricActionsModelThatLearnsEmbeddings(DistributionalQTFModel): '''Same as the above ParametricActionsModel. However, this version also learns the action embeddings. ''' def __init__(self, obs_space, action_space, num_outputs, model_config, name, true_obs_shape=(4,), action_embed_size=2, **k...
4
1
24
4
18
3
1
0.2
1
3
0
0
3
3
3
3
81
16
54
28
40
11
23
18
19
1
1
0
3
11,414
ray-project/ray
rllib/examples/_old_api_stack/models/parametric_actions_model.py
rllib.examples._old_api_stack.models.parametric_actions_model.TorchParametricActionsModel
from gymnasium.spaces import Box from ray.rllib.algorithms.dqn.dqn_torch_model import DQNTorchModel from ray.rllib.utils.torch_utils import FLOAT_MAX, FLOAT_MIN from ray.rllib.models.torch.fcnet import FullyConnectedNetwork as TorchFC class TorchParametricActionsModel(DQNTorchModel): """PyTorch version of above Pa...
class TorchParametricActionsModel(DQNTorchModel): '''PyTorch version of above ParametricActionsModel.''' def __init__(self, obs_space, action_space, num_outputs, model_config, name, true_obs_shape=(4,), action_embed_size=2, **kw): pass def forward(self, input_dict, state, seq_lens): pass ...
4
1
15
2
10
3
1
0.28
1
0
0
0
3
1
3
3
50
9
32
21
18
9
14
11
10
1
1
0
3
11,415
ray-project/ray
rllib/examples/_old_api_stack/models/shared_weights_model.py
rllib.examples._old_api_stack.models.shared_weights_model.SharedWeightsModel1
from ray.rllib.utils.annotations import override from ray.rllib.models.tf.tf_modelv2 import TFModelV2 from ray.rllib.models.modelv2 import ModelV2 class SharedWeightsModel1(TFModelV2): """Example of weight sharing between two different TFModelV2s. NOTE: This will only work for tf1 (static graph). When running...
class SharedWeightsModel1(TFModelV2): '''Example of weight sharing between two different TFModelV2s. NOTE: This will only work for tf1 (static graph). When running with config.framework_str=tf2, use TF2SharedWeightsModel, instead! Here, we share the variables defined in the 'shared' variable scope ...
6
1
9
0
9
0
1
0.27
1
1
0
0
3
2
3
3
44
6
30
14
22
8
14
10
10
1
1
1
3
11,416
ray-project/ray
rllib/examples/_old_api_stack/models/shared_weights_model.py
rllib.examples._old_api_stack.models.shared_weights_model.SharedWeightsModel2
from ray.rllib.utils.annotations import override from ray.rllib.models.modelv2 import ModelV2 from ray.rllib.models.tf.tf_modelv2 import TFModelV2 class SharedWeightsModel2(TFModelV2): """The "other" TFModelV2 using the same shared space as the one above.""" def __init__(self, observation_space, action_space,...
class SharedWeightsModel2(TFModelV2): '''The "other" TFModelV2 using the same shared space as the one above.''' def __init__(self, observation_space, action_space, num_outputs, model_config, name): pass @override(ModelV2) def forward(self, input_dict, state, seq_lens): pass @overri...
6
1
10
1
9
0
1
0.07
1
1
0
0
3
2
3
3
37
5
30
14
22
2
14
10
10
1
1
1
3
11,417
ray-project/ray
rllib/examples/_old_api_stack/models/shared_weights_model.py
rllib.examples._old_api_stack.models.shared_weights_model.TF2SharedWeightsModel
from ray.rllib.utils.annotations import override from ray.rllib.models.modelv2 import ModelV2 from ray.rllib.models.tf.tf_modelv2 import TFModelV2 class TF2SharedWeightsModel(TFModelV2): """Example of weight sharing between two different TFModelV2s. NOTE: This will only work for tf2.x. When running with confi...
class TF2SharedWeightsModel(TFModelV2): '''Example of weight sharing between two different TFModelV2s. NOTE: This will only work for tf2.x. When running with config.framework=tf, use SharedWeightsModel1 and SharedWeightsModel2 below, instead! The shared (single) layer is simply defined outside of the t...
6
1
9
1
8
0
1
0.25
1
1
0
0
3
2
3
3
42
7
28
15
19
7
16
11
11
2
1
1
4
11,418
ray-project/ray
rllib/examples/_old_api_stack/models/shared_weights_model.py
rllib.examples._old_api_stack.models.shared_weights_model.TorchSharedWeightsModel
from ray.rllib.utils.annotations import override from ray.rllib.models.modelv2 import ModelV2 from ray.rllib.models.torch.torch_modelv2 import TorchModelV2 import numpy as np from ray.rllib.models.torch.misc import SlimFC class TorchSharedWeightsModel(TorchModelV2, nn.Module): """Example of weight sharing between ...
class TorchSharedWeightsModel(TorchModelV2, nn.Module): '''Example of weight sharing between two different TorchModelV2s. The shared (single) layer is simply defined outside of the two Models, then used by both Models in their forward pass. ''' def __init__(self, observation_space, action_space, n...
6
1
13
1
12
1
1
0.16
2
1
0
0
3
6
3
3
50
6
38
16
30
6
17
11
13
1
1
0
3
11,419
ray-project/ray
rllib/examples/_old_api_stack/models/simple_rpg_model.py
rllib.examples._old_api_stack.models.simple_rpg_model.CustomTFRPGModel
from ray.rllib.models.tf.fcnet import FullyConnectedNetwork as TFFCNet from ray.rllib.models.tf.tf_modelv2 import TFModelV2 class CustomTFRPGModel(TFModelV2): """Example of interpreting repeated observations.""" def __init__(self, obs_space, action_space, num_outputs, model_config, name): super().__in...
class CustomTFRPGModel(TFModelV2): '''Example of interpreting repeated observations.''' def __init__(self, obs_space, action_space, num_outputs, model_config, name): pass def forward(self, input_dict, state, seq_lens): pass def value_function(self): pass
4
1
7
0
5
2
1
0.47
1
1
0
0
3
1
3
3
25
3
15
5
11
7
15
5
11
2
1
1
4
11,420
ray-project/ray
rllib/examples/_old_api_stack/models/simple_rpg_model.py
rllib.examples._old_api_stack.models.simple_rpg_model.CustomTorchRPGModel
from ray.rllib.models.torch.fcnet import FullyConnectedNetwork as TorchFCNet from ray.rllib.models.torch.torch_modelv2 import TorchModelV2 class CustomTorchRPGModel(TorchModelV2, nn.Module): """Example of interpreting repeated observations.""" def __init__(self, obs_space, action_space, num_outputs, model_con...
class CustomTorchRPGModel(TorchModelV2, nn.Module): '''Example of interpreting repeated observations.''' def __init__(self, obs_space, action_space, num_outputs, model_config, name): pass def forward(self, input_dict, state, seq_lens): pass def value_function(self): pass
4
1
7
0
5
2
1
0.41
2
1
0
0
3
1
3
3
27
3
17
5
13
7
15
5
11
1
1
0
3
11,421
ray-project/ray
rllib/examples/_old_api_stack/policy/cliff_walking_wall_policy.py
rllib.examples._old_api_stack.policy.cliff_walking_wall_policy.CliffWalkingWallPolicy
from ray.rllib.policy.sample_batch import SampleBatch from ray.rllib.utils.annotations import override from ray.rllib.policy.policy import Policy, ViewRequirement import gymnasium as gym from ray.rllib.models.torch.torch_action_dist import TorchCategorical from ray.rllib.utils.typing import AlgorithmConfigDict, TensorS...
class CliffWalkingWallPolicy(Policy): '''Optimal RLlib policy for the CliffWalkingWallEnv environment, defined in ray/rllib/examples/env/cliff_walking_wall_env.py, with epsilon-greedy exploration. The policy takes a random action with probability epsilon, specified by `config["epsilon"]`, and the optim...
8
1
18
1
14
3
1
0.3
1
6
0
0
4
4
4
4
87
8
61
38
36
18
37
18
32
2
1
1
5
11,422
ray-project/ray
rllib/examples/_old_api_stack/policy/random_policy.py
rllib.examples._old_api_stack.policy.random_policy.RandomPolicy
from ray.rllib.policy.policy import Policy import random from gymnasium.spaces import Box import tree from typing import List, Optional, Union from ray.rllib.policy.sample_batch import SampleBatch from ray.rllib.utils.annotations import override from ray.rllib.utils.typing import ModelWeights, TensorStructType, TensorT...
class RandomPolicy(Policy): '''Hand-coded policy that returns random actions.''' def __init__(self, *args, **kwargs): pass @override(Policy) def init_view_requirements(self): pass @override(Policy) def compute_actions(self, obs_batch: Union[List[TensorStructType], TensorStructT...
16
4
8
0
7
1
1
0.17
1
4
0
0
8
1
8
8
84
9
64
35
33
11
24
12
15
2
1
1
9
11,423
ray-project/ray
rllib/examples/algorithms/classes/vpg.py
rllib.examples.algorithms.classes.vpg.VPG
from ray.rllib.utils.annotations import override from ray.rllib.algorithms import Algorithm import tree from ray.rllib.utils.metrics import ENV_RUNNER_RESULTS, ENV_RUNNER_SAMPLING_TIMER, LEARNER_RESULTS, LEARNER_UPDATE_TIMER, NUM_ENV_STEPS_SAMPLED_LIFETIME, SYNCH_WORKER_WEIGHTS_TIMER, TIMERS class VPG(Algorithm): ...
class VPG(Algorithm): @classmethod @override(Algorithm) def get_default_config(cls) -> VPGConfig: pass @override(Algorithm) def training_step(self) -> None: '''Override of the training_step method of `Algorithm`. Runs the following steps per call: - Sample B timeste...
7
1
25
2
16
8
1
0.46
1
2
1
0
2
1
3
3
82
7
52
13
45
24
20
10
16
1
1
1
3
11,424
ray-project/ray
rllib/examples/algorithms/classes/vpg.py
rllib.examples.algorithms.classes.vpg.VPGConfig
from typing_extensions import Self from ray.rllib.utils.annotations import override from ray.rllib.algorithms.algorithm_config import AlgorithmConfig, NotProvided from ray.rllib.core.rl_module.rl_module import RLModuleSpec class VPGConfig(AlgorithmConfig): """A simple VPG (vanilla policy gradient) algorithm w/o va...
class VPGConfig(AlgorithmConfig): '''A simple VPG (vanilla policy gradient) algorithm w/o value function support. Use for testing purposes only! This Algorithm should use the VPGTorchLearner and VPGTorchRLModule ''' def __init__(self, algo_class=None): pass @override(AlgorithmConfig) ...
8
2
15
2
8
4
2
0.59
1
3
1
0
4
3
4
4
75
16
37
21
21
22
23
12
16
2
1
1
7
11,425
ray-project/ray
rllib/examples/centralized_critic.py
rllib.examples.centralized_critic.CCPPOTorchPolicy
from ray.rllib.algorithms.ppo.ppo_torch_policy import PPOTorchPolicy from ray.rllib.utils.annotations import override class CCPPOTorchPolicy(CentralizedValueMixin, PPOTorchPolicy): def __init__(self, observation_space, action_space, config): PPOTorchPolicy.__init__(self, observation_space, action_space, c...
class CCPPOTorchPolicy(CentralizedValueMixin, PPOTorchPolicy): def __init__(self, observation_space, action_space, config): pass @override(PPOTorchPolicy) def loss(self, model, dist_class, train_batch): pass @override(PPOTorchPolicy) def postprocess_trajectory(self, sample_batch, o...
6
0
4
0
4
0
1
0
2
1
0
0
3
0
3
4
16
2
14
8
6
0
8
4
4
1
1
0
3
11,426
ray-project/ray
rllib/examples/centralized_critic.py
rllib.examples.centralized_critic.CentralizedCritic
from ray.rllib.algorithms.ppo.ppo import PPO, PPOConfig from ray.rllib.utils.annotations import override class CentralizedCritic(PPO): @classmethod @override(PPO) def get_default_policy_class(cls, config): if config['framework'] == 'torch': return CCPPOTorchPolicy elif config['...
class CentralizedCritic(PPO): @classmethod @override(PPO) def get_default_policy_class(cls, config): pass
4
0
7
0
7
0
3
0
1
1
1
0
0
0
1
1
10
0
10
3
6
0
6
2
4
3
1
1
3
11,427
ray-project/ray
rllib/examples/centralized_critic.py
rllib.examples.centralized_critic.CentralizedValueMixin
from ray.rllib.utils.tf_utils import explained_variance, make_tf_callable class CentralizedValueMixin: """Add method to evaluate the central value function from the model.""" def __init__(self): if self.config['framework'] != 'torch': self.compute_central_vf = make_tf_callable(self.get_ses...
class CentralizedValueMixin: '''Add method to evaluate the central value function from the model.''' def __init__(self): pass
2
1
7
0
7
0
2
0.13
0
0
0
2
1
1
1
1
10
1
8
3
6
1
5
3
3
2
0
1
2
11,428
ray-project/ray
rllib/examples/checkpoints/continue_training_from_checkpoint.py
rllib.examples.checkpoints.continue_training_from_checkpoint.CrashAfterNIters
from ray.rllib.callbacks.callbacks import RLlibCallback from ray.rllib.utils.metrics import ENV_RUNNER_RESULTS, EPISODE_RETURN_MEAN class CrashAfterNIters(RLlibCallback): """Callback that makes the algo crash after a certain avg. return is reached.""" def __init__(self): super().__init__() sel...
class CrashAfterNIters(RLlibCallback): '''Callback that makes the algo crash after a certain avg. return is reached.''' def __init__(self): pass def on_train_result(self, *, algorithm, metrics_logger, result, **kwargs): pass
3
1
9
0
6
3
2
0.46
1
2
0
0
2
1
2
2
21
2
13
4
10
6
9
4
6
3
1
1
4
11,429
ray-project/ray
rllib/examples/checkpoints/onnx_torch_lstm.py
rllib.examples.checkpoints.onnx_torch_lstm.ONNXCompatibleWrapper
class ONNXCompatibleWrapper(torch.nn.Module): def __init__(self, original_model): super(ONNXCompatibleWrapper, self).__init__() self.original_model = original_model def forward(self, a, b0, b1, c): b = [b0, b1] ret = self.original_model({'obs': a}, b, c) return (ret[0],...
class ONNXCompatibleWrapper(torch.nn.Module): def __init__(self, original_model): pass def forward(self, a, b0, b1, c): pass
3
0
5
0
4
2
1
0.38
1
1
0
0
2
1
2
2
12
1
8
6
5
3
8
6
5
1
1
0
2
11,430
ray-project/ray
rllib/examples/compute_adapted_gae_on_postprocess_trajectory.py
rllib.examples.compute_adapted_gae_on_postprocess_trajectory.MyCallbacks
import numpy as np from ray.rllib.utils.annotations import override from ray.rllib.evaluation.postprocessing import Postprocessing from ray.rllib.callbacks.callbacks import RLlibCallback from ray.rllib.policy.sample_batch import SampleBatch class MyCallbacks(RLlibCallback): @override(RLlibCallback) def on_pos...
class MyCallbacks(RLlibCallback): @override(RLlibCallback) def on_postprocess_trajectory(self, *, worker, episode, agent_id, policy_id, policies, postprocessed_batch, original_batches, **kwargs): pass
3
0
83
7
65
11
3
0.16
1
2
0
0
1
0
1
1
85
7
67
23
53
11
21
11
19
3
1
2
3
11,431
ray-project/ray
rllib/examples/connectors/classes/count_based_curiosity.py
rllib.examples.connectors.classes.count_based_curiosity.CountBasedCuriosity
from typing import Any, List, Optional import gymnasium as gym from ray.rllib.core.rl_module.rl_module import RLModule from ray.rllib.connectors.connector_v2 import ConnectorV2 from collections import Counter from ray.rllib.utils.typing import EpisodeType class CountBasedCuriosity(ConnectorV2): """Learner Connecto...
class CountBasedCuriosity(ConnectorV2): '''Learner ConnectorV2 piece to compute intrinsic rewards based on obs counts. Add this connector piece to your Learner pipeline, through your algo config: ``` config.training( learner_connector=lambda obs_sp, act_sp: CountBasedCuriosity() ) ``` ...
3
2
26
2
16
8
2
1.15
1
10
0
0
2
2
2
2
82
11
33
25
14
38
15
9
12
3
1
2
4
11,432
ray-project/ray
rllib/examples/connectors/classes/euclidian_distance_based_curiosity.py
rllib.examples.connectors.classes.euclidian_distance_based_curiosity.EuclidianDistanceBasedCuriosity
import gymnasium as gym from ray.rllib.connectors.connector_v2 import ConnectorV2 from ray.rllib.core.rl_module.rl_module import RLModule from typing import Any, List, Optional import numpy as np from collections import deque from ray.rllib.utils.typing import EpisodeType class EuclidianDistanceBasedCuriosity(Connecto...
class EuclidianDistanceBasedCuriosity(ConnectorV2): '''Learner ConnectorV2 piece computing intrinsic rewards with euclidian distance. Add this connector piece to your Learner pipeline, through your algo config: ``` config.training( learner_connector=lambda obs_sp, act_sp: EuclidianDistanceBased...
3
2
37
4
24
10
4
0.94
1
9
0
0
2
3
2
2
111
16
49
30
29
46
27
13
24
7
1
3
8
11,433
ray-project/ray
rllib/examples/connectors/classes/protobuf_cartpole_observation_decoder.py
rllib.examples.connectors.classes.protobuf_cartpole_observation_decoder.ProtobufCartPoleObservationDecoder
from typing import Any, List, Optional from ray.rllib.utils.annotations import override from ray.rllib.connectors.connector_v2 import ConnectorV2 from ray.rllib.examples.envs.classes.utils.cartpole_observations_proto import CartPoleObservation from ray.rllib.utils.typing import EpisodeType import numpy as np from ray.r...
class ProtobufCartPoleObservationDecoder(ConnectorV2): '''Env-to-module ConnectorV2 piece decoding protobuf obs into CartPole-v1 obs. Add this connector piece to your env-to-module pipeline, through your algo config: ``` config.env_runners( env_to_module_connector=( lambda env, spac...
4
1
25
2
19
5
2
0.51
1
4
0
0
2
0
2
2
66
7
39
22
22
20
13
8
10
2
1
1
3
11,434
ray-project/ray
rllib/examples/connectors/mean_std_filtering.py
rllib.examples.connectors.mean_std_filtering.LopsidedObs
import numpy as np import gymnasium as gym class LopsidedObs(gym.ObservationWrapper): def __init__(self, env): super().__init__(env) self.observation_space = gym.spaces.Box(-4000.0, -1456.0, (3,), np.float32) def observation(self, observation): return (observation + 1.0) / 2.0 * (4000...
class LopsidedObs(gym.ObservationWrapper): def __init__(self, env): pass def observation(self, observation): pass
3
0
3
0
3
1
1
0.17
1
1
0
0
2
1
2
2
8
1
6
4
3
1
6
4
3
1
1
0
2
11,435
ray-project/ray
rllib/examples/curiosity/intrinsic_curiosity_model_based_curiosity.py
rllib.examples.curiosity.intrinsic_curiosity_model_based_curiosity.MeasureMaxDistanceToStart
from collections import defaultdict import numpy as np from ray.rllib.callbacks.callbacks import RLlibCallback class MeasureMaxDistanceToStart(RLlibCallback): """Callback measuring the dist of the agent to its start position in FrozenLake-v1. Makes the naive assumption that the start position ("S") is in the ...
class MeasureMaxDistanceToStart(RLlibCallback): '''Callback measuring the dist of the agent to its start position in FrozenLake-v1. Makes the naive assumption that the start position ("S") is in the upper left corner of the used map. Uses the MetricsLogger to record the (euclidian) distance value. ...
5
1
15
0
14
1
2
0.12
1
2
0
0
4
2
4
4
69
5
57
41
25
7
22
14
17
2
1
1
6
11,436
ray-project/ray
rllib/examples/curriculum/curriculum_learning.py
rllib.examples.curriculum.curriculum_learning.EnvTaskCallback
from ray.rllib.callbacks.callbacks import RLlibCallback from ray.rllib.algorithms.algorithm import Algorithm from ray.rllib.utils.metrics import ENV_RUNNER_RESULTS, EPISODE_RETURN_MEAN, NUM_ENV_STEPS_SAMPLED_LIFETIME from functools import partial class EnvTaskCallback(RLlibCallback): """Custom callback implementin...
class EnvTaskCallback(RLlibCallback): '''Custom callback implementing `on_train_result()` for changing the envs' maps.''' def on_algorithm_init(self, *, algorithm: 'Algorithm', **kwargs) -> None: pass def on_train_result(self, *, algorithm: Algorithm, metrics_logger=None, result: dict, **kwargs) ...
3
1
45
2
35
9
6
0.28
1
2
0
0
1
0
1
1
48
3
36
12
27
10
17
5
15
6
1
2
6
11,437
ray-project/ray
rllib/examples/envs/async_gym_env_vectorization.py
rllib.examples.envs.async_gym_env_vectorization.SlowEnv
import time import gymnasium as gym class SlowEnv(gym.ObservationWrapper): def observation(self, observation): time.sleep(0.005) return observation
class SlowEnv(gym.ObservationWrapper): def observation(self, observation): pass
2
0
3
0
3
0
1
0
1
0
0
0
1
0
1
1
4
0
4
2
2
0
4
2
2
1
1
0
1
11,438
ray-project/ray
rllib/examples/envs/classes/action_mask_env.py
rllib.examples.envs.classes.action_mask_env.ActionMaskEnv
from ray.rllib.examples.envs.classes.random_env import RandomEnv import numpy as np from gymnasium.spaces import Box, Dict, Discrete class ActionMaskEnv(RandomEnv): """A randomly acting environment that publishes an action-mask each step.""" def __init__(self, config): super().__init__(config) ...
class ActionMaskEnv(RandomEnv): '''A randomly acting environment that publishes an action-mask each step.''' def __init__(self, config): pass def reset(self, *, seed=None, options=None): pass def step(self, action): pass def _fix_action_mask(self, obs): pass
5
1
8
0
7
1
1
0.19
1
2
0
0
4
2
4
4
36
4
27
9
22
5
19
9
14
2
1
1
5
11,439
ray-project/ray
rllib/examples/envs/classes/cartpole_crashing.py
rllib.examples.envs.classes.cartpole_crashing.CartPoleCrashing
from ray.rllib.utils.error import EnvError import time from ray.rllib.utils.annotations import override from gymnasium.envs.classic_control import CartPoleEnv import numpy as np class CartPoleCrashing(CartPoleEnv): """A CartPole env that crashes (or stalls) from time to time. Useful for testing faulty sub-env...
class CartPoleCrashing(CartPoleEnv): '''A CartPole env that crashes (or stalls) from time to time. Useful for testing faulty sub-env (within a vectorized env) handling by EnvRunners. After crashing, the env expects a `reset()` call next (calling `step()` will result in yet another error), which may...
8
1
29
3
22
4
5
0.26
1
4
0
0
5
12
5
5
167
22
115
25
107
30
68
23
62
8
1
2
24
11,440
ray-project/ray
rllib/examples/envs/classes/cartpole_sparse_rewards.py
rllib.examples.envs.classes.cartpole_sparse_rewards.CartPoleSparseRewards
from copy import deepcopy from gymnasium.spaces import Box, Dict, Discrete import numpy as np import gymnasium as gym class CartPoleSparseRewards(gym.Env): """Wrapper for gym CartPole environment where reward is accumulated to the end.""" def __init__(self, config=None): self.env = gym.make('CartPole-...
class CartPoleSparseRewards(gym.Env): '''Wrapper for gym CartPole environment where reward is accumulated to the end.''' def __init__(self, config=None): pass def reset(self, *, seed=None, options=None): pass def step(self, action): pass def set_state(self, state): ...
6
1
7
0
7
0
1
0.03
1
1
0
0
5
4
5
5
44
5
38
14
32
1
22
14
16
2
1
0
6
11,441
ray-project/ray
rllib/examples/envs/classes/cartpole_with_dict_observation_space.py
rllib.examples.envs.classes.cartpole_with_dict_observation_space.CartPoleWithDictObservationSpace
import numpy as np from gymnasium.envs.classic_control import CartPoleEnv import gymnasium as gym class CartPoleWithDictObservationSpace(CartPoleEnv): """CartPole gym environment that has a dict observation space. However, otherwise, the information content in each observation remains the same. https://g...
class CartPoleWithDictObservationSpace(CartPoleEnv): '''CartPole gym environment that has a dict observation space. However, otherwise, the information content in each observation remains the same. https://github.com/Farama-Foundation/Gymnasium/blob/main/gymnasium/envs/classic_control/cartpole.py # noqa ...
5
1
12
1
10
2
1
0.47
1
1
0
0
4
1
4
4
69
10
40
10
35
19
14
10
9
1
1
0
4
11,442
ray-project/ray
rllib/examples/envs/classes/cartpole_with_large_observation_space.py
rllib.examples.envs.classes.cartpole_with_large_observation_space.CartPoleWithLargeObservationSpace
import gymnasium as gym from gymnasium.envs.classic_control import CartPoleEnv import numpy as np class CartPoleWithLargeObservationSpace(CartPoleEnv): """CartPole gym environment that has a large dict observation space. However, otherwise, the information content in each observation remains the same. ht...
class CartPoleWithLargeObservationSpace(CartPoleEnv): '''CartPole gym environment that has a large dict observation space. However, otherwise, the information content in each observation remains the same. https://github.com/Farama-Foundation/Gymnasium/blob/main/gymnasium/envs/classic_control/cartpole.py #...
5
1
9
1
8
1
1
0.69
1
3
0
0
4
1
4
4
64
10
32
11
27
22
16
11
11
1
1
0
4
11,443
ray-project/ray
rllib/examples/envs/classes/cartpole_with_protobuf_observation_space.py
rllib.examples.envs.classes.cartpole_with_protobuf_observation_space.CartPoleWithProtobufObservationSpace
import numpy as np from ray.rllib.examples.envs.classes.utils.cartpole_observations_proto import CartPoleObservation from gymnasium.envs.classic_control import CartPoleEnv import gymnasium as gym class CartPoleWithProtobufObservationSpace(CartPoleEnv): """CartPole gym environment that has a protobuf observation sp...
class CartPoleWithProtobufObservationSpace(CartPoleEnv): '''CartPole gym environment that has a protobuf observation space. Sometimes, it is more performant for an environment to publish its observations as a protobuf message (instead of a heavily nested Dict). The protobuf message used here is origina...
5
1
7
1
6
1
1
0.63
1
1
0
0
4
1
4
4
51
12
24
14
19
15
22
14
17
1
1
0
4
11,444
ray-project/ray
rllib/examples/envs/classes/cliff_walking_wall_env.py
rllib.examples.envs.classes.cliff_walking_wall_env.CliffWalkingWallEnv
import gymnasium as gym from gymnasium import spaces class CliffWalkingWallEnv(gym.Env): """Modified version of the CliffWalking environment from Farama-Foundation's Gymnasium with walls instead of a cliff. ### Description The board is a 4x12 matrix, with (using NumPy matrix indexing): - [3, 0] or...
class CliffWalkingWallEnv(gym.Env): '''Modified version of the CliffWalking environment from Farama-Foundation's Gymnasium with walls instead of a cliff. ### Description The board is a 4x12 matrix, with (using NumPy matrix indexing): - [3, 0] or obs==36 as the start at bottom-left - [3, 11] or ...
4
1
11
0
9
1
4
0.86
1
1
0
0
3
3
3
3
62
8
29
11
25
25
25
11
21
9
1
2
11
11,445
ray-project/ray
rllib/examples/envs/classes/correlated_actions_env.py
rllib.examples.envs.classes.correlated_actions_env.CorrelatedActionsEnv
import numpy as np from typing import Any, Dict, Optional import gymnasium as gym class CorrelatedActionsEnv(gym.Env): """Environment that can only be solved through an autoregressive action model. In each step, the agent observes a random number (between -1 and 1) and has to choose two actions, a1 (discr...
class CorrelatedActionsEnv(gym.Env): '''Environment that can only be solved through an autoregressive action model. In each step, the agent observes a random number (between -1 and 1) and has to choose two actions, a1 (discrete, 0, 1, or 2) and a2 (cont. between -1 and 1). The reward is constructed suc...
4
3
14
3
7
5
1
1.67
1
4
0
0
3
3
3
3
73
18
21
13
15
35
17
11
13
1
1
0
3
11,446
ray-project/ray
rllib/examples/envs/classes/debug_counter_env.py
rllib.examples.envs.classes.debug_counter_env.DebugCounterEnv
import gymnasium as gym import numpy as np class DebugCounterEnv(gym.Env): """Simple Env that yields a ts counter as observation (0-based). Actions have no effect. The episode length is always 15. Reward is always: current ts % 3. """ def __init__(self, config=None): config = config o...
class DebugCounterEnv(gym.Env): '''Simple Env that yields a ts counter as observation (0-based). Actions have no effect. The episode length is always 15. Reward is always: current ts % 3. ''' def __init__(self, config=None): pass def reset(self, *, seed=None, options=None): ...
5
1
4
0
4
0
1
0.29
1
2
0
0
4
4
4
4
27
5
17
11
12
5
17
11
12
1
1
0
4
11,447
ray-project/ray
rllib/examples/envs/classes/debug_counter_env.py
rllib.examples.envs.classes.debug_counter_env.MultiAgentDebugCounterEnv
from ray.rllib.env.multi_agent_env import MultiAgentEnv import numpy as np import gymnasium as gym class MultiAgentDebugCounterEnv(MultiAgentEnv): def __init__(self, config): super().__init__() self.num_agents = config['num_agents'] self.base_episode_len = config.get('base_episode_len', 10...
class MultiAgentDebugCounterEnv(MultiAgentEnv): def __init__(self, config): pass def reset(self, *, seed=None, options=None): pass def step(self, action_dict): pass
4
0
18
1
15
2
2
0.16
1
4
0
0
3
7
3
3
57
5
45
13
41
7
30
13
26
5
1
2
7
11,448
ray-project/ray
rllib/examples/envs/classes/env_using_remote_actor.py
rllib.examples.envs.classes.env_using_remote_actor.CartPoleWithRemoteParamServer
from gymnasium.utils import seeding import ray from gymnasium.envs.classic_control.cartpole import CartPoleEnv class CartPoleWithRemoteParamServer(CartPoleEnv): """CartPoleMassEnv varies the weights of the cart and the pole.""" def __init__(self, env_config): self.env_config = env_config super...
class CartPoleWithRemoteParamServer(CartPoleEnv): '''CartPoleMassEnv varies the weights of the cart and the pole.''' def __init__(self, env_config): pass def reset(self, *, seed=None, options=None): pass
3
1
20
3
13
5
2
0.37
1
2
0
0
2
7
2
2
44
7
27
13
24
10
20
13
17
3
1
1
4
11,449
ray-project/ray
rllib/examples/envs/classes/env_using_remote_actor.py
rllib.examples.envs.classes.env_using_remote_actor.ParameterStorage
import ray @ray.remote class ParameterStorage: def get_params(self, rng): return {'MASSCART': rng.uniform(low=0.5, high=2.0)}
@ray.remote class ParameterStorage: def get_params(self, rng): pass
3
0
4
0
4
0
1
0
0
0
0
0
1
0
1
1
5
0
5
2
3
0
3
2
1
1
0
0
1
11,450
ray-project/ray
rllib/examples/envs/classes/env_with_subprocess.py
rllib.examples.envs.classes.env_with_subprocess.EnvWithSubprocess
from gymnasium.spaces import Discrete import gymnasium as gym import os import atexit import subprocess class EnvWithSubprocess(gym.Env): """An env that spawns a subprocess.""" UNIQUE_CMD = 'sleep 20' def __init__(self, config): self.UNIQUE_FILE_0 = config['tmp_file1'] self.UNIQUE_FILE_1 =...
class EnvWithSubprocess(gym.Env): '''An env that spawns a subprocess.''' def __init__(self, config): pass def close(self): pass def reset(self, *, seed=None, options=None): pass def step(self, action): pass
5
1
7
0
6
1
2
0.16
1
1
0
0
4
8
4
4
35
6
25
14
20
4
23
14
18
2
1
1
6
11,451
ray-project/ray
rllib/examples/envs/classes/fast_image_env.py
rllib.examples.envs.classes.fast_image_env.FastImageEnv
import gymnasium as gym import numpy as np from gymnasium.spaces import Box, Discrete class FastImageEnv(gym.Env): def __init__(self, config): self.zeros = np.zeros((84, 84, 4)) self.action_space = Discrete(2) self.observation_space = Box(0.0, 1.0, shape=(84, 84, 4), dtype=np.float32) ...
class FastImageEnv(gym.Env): def __init__(self, config): pass def reset(self, *, seed=None, options=None): pass def step(self, action): pass
4
0
4
0
4
0
1
0
1
0
0
0
3
4
3
3
15
2
13
9
9
0
13
9
9
1
1
0
3
11,452
ray-project/ray
rllib/examples/envs/classes/gpu_requiring_env.py
rllib.examples.envs.classes.gpu_requiring_env.GPURequiringEnv
from ray.rllib.examples.envs.classes.simple_corridor import SimpleCorridor import ray import numpy as np class GPURequiringEnv(SimpleCorridor): """A dummy env that requires a GPU in order to work. The env here is a simple corridor env that additionally simulates a GPU check in its constructor via `ray.get...
class GPURequiringEnv(SimpleCorridor): '''A dummy env that requires a GPU in order to work. The env here is a simple corridor env that additionally simulates a GPU check in its constructor via `ray.get_gpu_ids()`. If this returns an empty list, we raise an error. To make this env work, use `num_gpu...
2
1
15
2
8
5
2
1.56
1
2
0
0
1
1
1
1
28
5
9
4
7
14
7
4
5
2
1
1
2
11,453
ray-project/ray
rllib/examples/envs/classes/look_and_push.py
rllib.examples.envs.classes.look_and_push.LookAndPush
import numpy as np import gymnasium as gym class LookAndPush(gym.Env): """Memory-requiring Env: Best sequence of actions depends on prev. states. Optimal behavior: 0) a=0 -> observe next state (s'), which is the "hidden" state. If a=1 here, the hidden state is not observed. 1) a=1 ...
class LookAndPush(gym.Env): '''Memory-requiring Env: Best sequence of actions depends on prev. states. Optimal behavior: 0) a=0 -> observe next state (s'), which is the "hidden" state. If a=1 here, the hidden state is not observed. 1) a=1 to always jump to s=2 (not matter what the p...
4
1
9
1
8
0
3
0.38
1
0
0
0
3
4
3
3
42
6
26
8
22
10
22
8
18
6
1
3
8
11,454
ray-project/ray
rllib/examples/envs/classes/look_and_push.py
rllib.examples.envs.classes.look_and_push.OneHot
import gymnasium as gym import numpy as np class OneHot(gym.Wrapper): def __init__(self, env): super(OneHot, self).__init__(env) self.observation_space = gym.spaces.Box(0.0, 1.0, (env.observation_space.n,)) def reset(self, *, seed=None, options=None): obs, info = self.env.reset(seed=s...
class OneHot(gym.Wrapper): def __init__(self, env): pass def reset(self, *, seed=None, options=None): pass def step(self, action): pass def _encode_obs(self, obs): pass
5
0
3
0
3
0
1
0
1
1
0
0
4
1
4
4
17
3
14
9
9
0
14
9
9
1
1
0
4
11,455
ray-project/ray
rllib/examples/envs/classes/memory_leaking_env.py
rllib.examples.envs.classes.memory_leaking_env.MemoryLeakingEnv
from ray.rllib.utils.annotations import override from ray.rllib.examples.envs.classes.random_env import RandomEnv import uuid class MemoryLeakingEnv(RandomEnv): """An env that leaks very little memory. Useful for proving that our memory-leak tests can catch the slightest leaks. """ def __init__(s...
class MemoryLeakingEnv(RandomEnv): '''An env that leaks very little memory. Useful for proving that our memory-leak tests can catch the slightest leaks. ''' def __init__(self, config=None): pass @override(RandomEnv) def reset(self, *, seed=None, options=None): pass @ove...
6
1
5
1
4
0
1
0.33
1
1
0
0
3
2
3
3
26
6
15
8
9
5
13
6
9
2
1
1
4
11,456
ray-project/ray
rllib/examples/envs/classes/mock_env.py
rllib.examples.envs.classes.mock_env.MockEnv
import gymnasium as gym class MockEnv(gym.Env): """Mock environment for testing purposes. Observation=0, reward=1.0, episode-len is configurable. Actions are ignored. """ def __init__(self, episode_length, config=None): self.episode_length = episode_length self.config = config ...
class MockEnv(gym.Env): '''Mock environment for testing purposes. Observation=0, reward=1.0, episode-len is configurable. Actions are ignored. ''' def __init__(self, episode_length, config=None): pass def reset(self, *, seed=None, options=None): pass def step(self, action...
4
1
4
0
4
0
1
0.29
1
0
0
0
3
5
3
3
22
4
14
10
10
4
14
10
10
1
1
0
3
11,457
ray-project/ray
rllib/examples/envs/classes/mock_env.py
rllib.examples.envs.classes.mock_env.MockEnv2
import numpy as np import gymnasium as gym from typing import Optional class MockEnv2(gym.Env): """Mock environment for testing purposes. Observation=ts (discrete space!), reward=100.0, episode-len is configurable. Actions are ignored. """ metadata = {'render.modes': ['rgb_array']} render_mode...
class MockEnv2(gym.Env): '''Mock environment for testing purposes. Observation=ts (discrete space!), reward=100.0, episode-len is configurable. Actions are ignored. ''' def __init__(self, episode_length): pass def reset(self, *, seed=None, options=None): pass def step(sel...
5
1
5
0
4
1
1
0.32
1
0
0
0
4
5
4
4
35
6
22
13
17
7
20
13
15
2
1
1
5
11,458
ray-project/ray
rllib/examples/envs/classes/mock_env.py
rllib.examples.envs.classes.mock_env.MockEnv3
import gymnasium as gym class MockEnv3(gym.Env): """Mock environment for testing purposes. Observation=ts (discrete space!), reward=100.0, episode-len is configurable. Actions are ignored. """ def __init__(self, episode_length): self.episode_length = episode_length self.i = 0 ...
class MockEnv3(gym.Env): '''Mock environment for testing purposes. Observation=ts (discrete space!), reward=100.0, episode-len is configurable. Actions are ignored. ''' def __init__(self, episode_length): pass def reset(self, *, seed=None, options=None): pass def step(sel...
4
1
4
0
4
0
1
0.31
1
0
0
0
3
4
3
3
21
4
13
9
9
4
13
9
9
1
1
0
3
11,459
ray-project/ray
rllib/examples/envs/classes/mock_env.py
rllib.examples.envs.classes.mock_env.MockVectorEnv
from ray.rllib.utils.annotations import override from ray.rllib.env.vector_env import VectorEnv import gymnasium as gym class MockVectorEnv(VectorEnv): """A custom vector env that uses a single(!) CartPole sub-env. However, this env pretends to be a vectorized one to illustrate how one could create custom...
class MockVectorEnv(VectorEnv): '''A custom vector env that uses a single(!) CartPole sub-env. However, this env pretends to be a vectorized one to illustrate how one could create custom VectorEnvs w/o the need for actual vectorizations of sub-envs under the hood. ''' def __init__(self, episod...
10
1
12
0
10
2
2
0.31
1
2
0
0
5
3
5
5
77
6
54
21
44
17
37
14
31
4
1
2
8
11,460
ray-project/ray
rllib/examples/envs/classes/mock_env.py
rllib.examples.envs.classes.mock_env.VectorizedMockEnv
from ray.rllib.env.vector_env import VectorEnv import gymnasium as gym from ray.rllib.utils.annotations import override class VectorizedMockEnv(VectorEnv): """Vectorized version of the MockEnv. Contains `num_envs` MockEnv instances, each one having its own `episode_length` horizon. """ def __init...
class VectorizedMockEnv(VectorEnv): '''Vectorized version of the MockEnv. Contains `num_envs` MockEnv instances, each one having its own `episode_length` horizon. ''' def __init__(self, episode_length, num_envs): pass @override(VectorEnv) def vector_reset(self, *, seeds=None, optio...
10
1
7
0
7
0
1
0.1
1
4
1
0
5
1
5
5
49
6
39
15
29
4
23
11
17
2
1
1
6
11,461
ray-project/ray
rllib/examples/envs/classes/multi_agent/bandit_envs_discrete.py
rllib.examples.envs.classes.multi_agent.bandit_envs_discrete.LinearDiscreteEnv
from gymnasium.spaces import Box, Discrete import copy import numpy as np import gymnasium as gym class LinearDiscreteEnv(gym.Env): """Samples data from linearly parameterized arms. The reward for context X and arm i is given by X^T * theta_i, for some latent set of parameters {theta_i : i = 1, ..., k}. ...
class LinearDiscreteEnv(gym.Env): '''Samples data from linearly parameterized arms. The reward for context X and arm i is given by X^T * theta_i, for some latent set of parameters {theta_i : i = 1, ..., k}. The thetas are sampled uniformly at random, the contexts are Gaussian, and Gaussian noise is...
6
1
10
2
8
0
1
0.15
1
4
0
0
5
9
5
5
69
16
46
21
40
7
34
21
28
2
1
1
6
11,462
ray-project/ray
rllib/examples/envs/classes/multi_agent/bandit_envs_discrete.py
rllib.examples.envs.classes.multi_agent.bandit_envs_discrete.SimpleContextualBandit
import random import gymnasium as gym from gymnasium.spaces import Box, Discrete import numpy as np class SimpleContextualBandit(gym.Env): """Simple env w/ 2 states and 3 actions (arms): 0, 1, and 2. Episodes last only for one timestep, possible observations are: [-1.0, 1.0] and [1.0, -1.0], where the fir...
class SimpleContextualBandit(gym.Env): '''Simple env w/ 2 states and 3 actions (arms): 0, 1, and 2. Episodes last only for one timestep, possible observations are: [-1.0, 1.0] and [1.0, -1.0], where the first element is the "current context". The highest reward (+10.0) is received for selecting arm 0 f...
4
1
7
0
7
0
1
0.29
1
0
0
0
3
3
3
3
31
4
21
9
17
6
12
9
8
1
1
0
3
11,463
ray-project/ray
rllib/examples/envs/classes/multi_agent/bandit_envs_discrete.py
rllib.examples.envs.classes.multi_agent.bandit_envs_discrete.WheelBanditEnv
import numpy as np import copy import gymnasium as gym from gymnasium.spaces import Box, Discrete class WheelBanditEnv(gym.Env): """Wheel bandit environment for 2D contexts (see https://arxiv.org/abs/1802.09127). """ DEFAULT_CONFIG_WHEEL = {'delta': 0.5, 'mu_1': 1.2, 'mu_2': 1, 'mu_3': 50, 'std': 0.01}...
class WheelBanditEnv(gym.Env): '''Wheel bandit environment for 2D contexts (see https://arxiv.org/abs/1802.09127). ''' def __init__(self, config=None): pass def _sample_context(self): pass def reset(self, *, seed=None, options=None): pass def step(self, action): ...
6
1
15
2
12
1
2
0.11
1
5
0
0
5
11
5
5
95
15
72
27
66
8
52
27
46
5
1
3
12
11,464
ray-project/ray
rllib/examples/envs/classes/multi_agent/bandit_envs_recommender_system.py
rllib.examples.envs.classes.multi_agent.bandit_envs_recommender_system.ParametricRecSys
from typing import Optional import gymnasium as gym import numpy as np from ray.rllib.utils.numpy import softmax class ParametricRecSys(gym.Env): """A recommendation environment which generates items with visible features randomly (parametric actions). The environment can be configured to be multi-user, i....
class ParametricRecSys(gym.Env): '''A recommendation environment which generates items with visible features randomly (parametric actions). The environment can be configured to be multi-user, i.e. different models will be learned independently for each user, by setting num_users_in_db parameter. ...
6
2
35
3
23
10
2
0.5
1
6
0
0
5
13
5
5
190
19
114
40
100
57
48
29
42
4
1
2
12
11,465
ray-project/ray
rllib/examples/envs/classes/multi_agent/guess_the_number_game.py
rllib.examples.envs.classes.multi_agent.guess_the_number_game.GuessTheNumberGame
import gymnasium as gym from ray.rllib.env.multi_agent_env import MultiAgentEnv class GuessTheNumberGame(MultiAgentEnv): """ We have two players, 0 and 1. Agent 0 has to pick a number between 0, MAX-1 at reset. Agent 1 has to guess the number by asking N questions of whether of the form of "a <number> ...
class GuessTheNumberGame(MultiAgentEnv): ''' We have two players, 0 and 1. Agent 0 has to pick a number between 0, MAX-1 at reset. Agent 1 has to guess the number by asking N questions of whether of the form of "a <number> is higher|lower|equal to the picked number. The action space is MultiDiscret...
4
1
21
2
16
5
3
0.55
1
3
0
0
3
7
3
3
84
10
51
21
47
28
40
21
36
7
1
2
9
11,466
ray-project/ray
rllib/examples/envs/classes/multi_agent/pettingzoo_chess.py
rllib.examples.envs.classes.multi_agent.pettingzoo_chess.MultiAgentChess
import copy from pettingzoo import AECEnv from pettingzoo.classic.chess.chess import raw_env as chess_v5 from ray.rllib.env.multi_agent_env import MultiAgentEnv from typing import Dict, Any import numpy as np import chess as ch class MultiAgentChess(MultiAgentEnv): """An interface to the PettingZoo MARL environmen...
class MultiAgentChess(MultiAgentEnv): '''An interface to the PettingZoo MARL environment library. See: https://github.com/Farama-Foundation/PettingZoo Inherits from MultiAgentEnv and exposes a given AEC (actor-environment-cycle) game from the PettingZoo project via the MultiAgentEnv public API. ...
15
1
9
1
8
0
2
0.73
1
8
0
0
12
5
12
12
218
38
104
33
85
76
76
27
63
5
1
2
21
11,467
ray-project/ray
rllib/examples/envs/classes/multi_agent/pettingzoo_connect4.py
rllib.examples.envs.classes.multi_agent.pettingzoo_connect4.MultiAgentConnect4
from ray.rllib.env.multi_agent_env import MultiAgentEnv from pettingzoo.classic.connect_four_v3 import raw_env as connect_four_v3 import copy from typing import Dict, Any from pettingzoo import AECEnv class MultiAgentConnect4(MultiAgentEnv): """An interface to the PettingZoo MARL environment library. See: http...
class MultiAgentConnect4(MultiAgentEnv): '''An interface to the PettingZoo MARL environment library. See: https://github.com/Farama-Foundation/PettingZoo Inherits from MultiAgentEnv and exposes a given AEC (actor-environment-cycle) game from the PettingZoo project via the MultiAgentEnv public API. ...
14
1
9
1
8
0
1
0.84
1
6
0
0
11
5
11
11
204
37
91
31
73
76
63
25
51
5
1
2
16
11,468
ray-project/ray
rllib/examples/envs/classes/multi_agent/rock_paper_scissors.py
rllib.examples.envs.classes.multi_agent.rock_paper_scissors.RockPaperScissors
from ray.rllib.env.multi_agent_env import MultiAgentEnv import gymnasium as gym class RockPaperScissors(MultiAgentEnv): """Two-player environment for the famous rock paper scissors game. # __sphinx_doc_1_end__ Optionally, the "Sheldon Cooper extension" can be activated by passing `sheldon_cooper_mode=...
class RockPaperScissors(MultiAgentEnv): '''Two-player environment for the famous rock paper scissors game. # __sphinx_doc_1_end__ Optionally, the "Sheldon Cooper extension" can be activated by passing `sheldon_cooper_mode=True` into the constructor, in which case two more moves are allowed: Spock a...
4
1
17
3
10
4
1
0.65
1
1
0
0
3
7
3
3
116
19
68
21
64
44
30
21
26
2
1
1
4
11,469
ray-project/ray
rllib/examples/envs/classes/multi_agent/tic_tac_toe.py
rllib.examples.envs.classes.multi_agent.tic_tac_toe.TicTacToe
import gymnasium as gym from ray.rllib.env.multi_agent_env import MultiAgentEnv import numpy as np class TicTacToe(MultiAgentEnv): """A two-player game in which any player tries to complete one row in a 3x3 field. The observation space is Box(0.0, 1.0, (9,)), where each index represents a distinct field o...
class TicTacToe(MultiAgentEnv): '''A two-player game in which any player tries to complete one row in a 3x3 field. The observation space is Box(0.0, 1.0, (9,)), where each index represents a distinct field on a 3x3 board and values of 0.0 mean the field is empty, -1.0 means the opponend owns the field,...
4
1
34
4
22
9
3
0.73
1
1
0
0
3
6
3
3
134
20
66
14
62
48
30
14
26
7
1
2
9
11,470
ray-project/ray
rllib/examples/envs/classes/multi_agent/two_step_game.py
rllib.examples.envs.classes.multi_agent.two_step_game.TwoStepGame
import numpy as np from gymnasium.spaces import Dict, Discrete, MultiDiscrete, Tuple from ray.rllib.env.multi_agent_env import MultiAgentEnv, ENV_STATE class TwoStepGame(MultiAgentEnv): action_space = Discrete(2) def __init__(self, env_config): super().__init__() self.action_space = Discrete(2...
class TwoStepGame(MultiAgentEnv): def __init__(self, env_config): pass def reset(self, *, seed=None, options=None): pass def step(self, action_dict): pass def _obs(self): pass def agent_1_obs(self): pass def agent_2_obs(self): pass
7
0
15
0
14
1
3
0.05
1
1
0
0
6
8
6
6
95
8
83
25
76
4
60
25
53
7
1
2
18
11,471
ray-project/ray
rllib/examples/envs/classes/multi_agent/two_step_game.py
rllib.examples.envs.classes.multi_agent.two_step_game.TwoStepGameWithGroupedAgents
from gymnasium.spaces import Dict, Discrete, MultiDiscrete, Tuple from ray.rllib.env.multi_agent_env import MultiAgentEnv, ENV_STATE class TwoStepGameWithGroupedAgents(MultiAgentEnv): def __init__(self, env_config): self._agent_ids = {'agents'} super().__init__() env = TwoStepGame(env_conf...
class TwoStepGameWithGroupedAgents(MultiAgentEnv): def __init__(self, env_config): pass def reset(self, *, seed=None, options=None): pass def step(self, actions): pass
4
0
6
0
6
0
1
0
1
2
1
0
3
4
3
3
20
2
18
11
14
0
14
11
10
1
1
0
3
11,472
ray-project/ray
rllib/examples/envs/classes/nested_space_repeat_after_me_env.py
rllib.examples.envs.classes.nested_space_repeat_after_me_env.NestedSpaceRepeatAfterMeEnv
import numpy as np import tree from ray.rllib.utils.spaces.space_utils import flatten_space import gymnasium as gym from gymnasium.spaces import Box, Dict, Discrete, Tuple class NestedSpaceRepeatAfterMeEnv(gym.Env): """Env for which policy has to repeat the (possibly complex) observation. The action space and...
class NestedSpaceRepeatAfterMeEnv(gym.Env): '''Env for which policy has to repeat the (possibly complex) observation. The action space and observation spaces are always the same and may be arbitrarily nested Dict/Tuple Spaces. Rewards are given for exactly matching Discrete sub-actions and for being ...
5
1
8
0
7
1
2
0.28
1
1
0
0
4
7
4
4
42
5
29
15
24
8
25
15
20
5
1
2
8
11,473
ray-project/ray
rllib/examples/envs/classes/parametric_actions_cartpole.py
rllib.examples.envs.classes.parametric_actions_cartpole.ParametricActionsCartPole
import numpy as np from gymnasium.spaces import Box, Dict, Discrete import gymnasium as gym import random class ParametricActionsCartPole(gym.Env): """Parametric action version of CartPole. In this env there are only ever two valid actions, but we pretend there are actually up to `max_avail_actions` actio...
class ParametricActionsCartPole(gym.Env): '''Parametric action version of CartPole. In this env there are only ever two valid actions, but we pretend there are actually up to `max_avail_actions` actions that can be taken, and the two valid actions are randomly hidden among this set. At each step, w...
5
1
14
0
13
0
2
0.35
1
2
0
0
4
9
4
4
80
7
54
17
49
19
29
17
24
3
1
1
6
11,474
ray-project/ray
rllib/examples/envs/classes/parametric_actions_cartpole.py
rllib.examples.envs.classes.parametric_actions_cartpole.ParametricActionsCartPoleNoEmbeddings
from gymnasium.spaces import Box, Dict, Discrete import random import gymnasium as gym import numpy as np class ParametricActionsCartPoleNoEmbeddings(gym.Env): """Same as the above ParametricActionsCartPole. However, action embeddings are not published inside observations, but will be learnt by the model....
class ParametricActionsCartPoleNoEmbeddings(gym.Env): '''Same as the above ParametricActionsCartPole. However, action embeddings are not published inside observations, but will be learnt by the model. At each step, we emit a dict of: - the actual cart observation - a mask of valid actio...
4
1
14
0
13
0
2
0.24
1
2
0
0
3
6
3
3
56
5
41
13
37
10
20
13
16
3
1
1
5
11,475
ray-project/ray
rllib/examples/envs/classes/random_env.py
rllib.examples.envs.classes.random_env.RandomEnv
import gymnasium as gym import copy import numpy as np from gymnasium.spaces import Discrete, Tuple class RandomEnv(gym.Env): """A randomly acting environment. Can be instantiated with arbitrary action-, observation-, and reward spaces. Observations and rewards are generated by simply sampling from the ...
class RandomEnv(gym.Env): '''A randomly acting environment. Can be instantiated with arbitrary action-, observation-, and reward spaces. Observations and rewards are generated by simply sampling from the observation/reward spaces. The probability of a `terminated=True` after each action can be conf...
4
1
27
1
21
5
4
0.32
1
2
0
2
3
10
3
3
91
8
63
16
59
20
35
16
31
6
1
1
11
11,476
ray-project/ray
rllib/examples/envs/classes/random_env.py
rllib.examples.envs.classes.random_env.RandomLargeObsSpaceEnv
import gymnasium as gym class RandomLargeObsSpaceEnv(RandomEnv): def __init__(self, config=None): config = config or {} config.update({'observation_space': gym.spaces.Box(-1.0, 1.0, (5000,))}) super().__init__(config=config)
class RandomLargeObsSpaceEnv(RandomEnv): def __init__(self, config=None): pass
2
0
4
0
4
0
1
0
1
1
0
0
1
0
1
4
5
0
5
2
3
0
5
2
3
1
2
0
1
11,477
ray-project/ray
rllib/examples/envs/classes/random_env.py
rllib.examples.envs.classes.random_env.RandomLargeObsSpaceEnvContActions
import gymnasium as gym class RandomLargeObsSpaceEnvContActions(RandomEnv): def __init__(self, config=None): config = config or {} config.update({'observation_space': gym.spaces.Box(-1.0, 1.0, (5000,)), 'action_space': gym.spaces.Box(-1.0, 1.0, (5,))}) super().__init__(config=config)
class RandomLargeObsSpaceEnvContActions(RandomEnv): def __init__(self, config=None): pass
2
0
9
0
9
0
1
0
1
1
0
0
1
0
1
4
10
0
10
2
8
0
5
2
3
1
2
0
1
11,478
ray-project/ray
rllib/examples/envs/classes/recommender_system_envs_with_recsim.py
rllib.examples.envs.classes.recommender_system_envs_with_recsim.SingleClusterIEvVideo
from recsim.environments import long_term_satisfaction as lts, interest_evolution as iev, interest_exploration as iex class SingleClusterIEvVideo(iev.IEvVideo): def __init__(self, doc_id, features, video_length=None, quality=None): super(SingleClusterIEvVideo, self).__init__(doc_id=doc_id, features=featur...
class SingleClusterIEvVideo(iev.IEvVideo): def __init__(self, doc_id, features, video_length=None, quality=None): pass
2
0
8
0
8
1
1
0.11
1
1
0
0
1
0
1
1
9
0
9
2
7
1
3
2
1
1
1
0
1
11,479
ray-project/ray
rllib/examples/envs/classes/repeat_after_me_env.py
rllib.examples.envs.classes.repeat_after_me_env.RepeatAfterMeEnv
import numpy as np from gymnasium.spaces import Box, Discrete import gymnasium as gym class RepeatAfterMeEnv(gym.Env): """Env in which the observation at timestep minus n must be repeated.""" def __init__(self, config=None): config = config or {} if config.get('continuous'): self.o...
class RepeatAfterMeEnv(gym.Env): '''Env in which the observation at timestep minus n must be repeated.''' def __init__(self, config=None): pass def reset(self, *, seed=None, options=None): pass def step(self, action): pass def _next_obs(self): pass
5
1
9
1
7
1
2
0.17
1
0
0
0
4
5
4
4
42
7
30
14
25
5
28
14
23
4
1
1
9
11,480
ray-project/ray
rllib/examples/envs/classes/repeat_initial_obs_env.py
rllib.examples.envs.classes.repeat_initial_obs_env.RepeatInitialObsEnv
import random import gymnasium as gym from gymnasium.spaces import Discrete class RepeatInitialObsEnv(gym.Env): """Env in which the initial observation has to be repeated all the time. Runs for n steps. r=1 if action correct, -1 otherwise (max. R=100). """ def __init__(self, episode_len=100): ...
class RepeatInitialObsEnv(gym.Env): '''Env in which the initial observation has to be repeated all the time. Runs for n steps. r=1 if action correct, -1 otherwise (max. R=100). ''' def __init__(self, episode_len=100): pass def reset(self, *, seed=None, options=None): pass ...
4
1
6
0
6
0
1
0.21
1
0
0
0
3
5
3
3
27
4
19
11
15
4
18
11
14
2
1
1
4
11,481
ray-project/ray
rllib/examples/envs/classes/simple_corridor.py
rllib.examples.envs.classes.simple_corridor.SimpleCorridor
import gymnasium as gym from gymnasium.spaces import Box, Discrete import numpy as np class SimpleCorridor(gym.Env): """Example of a custom env in which you have to walk down a corridor. You can configure the length of the corridor via the env config.""" def __init__(self, config=None): config = ...
class SimpleCorridor(gym.Env): '''Example of a custom env in which you have to walk down a corridor. You can configure the length of the corridor via the env config.''' def __init__(self, config=None): pass def set_corridor_length(self, length): pass def reset(self, *, seed=None,...
6
1
6
1
5
0
2
0.08
1
0
0
0
5
4
5
5
37
9
26
13
20
2
25
13
19
4
1
1
8
11,482
ray-project/ray
rllib/examples/envs/classes/simple_rpg.py
rllib.examples.envs.classes.simple_rpg.SimpleRPG
from ray.rllib.utils.spaces.repeated import Repeated import gymnasium as gym from gymnasium.spaces import Discrete, Box, Dict class SimpleRPG(gym.Env): """Example of a custom env with a complex, structured observation. The observation is a list of players, each of which is a Dict of attributes, and may fu...
class SimpleRPG(gym.Env): '''Example of a custom env with a complex, structured observation. The observation is a list of players, each of which is a Dict of attributes, and may further hold a list of items (categorical space). Note that the env doesn't train, it's just a dummy example to show how to ...
4
1
9
1
6
1
1
0.53
1
0
0
0
3
6
3
3
38
9
19
10
15
10
12
10
8
1
1
0
3
11,483
ray-project/ray
rllib/examples/envs/classes/six_room_env.py
rllib.examples.envs.classes.six_room_env.HierarchicalSixRoomEnv
import gymnasium as gym from ray.rllib.env.multi_agent_env import MultiAgentEnv class HierarchicalSixRoomEnv(MultiAgentEnv): def __init__(self, config=None): super().__init__() self.map = config.get('custom_map', MAPS.get(config.get('map'), MAPS['small'])) self.max_steps_low_level = config...
class HierarchicalSixRoomEnv(MultiAgentEnv): def __init__(self, config=None): pass def reset(self, *, seed=None, options=None): pass def step(self, action_dict): pass @property def _agent_discrete_pos(self): pass @staticmethod def eucl_dist(pos1, pos2, map...
8
0
38
3
29
7
2
0.24
1
3
0
0
4
13
5
5
196
19
146
33
138
35
59
31
53
6
1
3
10
11,484
ray-project/ray
rllib/examples/envs/classes/six_room_env.py
rllib.examples.envs.classes.six_room_env.SixRoomEnv
import gymnasium as gym class SixRoomEnv(gym.Env): """A grid-world with six rooms (arranged as 2x3), which are connected by doors. The agent starts in the upper left room and has to reach a designated goal state in one of the rooms using primitive actions up, left, down, and right. The agent receives...
class SixRoomEnv(gym.Env): '''A grid-world with six rooms (arranged as 2x3), which are connected by doors. The agent starts in the upper left room and has to reach a designated goal state in one of the rooms using primitive actions up, left, down, and right. The agent receives a small penalty of -0.01 ...
6
1
10
2
6
3
2
0.64
1
1
0
0
4
6
4
4
54
13
25
15
19
16
24
14
19
3
1
1
6
11,485
ray-project/ray
rllib/examples/envs/classes/stateless_cartpole.py
rllib.examples.envs.classes.stateless_cartpole.StatelessCartPole
from gymnasium.envs.classic_control import CartPoleEnv from gymnasium.spaces import Box import numpy as np class StatelessCartPole(CartPoleEnv): """Partially observable variant of the CartPole gym environment. https://github.com/openai/gym/blob/master/gym/envs/classic_control/ cartpole.py We delete t...
class StatelessCartPole(CartPoleEnv): '''Partially observable variant of the CartPole gym environment. https://github.com/openai/gym/blob/master/gym/envs/classic_control/ cartpole.py We delete the x- and angular velocity components of the state, so that it can only be solved by a memory enhanced mo...
4
1
7
1
5
1
1
0.53
1
1
0
0
3
1
3
3
33
7
17
8
13
9
11
8
7
1
1
0
3
11,486
ray-project/ray
rllib/examples/envs/classes/stateless_pendulum.py
rllib.examples.envs.classes.stateless_pendulum.StatelessPendulum
from gymnasium.spaces import Box from gymnasium.envs.classic_control import PendulumEnv import numpy as np class StatelessPendulum(PendulumEnv): """Partially observable variant of the Pendulum gym environment. https://github.com/Farama-Foundation/Gymnasium/blob/main/gymnasium/envs/ classic_control/pendulu...
class StatelessPendulum(PendulumEnv): '''Partially observable variant of the Pendulum gym environment. https://github.com/Farama-Foundation/Gymnasium/blob/main/gymnasium/envs/ classic_control/pendulum.py We delete the angular velocity component of the state, so that it can only be solved by a memor...
4
1
6
1
4
1
1
0.69
1
1
0
0
3
1
3
3
29
7
13
9
9
9
13
9
9
1
1
0
3
11,487
ray-project/ray
rllib/examples/envs/classes/transformed_action_space_env.py
rllib.examples.envs.classes.transformed_action_space_env.ActionTransform
import gymnasium as gym class ActionTransform(gym.ActionWrapper): def __init__(self, env, low, high): super().__init__(env) self._low = low self._high = high self.action_space = type(env.action_space)(self._low, self._high, env.action_space.shape, env.action_space.dtype) def a...
class ActionTransform(gym.ActionWrapper): def __init__(self, env, low, high): pass def action(self, action): pass
3
0
6
0
6
0
1
0
1
2
0
0
2
3
2
2
13
1
12
6
9
0
8
6
5
1
1
0
2
11,488
ray-project/ray
rllib/examples/envs/classes/windy_maze_env.py
rllib.examples.envs.classes.windy_maze_env.HierarchicalWindyMazeEnv
from ray.rllib.env import MultiAgentEnv class HierarchicalWindyMazeEnv(MultiAgentEnv): def __init__(self, env_config): super().__init__() self.flat_env = WindyMazeEnv(env_config) def reset(self, *, seed=None, options=None): self.cur_obs, infos = self.flat_env.reset() self.curr...
class HierarchicalWindyMazeEnv(MultiAgentEnv): def __init__(self, env_config): pass def reset(self, *, seed=None, options=None): pass def step(self, action_dict): pass def _high_level_step(self, action): pass def _low_level_step(self, action): pass
6
0
13
1
12
1
2
0.08
1
4
1
0
5
6
5
5
72
8
59
23
53
5
53
23
47
5
1
2
10
11,489
ray-project/ray
rllib/examples/envs/classes/windy_maze_env.py
rllib.examples.envs.classes.windy_maze_env.WindyMazeEnv
from gymnasium.spaces import Box, Discrete, Tuple import gymnasium as gym import random class WindyMazeEnv(gym.Env): def __init__(self, env_config): self.map = [m for m in MAP_DATA.split('\n') if m] self.x_dim = len(self.map) self.y_dim = len(self.map[0]) logger.info('Loaded map {}...
class WindyMazeEnv(gym.Env): def __init__(self, env_config): pass def reset(self, *, seed=None, options=None): pass def step(self, action): pass def _get_new_pos(self, pos, direction): pass
5
0
15
0
15
1
4
0.08
1
2
0
0
4
10
4
4
62
3
59
21
54
5
37
21
32
6
1
3
14
11,490
ray-project/ray
rllib/examples/envs/custom_env_render_method.py
rllib.examples.envs.custom_env_render_method.CustomRenderedCorridorEnv
from gymnasium.spaces import Box, Discrete import gymnasium as gym from PIL import Image, ImageDraw import numpy as np class CustomRenderedCorridorEnv(gym.Env): """Example of a custom env, for which we specify rendering behavior.""" def __init__(self, config): self.end_pos = config.get('corridor_lengt...
class CustomRenderedCorridorEnv(gym.Env): '''Example of a custom env, for which we specify rendering behavior.''' def __init__(self, config): pass def reset(self, *, seed=None, options=None): pass def step(self, action): pass def render(self) -> np._typing.NDArray[np.uin...
5
2
16
2
10
5
2
0.51
1
0
0
0
4
6
4
4
70
11
39
19
34
20
32
19
27
4
1
1
7
11,491
ray-project/ray
rllib/examples/envs/custom_gym_env.py
rllib.examples.envs.custom_gym_env.SimpleCorridor
import gymnasium as gym from gymnasium.spaces import Discrete, Box import numpy as np from typing import Optional import random class SimpleCorridor(gym.Env): """Example of a custom env in which the agent has to walk down a corridor. ------------ |S........G| ------------ , where S is the starting...
class SimpleCorridor(gym.Env): '''Example of a custom env in which the agent has to walk down a corridor. ------------ |S........G| ------------ , where S is the starting position, G is the goal position, and fields with '.' mark free spaces, over which the agent may step. The length of the abo...
4
1
11
0
9
2
2
0.68
1
1
0
0
3
4
3
3
53
6
28
12
24
19
21
12
17
4
1
1
6
11,492
ray-project/ray
rllib/examples/envs/env_rendering_and_recording.py
rllib.examples.envs.env_rendering_and_recording.EnvRenderCallback
from typing import Optional, Sequence from ray.rllib.utils.images import resize from ray.rllib.callbacks.callbacks import RLlibCallback from ray.rllib.env.vector.vector_multi_agent_env import VectorMultiAgentEnv import numpy as np import gymnasium as gym class EnvRenderCallback(RLlibCallback): """A custom callback...
class EnvRenderCallback(RLlibCallback): '''A custom callback to render the environment. This can be used to create videos of the episodes for some or all EnvRunners and some or all env indices (in a vectorized env). These videos can then be sent to e.g. WandB as shown in this example script here. W...
5
5
36
2
20
14
3
0.79
1
3
0
0
4
3
4
4
158
15
80
39
48
63
32
12
27
4
1
2
11
11,493
ray-project/ray
rllib/examples/evaluation/evaluation_parallel_to_training.py
rllib.examples.evaluation.evaluation_parallel_to_training.AssertEvalCallback
from ray.rllib.utils.metrics import ENV_RUNNER_RESULTS, EPISODE_RETURN_MEAN, EVALUATION_RESULTS, NUM_EPISODES, NUM_ENV_STEPS_SAMPLED, NUM_ENV_STEPS_SAMPLED_LIFETIME from ray.rllib.utils.metrics.metrics_logger import MetricsLogger from ray.rllib.callbacks.callbacks import RLlibCallback from ray.rllib.algorithms.algorith...
class AssertEvalCallback(RLlibCallback): def on_train_result(self, *, algorithm: Algorithm, metrics_logger: Optional[MetricsLogger]=None, result: ResultDict, **kwargs): pass
2
0
64
1
35
28
5
0.78
1
0
0
0
1
0
1
1
65
1
36
13
27
28
14
6
12
5
1
2
5
11,494
ray-project/ray
rllib/examples/gpus/float16_training_and_inference.py
rllib.examples.gpus.float16_training_and_inference.Float16GradScaler
import torch class Float16GradScaler: """Custom grad scaler for `TorchLearner`. This class is utilizing the experimental support for the `TorchLearner`'s support for loss/gradient scaling (analogous to how a `torch.amp.GradScaler` would work). TorchLearner performs the following steps using this clas...
class Float16GradScaler: '''Custom grad scaler for `TorchLearner`. This class is utilizing the experimental support for the `TorchLearner`'s support for loss/gradient scaling (analogous to how a `torch.amp.GradScaler` would work). TorchLearner performs the following steps using this class (`scaler`): ...
6
1
9
0
8
1
3
0.45
0
0
0
0
5
6
5
5
65
7
40
20
28
18
33
14
27
7
0
4
13
11,495
ray-project/ray
rllib/examples/gpus/float16_training_and_inference.py
rllib.examples.gpus.float16_training_and_inference.LargeEpsAdamTorchLearner
from ray.rllib.core.learner.torch.torch_learner import TorchLearner import torch from ray.rllib.algorithms.ppo.torch.ppo_torch_learner import PPOTorchLearner from ray.rllib.utils.annotations import override class LargeEpsAdamTorchLearner(PPOTorchLearner): """A TorchLearner overriding the default optimizer (Adam) t...
class LargeEpsAdamTorchLearner(PPOTorchLearner): '''A TorchLearner overriding the default optimizer (Adam) to use non-default eps.''' @override(TorchLearner) def configure_optimizers_for_module(self, module_id, config): '''Registers an Adam optimizer with a larg epsilon under the given module_id.''...
3
2
17
1
8
8
1
0.9
1
1
0
0
1
0
1
1
21
2
10
4
7
9
4
3
2
1
1
0
1
11,496
ray-project/ray
rllib/examples/gpus/float16_training_and_inference.py
rllib.examples.gpus.float16_training_and_inference.WriteObsAndRewardsAsFloat16
import gymnasium as gym import numpy as np from ray.rllib.connectors.connector_v2 import ConnectorV2 class WriteObsAndRewardsAsFloat16(ConnectorV2): """ConnectorV2 piece preprocessing observations and rewards to be float16. Note that users can also write a gymnasium.Wrapper for observations and rewards to...
class WriteObsAndRewardsAsFloat16(ConnectorV2): '''ConnectorV2 piece preprocessing observations and rewards to be float16. Note that users can also write a gymnasium.Wrapper for observations and rewards to achieve the same thing. ''' def recompute_output_observation_space(self, input_observation_s...
3
1
10
0
10
0
2
0.19
1
0
0
0
2
0
2
2
28
3
21
11
14
4
12
7
9
3
1
2
4
11,497
ray-project/ray
rllib/examples/gpus/mixed_precision_training_float16_inference.py
rllib.examples.gpus.mixed_precision_training_float16_inference.Float16Connector
import numpy as np import gymnasium as gym from ray.rllib.connectors.connector_v2 import ConnectorV2 class Float16Connector(ConnectorV2): """ConnectorV2 piece preprocessing observations and rewards to be float16. Note that users can also write a gymnasium.Wrapper for observations and rewards to achieve th...
class Float16Connector(ConnectorV2): '''ConnectorV2 piece preprocessing observations and rewards to be float16. Note that users can also write a gymnasium.Wrapper for observations and rewards to achieve the same thing. ''' def recompute_output_observation_space(self, input_observation_space, input...
3
1
11
0
11
0
2
0.17
1
0
0
0
2
0
2
2
30
3
23
10
16
4
9
6
6
2
1
1
3
11,498
ray-project/ray
rllib/examples/gpus/mixed_precision_training_float16_inference.py
rllib.examples.gpus.mixed_precision_training_float16_inference.PPOTorchMixedPrecisionLearner
from ray.rllib.algorithms.ppo.torch.ppo_torch_learner import PPOTorchLearner import torch class PPOTorchMixedPrecisionLearner(PPOTorchLearner): def _update(self, *args, **kwargs): with torch.cuda.amp.autocast(): results = super()._update(*args, **kwargs) return results
class PPOTorchMixedPrecisionLearner(PPOTorchLearner): def _update(self, *args, **kwargs): pass
2
0
4
0
4
0
1
0
1
2
0
0
1
0
1
1
5
0
5
3
3
0
5
3
3
1
1
1
1
11,499
ray-project/ray
rllib/examples/learners/classes/custom_ppo_loss_fn_learner.py
rllib.examples.learners.classes.custom_ppo_loss_fn_learner.PPOTorchLearnerWithWeightRegularizerLoss
from ray.rllib.algorithms.ppo import PPOConfig from ray.rllib.utils.typing import ModuleID, TensorType from ray.rllib.utils.annotations import override from ray.rllib.algorithms.ppo.torch.ppo_torch_learner import PPOTorchLearner from typing import Any, Dict class PPOTorchLearnerWithWeightRegularizerLoss(PPOTorchLearne...
class PPOTorchLearnerWithWeightRegularizerLoss(PPOTorchLearner): '''A custom PPO torch learner adding a weight regularizer term to the loss. We compute a naive regularizer term averaging over all parameters of the RLModule and add this mean value (multiplied by the regularizer coefficient) to the base PPO ...
3
1
32
5
26
1
1
0.29
1
3
0
0
1
0
1
1
43
7
28
14
18
8
8
6
6
1
1
0
1