本文整理汇总了Python中pybrain.rl.environments.EpisodicTask类的典型用法代码示例。如果您正苦于以下问题:Python EpisodicTask类的具体用法?Python EpisodicTask怎么用?Python EpisodicTask使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EpisodicTask类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, environment):
EpisodicTask.__init__(self, environment)
self.reward_history = []
self.count = 0
# normalize to (-1, 1)
self.sensor_limits = [(-pi, pi), (-20, 20)]
self.actor_limits = [(-1, 1)]
示例2: performAction
def performAction(self, action):
action = self.action_from_joint_angles(action)
# Carry out the action based on angular velocities
EpisodicTask.performAction(self, action)
return
示例3: reset
def reset(self):
self.reward[0] = 0.0
self.rawReward = 0.0
self.env.reset()
self.action = [self.env.dists[0]] * self.outDim
self.epiStep = 0
EpisodicTask.reset(self)
示例4: performAction
def performAction(self, action):
""" POMDP tasks, as they have discrete actions, can me used by providing either an index,
or an array with a 1-in-n coding (which can be stochastic). """
if type(action) == ndarray:
action = drawIndex(action, tolerant = True)
self.steps += 1
EpisodicTask.performAction(self, action)
示例5: __init__
def __init__(self, env=None, maxsteps=1000, desiredValue=0, location="Portland, OR"):
"""
:key env: (optional) an instance of a CartPoleEnvironment (or a subclass thereof)
:key maxsteps: maximal number of steps (default: 1000)
"""
self.location = location
self.airport_code = weather.airport(location)
self.desiredValue = desiredValue
if env is None:
env = CartPoleEnvironment()
EpisodicTask.__init__(self, env)
self.N = maxsteps
self.t = 0
# scale position and angle, don't scale velocities (unknown maximum)
self.sensor_limits = [(-3, 3)]
for i in range(1, self.outdim):
if isinstance(self.env, NonMarkovPoleEnvironment) and i % 2 == 0:
self.sensor_limits.append(None)
else:
self.sensor_limits.append((-np.pi, np.pi))
# self.sensor_limits = [None] * 4
# actor between -10 and 10 Newton
self.actor_limits = [(-50, 50)]
示例6: performAction
def performAction(self, action):
#Filtered mapping towards performAction of the underlying environment
#The standard Johnnie task uses a PID controller to controll directly angles instead of forces
#This makes most tasks much simpler to learn
isJoints=self.env.getSensorByName('JointSensor') #The joint angles
isSpeeds=self.env.getSensorByName('JointVelocitySensor') #The joint angular velocitys
act=(action+1.0)/2.0*(self.env.cHighList-self.env.cLowList)+self.env.cLowList #norm output to action intervall
action=tanh((act-isJoints-isSpeeds)*16.0)*self.maxPower*self.env.tourqueList #simple PID
EpisodicTask.performAction(self, action)
示例7: __init__
def __init__(self,environment, maxSteps, goalTolerance):
EpisodicTask.__init__(self,environment)
self.env = environment
self.count = 0
self.atGoal = False
self.MAX_STEPS = maxSteps
self.GOAL_TOLERANCE = goalTolerance
self.oldDist = 0
self.reward = 0
示例8: performAction
def performAction(self, action):
""" a filtered mapping towards performAction of the underlying environment. """
# scaling
self.incStep()
action = (action + 1.0) / 2.0 * self.dif + self.env.fraktMin * self.env.dists[0]
#Clipping the maximal change in actions (max force clipping)
action = clip(action, self.action - self.maxSpeed, self.action + self.maxSpeed)
EpisodicTask.performAction(self, action)
self.action = action.copy()
示例9: __init__
def __init__(self, environment=None, batchSize=1):
self.batchSize = batchSize
if environment is None:
self.env = Lander()
else:
self.env = environment
EpisodicTask.__init__(self, self.env)
self.sensor_limits = [(0.0, 200.0), (0.0, 35.0), (0.0, 4.0),
(-6.0, 6.0), (-0.4, 0.4),
(-0.15, 0.15), (0.0, 200.0)]
示例10: performAction
def performAction(self, action):
#Filtered mapping towards performAction of the underlying environment
#The standard Tetra2 task uses a PID controller to control directly angles instead of forces
#This makes most tasks much simpler to learn
isJoints=self.env.getSensorByName('JointSensor') #The joint angles
#print "Pos:", [int(i*10) for i in isJoints]
isSpeeds=self.env.getSensorByName('JointVelocitySensor') #The joint angular velocitys
#print "Speeds:", [int(i*10) for i in isSpeeds]
#print "Action", action, "cHighList",self.env.cHighList , self.env.cLowList
#act=(action+1.0)/2.0*(self.env.cHighList-self.env.cLowList)+self.env.cLowList #norm output to action intervall
#action=tanh(act-isJoints-isSpeeds)*self.maxPower*self.env.tourqueList #simple PID
#print "Action", act[:5]
EpisodicTask.performAction(self, action *self.maxPower*self.env.tourqueList)
示例11: performAction
def performAction(self, action):
#Filtered mapping towards performAction of the underlying environment
#The standard CCRL task uses a PID controller to controll directly angles instead of forces
#This makes most tasks much simpler to learn
self.oldAction = action
#Grasping as reflex depending on the distance to target - comment in for more easy grasping
if abs(abs(self.dist[:3]).sum())<2.0: action[15]=1.0 #self.grepRew=action[15]*.01
else: action[15]=-1.0 #self.grepRew=action[15]*-.03
isJoints=array(self.env.getSensorByName('JointSensor')) #The joint angles
isSpeeds=array(self.env.getSensorByName('JointVelocitySensor')) #The joint angular velocitys
act=(action+1.0)/2.0*(self.env.cHighList-self.env.cLowList)+self.env.cLowList #norm output to action intervall
action=tanh((act-isJoints-0.9*isSpeeds*self.env.tourqueList)*16.0)*self.maxPower*self.env.tourqueList #simple PID
EpisodicTask.performAction(self, action)
示例12: __init__
def __init__(self, env = None, maxsteps = 1000):
if env == None:
env = CarEnvironment()
EpisodicTask.__init__(self, env)
self.N = maxsteps
self.t = 0
# (vel, deg, dist_to_goal, dir_of_goal, direction_diff)
self.sensor_limits = [(-30.0, 100.0),
(0.0, 360.0),
(0.0, variables.grid_size*2),
(-180.0, 180.0),
(-180.0, 180.0)]
self.actor_limits = [(-1.0, +4.5), (-90.0, +90.0)]
self.rewardscale = 100.0 / env.distance_to_goal
self.total_reward = 0.0
示例13: __init__
def __init__(self, env=None, maxsteps=1000, desiredValue = 0, tolorance = 0.3):
"""
:key env: (optional) an instance of a CartPoleEnvironment (or a subclass thereof)
:key maxsteps: maximal number of steps (default: 1000)
"""
self.desiredValue = desiredValue
EpisodicTask.__init__(self, env)
self.N = maxsteps
self.t = 0
self.tolorance = tolorance
# self.sensor_limits = [None] * 4
# actor between -10 and 10 Newton
self.actor_limits = [(-15, 15)]
示例14: __init__
def __init__(self, env=None, maxsteps=1000):
"""
:key env: (optional) an instance of a ChemotaxisEnv (or a subclass thereof)
:key maxsteps: maximal number of steps (default: 1000)
"""
if env == None:
env = ChemotaxisEnv()
self.env = env
EpisodicTask.__init__(self, env)
self.N = maxsteps
self.t = 0
#self.actor_limits = [(0,1), (0,1)] # scale (-1,1) to motor neurons
self.sensor_limits = [(0,1), (0,1)] # scale sensor neurons to (-1,1)
示例15: __init__
def __init__(self, env=None, maxsteps=1000):
"""
:key env: (optional) an instance of a CartPoleEnvironment (or a subclass thereof)
:key maxsteps: maximal number of steps (default: 1000)
"""
if env == None:
env = CartPoleEnvironment()
EpisodicTask.__init__(self, env)
self.N = maxsteps
self.t = 0
# no scaling of sensors
self.sensor_limits = [None] * 2
# scale actor
self.actor_limits = [(-50, 50)]