# Path: HDPy/rl.py
# class Policy(PuPy.RobotActor):
#     """A template for Actor-Critic *policies*. The *Policy* defines how
#     an action is translated into a control (motor) signal. It
#     continously receives action updates from the *Critic* which it has
#     to digest.
#     
#     An additional instance to :py:class:`PuPy.Normalization` may be 
#     supplied in ``norm`` for normalizing sensor values.
#     """
#     def __init__(self, action_space_dim=None, norm=None):
#         super(Policy, self).__init__()
#         self._action_space_dim = action_space_dim
#         self.normalization = None
#         self.set_normalization(norm)
#     
#     def initial_action(self):
#         """Return the initial action. A valid action must be returned
#         since the :py:class:`ActorCritic` relies on the format.
#         
#         The action has to be a 2-dimensional numpy vector, with both
#         dimensions available.
#         """
#         raise NotImplementedError()
#     
#     def update(self, action_upd):
#         """Update the *Policy* according to the current action update
#         ``action_upd``, which was in turn computed by the
#         :py:class:`ActorCritic`.
#         """
#         raise NotImplementedError()
#     
#     def get_iterator(self, time_start_ms, time_end_ms, step_size_ms):
#         """Return an iterator for the *motor_target* sequence, according
#         to the current action configuration.
#         
#         The *motor_targets* glue the *Policy* and *Plant* together.
#         Since they are applied in the robot and effect the sensor
#         readouts, they are an "input" to the environment. As the targets
#         are generated as effect of the action update, they are an output
#         of the policy.
#         
#         """
#         raise NotImplementedError()
#     
#     def action_space_dim(self):
#         """Return the dimension of the action space.
#         This value is equal to the size of the vector returned by
#         :py:meth:`initial_action`.
#         """
#         if self._action_space_dim is None:
#             raise NotImplementedError()
#         return self._action_space_dim
#     
#     def reset(self):
#         """Undo any policy updates."""
#         raise NotImplementedError()
#     
#     def set_normalization(self, norm):
#         """Set the normalization instance to ``norm``."""
#         if norm is None:
#             norm = PuPy.Normalization()
#         self.normalization = norm
#     
#     
#     def __call__(self, epoch, time_start_ms, time_end_ms, step_size_ms):
#         if epoch.has_key('a_next'):
#             self.update(np.atleast_2d(epoch['a_next']).T)
#         return self.get_iterator(time_start_ms, time_end_ms, step_size_ms)
#     
#     def _get_initial_targets(self, time_start_ms, time_end_ms, step_size_ms):
#         return self.__call__({}, time_start_ms, time_end_ms, step_size_ms)


from ...rl import Policy
import numpy as np

# Individual, Three

class IIAPF(_II3):
    """Individual; Amplitude, Phase, Frequency"""
    def __init__(self, gait):
        super(IIAPF, self).__init__(gait, 'amplitude', 'phase', 'frequency')

class IIAPO(_II3):
    """Individual; Amplitude, Phase, Offset"""
    def __init__(self, gait):
        super(IIAPO, self).__init__(gait, 'amplitude', 'phase', 'offset')

class IIAFO(_II3):
    """Individual; Amplitude, Frequency, Offset"""
    def __init__(self, gait):
        super(IIAFO, self).__init__(gait, 'amplitude', 'frequency', 'offset')

class IIPFO(_II3):
    """Individual; Phase, Frequency, Offset"""
    def __init__(self, gait):
        super(IIPFO, self).__init__(gait, 'phase', 'frequency', 'offset')

# Individual, Four

class IIAPFO(_II4):
    """Individual; Amplitude, Phase, Frequency, Offset"""
    pass

# Policy with raw motor targets

# Path: HDPy/rl.py
# class Policy(PuPy.RobotActor):
#     """A template for Actor-Critic *policies*. The *Policy* defines how
#     an action is translated into a control (motor) signal. It
#     continously receives action updates from the *Critic* which it has
#     to digest.
#     
#     An additional instance to :py:class:`PuPy.Normalization` may be 
#     supplied in ``norm`` for normalizing sensor values.
#     """
#     def __init__(self, action_space_dim=None, norm=None):
#         super(Policy, self).__init__()
#         self._action_space_dim = action_space_dim
#         self.normalization = None
#         self.set_normalization(norm)
#     
#     def initial_action(self):
#         """Return the initial action. A valid action must be returned
#         since the :py:class:`ActorCritic` relies on the format.
#         
#         The action has to be a 2-dimensional numpy vector, with both
#         dimensions available.
#         """
#         raise NotImplementedError()
#     
#     def update(self, action_upd):
#         """Update the *Policy* according to the current action update
#         ``action_upd``, which was in turn computed by the
#         :py:class:`ActorCritic`.
#         """
#         raise NotImplementedError()
#     
#     def get_iterator(self, time_start_ms, time_end_ms, step_size_ms):
#         """Return an iterator for the *motor_target* sequence, according
#         to the current action configuration.
#         
#         The *motor_targets* glue the *Policy* and *Plant* together.
#         Since they are applied in the robot and effect the sensor
#         readouts, they are an "input" to the environment. As the targets
#         are generated as effect of the action update, they are an output
#         of the policy.
#         
#         """
#         raise NotImplementedError()
#     
#     def action_space_dim(self):
#         """Return the dimension of the action space.
#         This value is equal to the size of the vector returned by
#         :py:meth:`initial_action`.
#         """
#         if self._action_space_dim is None:
#             raise NotImplementedError()
#         return self._action_space_dim
#     
#     def reset(self):
#         """Undo any policy updates."""
#         raise NotImplementedError()
#     
#     def set_normalization(self, norm):
#         """Set the normalization instance to ``norm``."""
#         if norm is None:
#             norm = PuPy.Normalization()
#         self.normalization = norm
#     
#     
#     def __call__(self, epoch, time_start_ms, time_end_ms, step_size_ms):
#         if epoch.has_key('a_next'):
#             self.update(np.atleast_2d(epoch['a_next']).T)
#         return self.get_iterator(time_start_ms, time_end_ms, step_size_ms)
#     
#     def _get_initial_targets(self, time_start_ms, time_end_ms, step_size_ms):
#         return self.__call__({}, time_start_ms, time_end_ms, step_size_ms)


# Path: HDPy/puppy/policy/policies.py
from ...rl import Policy
import numpy as np


# Individual, Three

class IIAPF(_II3):
    """Individual; Amplitude, Phase, Frequency"""
    def __init__(self, gait):
        super(IIAPF, self).__init__(gait, 'amplitude', 'phase', 'frequency')

class IIAPO(_II3):
    """Individual; Amplitude, Phase, Offset"""
    def __init__(self, gait):
        super(IIAPO, self).__init__(gait, 'amplitude', 'phase', 'offset')

class IIAFO(_II3):
    """Individual; Amplitude, Frequency, Offset"""
    def __init__(self, gait):
        super(IIAFO, self).__init__(gait, 'amplitude', 'frequency', 'offset')

class IIPFO(_II3):
    """Individual; Phase, Frequency, Offset"""
    def __init__(self, gait):
        super(IIPFO, self).__init__(gait, 'phase', 'frequency', 'offset')

# Individual, Four

class IIAPFO(_II4):
    """Individual; Amplitude, Phase, Frequency, Offset"""
    pass

# Policy with raw motor targets

class RawTrgPolicy(Policy):