Exemplo n.º 1
0
 def __init__(
     self,
     algorithm: AlgorithmParameters,
     exploration: 'ExplorationParameters',
     memory: 'MemoryParameters',
     networks: Dict[str, NetworkParameters],
     visualization: VisualizationParameters = VisualizationParameters()):
     """
     :param algorithm: the algorithmic parameters
     :param exploration: the exploration policy parameters
     :param memory: the memory module parameters
     :param networks: the parameters for the networks of the agent
     :param visualization: the visualization parameters
     """
     super().__init__()
     self.visualization = visualization
     self.algorithm = algorithm
     self.exploration = exploration
     self.memory = memory
     self.network_wrappers = networks
     self.input_filter = None
     self.output_filter = None
     self.pre_network_filter = NoInputFilter()
     self.full_name_id = None  # TODO: do we really want to hold this parameter here?
     self.name = None
     self.is_a_highest_level_agent = True
     self.is_a_lowest_level_agent = True
     self.task_parameters = None
    def __init__(
            self,
            agent_params: AgentParameters,
            env_params: EnvironmentParameters,
            schedule_params: ScheduleParameters,
            vis_params: VisualizationParameters = VisualizationParameters(),
            preset_validation_params:
        PresetValidationParameters = PresetValidationParameters(),
            name='simple_rl_graph'):
        super().__init__(name, schedule_params, vis_params)
        self.agent_params = agent_params
        self.env_params = env_params
        self.preset_validation_params = preset_validation_params
        self.agent_params.visualization = vis_params

        if self.agent_params.input_filter is None:
            if env_params is not None:
                self.agent_params.input_filter = env_params.default_input_filter(
                )
            else:
                # In cases where there is no environment (e.g. batch-rl and imitation learning), there is nowhere to get
                # a default filter from. So using a default no-filter.
                # When there is no environment, the user is expected to define input/output filters (if required) using
                # the preset.
                self.agent_params.input_filter = NoInputFilter()
        if self.agent_params.output_filter is None:
            if env_params is not None:
                self.agent_params.output_filter = env_params.default_output_filter(
                )
            else:
                self.agent_params.output_filter = NoOutputFilter()
 def __init__(self, level=None):
     super().__init__(level=level)
     self.frame_skip = 1
     self.default_input_filter = NoInputFilter()
     self.default_output_filter = NoOutputFilter()
     self.agents_params = None
     self.non_trainable_agents = None
 def __init__(self, level=None):
     super().__init__(level=level)
     self.frame_skip = 1
     self.default_input_filter = NoInputFilter()
     self.default_output_filter = NoOutputFilter()
     self.agents_params = None
     self.non_trainable_agents = None
     self.run_phase_subject = None
     self.enable_domain_randomization = False
Exemplo n.º 5
0
 def __init__(
     self,
     algorithm: AlgorithmParameters,
     exploration: 'ExplorationParameters',
     memory: 'MemoryParameters',
     networks: Dict[str, NetworkParameters],
     visualization: VisualizationParameters = VisualizationParameters()):
     """
     :param algorithm:
         A class inheriting AlgorithmParameters.
         The parameters used for the specific algorithm used by the agent.
         These parameters can be later referenced in the agent implementation through self.ap.algorithm.
     :param exploration:
         Either a class inheriting ExplorationParameters or a dictionary mapping between action
         space types and their corresponding ExplorationParameters. If a dictionary was used,
         when the agent will be instantiated, the correct exploration policy parameters will be used
         according to the real type of the environment action space.
         These parameters will be used to instantiate the exporation policy.
     :param memory:
         A class inheriting MemoryParameters. It defines all the parameters used by the memory module.
     :param networks:
         A dictionary mapping between network names and their corresponding network parmeters, defined
         as a class inheriting NetworkParameters. Each element will be used in order to instantiate
         a NetworkWrapper class, and all the network wrappers will be stored in the agent under
         self.network_wrappers. self.network_wrappers is a dict mapping between the network name that
         was given in the networks dict, and the instantiated network wrapper.
     :param visualization:
         A class inheriting VisualizationParameters and defining various parameters that can be
         used for visualization purposes, such as printing to the screen, rendering, and saving videos.
     """
     super().__init__()
     self.visualization = visualization
     self.algorithm = algorithm
     self.exploration = exploration
     self.memory = memory
     self.network_wrappers = networks
     self.input_filter = None
     self.output_filter = None
     self.pre_network_filter = NoInputFilter()
     self.full_name_id = None
     self.name = None
     self.is_a_highest_level_agent = True
     self.is_a_lowest_level_agent = True
     self.task_parameters = None
     self.is_batch_rl_training = False
Exemplo n.º 6
0
 def __init__(self, level=None):
     super().__init__(level=level)
     self.frame_skip = 1
     self.default_input_filter = NoInputFilter()
     self.default_output_filter = NoOutputFilter()
schedule_params.heatup_steps = EnvironmentSteps(N)

####################
# DQN Agent Params #
####################
agent_params = DDQNAgentParameters()
agent_params.network_wrappers['main'].learning_rate = 0.00025
agent_params.network_wrappers['main'].heads_parameters = [
    DuelingQHeadParameters()
]
agent_params.memory.max_size = (MemoryGranularity.Transitions, 1000000)
agent_params.algorithm.discount = 0.99
agent_params.algorithm.num_consecutive_playing_steps = EnvironmentSteps(4)
agent_params.exploration.epsilon_schedule = LinearSchedule(
    1, 0.1, (N + 7) * 2000)
agent_params.input_filter = NoInputFilter()
agent_params.output_filter = NoOutputFilter()

###############
# Environment #
###############
env_params = GymEnvironmentParameters()
env_params.level = 'rl_coach.environments.toy_problems.exploration_chain:ExplorationChain'
env_params.additional_simulator_parameters = {
    'chain_length': N,
    'max_steps': N + 7
}

vis_params = VisualizationParameters()

# preset_validation_params = PresetValidationParameters()
Exemplo n.º 8
0
    5: carla.WeatherParameters.MidRainyNoon,
    6: carla.WeatherParameters.HardRainNoon,
    7: carla.WeatherParameters.SoftRainNoon,
    8: carla.WeatherParameters.ClearSunset,
    9: carla.WeatherParameters.CloudySunset,
    10: carla.WeatherParameters.WetSunset,
    11: carla.WeatherParameters.WetCloudySunset,
    12: carla.WeatherParameters.MidRainSunset,
    13: carla.WeatherParameters.HardRainSunset,
    14: carla.WeatherParameters.SoftRainSunset
}

# Set up the input and output filters
# Input filters apply operations to the input space defined, several input filters can be defined. The order is executed sequentially
# Output filters apply operations on the output space defined.
CarlaInputFilter = NoInputFilter()
CarlaOutputFilter = NoOutputFilter()


# Enumerate observation sources
# New observation sources need to be appended here
class SensorTypes(Enum):
    FRONT_CAMERA = "forward_camera"
    LIDAR = "lidar"
    BIRDEYE = "birdeye"


class CarlaEnvironmentParameters(EnvironmentParameters):
    def __init__(self):
        super().__init__()
        self.host = 'localhost'
Exemplo n.º 9
0
 def __init__(self):
     super().__init__()
     self.default_input_filter = NoInputFilter()
     self.default_output_filter = NoOutputFilter()
Exemplo n.º 10
0
class GymEnvironmentParameters(EnvironmentParameters):
    def __init__(self):
        super().__init__()
        self.random_initialization_steps = 0
        self.max_over_num_frames = 1
        self.additional_simulator_parameters = None

    @property
    def path(self):
        return 'rl_coach.environments.gym_environment:GymEnvironment'


"""
Roboschool Environment Components
"""
RoboSchoolInputFilters = NoInputFilter()
RoboSchoolOutputFilters = NoOutputFilter()


class Roboschool(GymEnvironmentParameters):
    def __init__(self):
        super().__init__()
        self.frame_skip = 1
        self.default_input_filter = RoboSchoolInputFilters
        self.default_output_filter = RoboSchoolOutputFilters


gym_roboschool_envs = [
    'inverted_pendulum', 'inverted_pendulum_swingup',
    'inverted_double_pendulum', 'reacher', 'hopper', 'walker2d',
    'half_cheetah', 'ant', 'humanoid', 'humanoid_flagrun',
Exemplo n.º 11
0
class ControlSuiteEnvironmentParameters(EnvironmentParameters):
    def __init__(self, level=None):
        super().__init__(level=level)
        self.observation_type = ObservationType.Measurements
        self.default_input_filter = ControlSuiteInputFilter
        self.default_output_filter = ControlSuiteOutputFilter

    @property
    def path(self):
        return 'rl_coach.environments.control_suite_environment:ControlSuiteEnvironment'


"""
ControlSuite Environment Components
"""
ControlSuiteInputFilter = NoInputFilter()
ControlSuiteOutputFilter = NoOutputFilter()

control_suite_envs = {
    ':'.join(env): ':'.join(env)
    for env in suite.BENCHMARKING
}


# Environment
class ControlSuiteEnvironment(Environment):
    def __init__(
            self,
            level: LevelSelection,
            frame_skip: int,
            visualization_parameters: VisualizationParameters,
Exemplo n.º 12
0
 def __init__(self, level=None):
     super().__init__(level=level)
     self.frame_skip = 1
     self.default_input_filter = NoInputFilter(
     )  # hrmm.. my custom input filter errored out
     self.default_output_filter = NoOutputFilter()