Esempio n. 1
0
 def __init__(self, name, num_states, num_actions, epsilon=0.3, gamma=0.99, alpha=0.95):
     self.controller = ActionValueTable(num_states, num_actions)
     self.controller.initialize(np.random.rand(num_states * num_actions))
     self.learner = Q(gamma=gamma, alpha=alpha)
     self.learner.batchMode = False
     self.learner.explorer.epsilon = epsilon
     LearningAgent.__init__(self, self.controller, self.learner)
     Agent.__init__(self, name)
Esempio n. 2
0
 def __init__(self, outdim, n_actions, random_state, rl_params):
     """ RL agent
     """
     module = SparseActionValueTable(n_actions, random_state)
     module.initialize(0.0)
     learner = EpisodeQ(alpha=rl_params.q_alpha,
                        w=rl_params.q_w,
                        gamma=rl_params.q_gamma)
     learner.explorer = EGreedyExplorer(random_state,
                                        epsilon=rl_params.exp_epsilon,
                                        decay=rl_params.exp_decay)
     LearningAgent.__init__(self, module, learner)
	def __init__(self, _id, module, learner=None):
		#define variaveis da class
		self.id = _id
		self.horizontal_edge = lane.getEdgeID(trafficlights.getControlledLanes(self.id)[0])
		self.vertical_edge = lane.getEdgeID(trafficlights.getControlledLanes(str(_id))[2])
		#define variaveis da classe pai
		self.horizontalLoad = []
		self.verticalLoad = []
		self.averageHorizontal = []
		self.averageVertical = []
		self.nextAction = None
		self.expectedReward = None
		self.tolerance = None
		LearningAgent.__init__(self, module, learner)
Esempio n. 4
0
 def __init__(self,
              name,
              num_states,
              num_actions,
              epsilon=0.3,
              gamma=0.99,
              alpha=0.95):
     self.controller = ActionValueTable(num_states, num_actions)
     self.controller.initialize(np.random.rand(num_states * num_actions))
     self.learner = Q(gamma=gamma, alpha=alpha)
     self.learner.batchMode = False
     self.learner.explorer.epsilon = epsilon
     LearningAgent.__init__(self, self.controller, self.learner)
     Agent.__init__(self, name)
Esempio n. 5
0
 def __init__(self, module, learner = None):
     '''
     Constructor
     '''
     LearningAgent.__init__(self, module, learner)
     self.__rules=[]
     self.__states={}
     self.__input={}
     self.__buffer={}
     # self.__rules.append(BackOffRule())
     self.__rules.append(BackOffRule2())
     self.__rules.append(LocomotionPrimitives())
     self.__states["driveBackStartTime"]=AgentMind.__driveBackStartTime
     self.__states["__lostTrackTurnStartTime"]=AgentMind.__lostTrackTurnStartTime
Esempio n. 6
0
 def __init__(self, module, learner=None):
     '''
     Constructor
     '''
     LearningAgent.__init__(self, module, learner)
     self.__rules = []
     self.__states = {}
     self.__input = {}
     self.__buffer = {}
     # self.__rules.append(BackOffRule())
     self.__rules.append(BackOffRule2())
     self.__rules.append(LocomotionPrimitives())
     self.__states["driveBackStartTime"] = AgentMind.__driveBackStartTime
     self.__states[
         "__lostTrackTurnStartTime"] = AgentMind.__lostTrackTurnStartTime
    def __init__(self, x, y, brain, learner, env):
        LearningAgent.__init__(self, brain.net, learner)
        self.cellType = 3
        self.brain = brain
        self.module = brain.net
        self.learner = learner
        self.env = env
        self.color = cell.BLACK
        self.x = x
        self.y = y
        self.num_interactions = 0
        self.age = 0
        self.colddown = 0

        self.speed = self.Speeds[0]
        self.energy = self.MaxEnergy
        self.food_sensor = 0
        self.hunger_sensor = 0
        self.target = [-1, -1]
    def __init__(self, x, y, brain, learner, env):
        LearningAgent.__init__(self, brain.net, learner)
        self.cellType = 3
        self.brain = brain
        self.module = brain.net
        self.learner = learner
        self.env = env
        self.color = cell.BLACK
        self.x = x
        self.y = y
        self.num_interactions = 0
        self.age = 0
        self.colddown = 0

        self.speed = self.Speeds[0]
        self.energy = self.MaxEnergy
        self.food_sensor = 0;
        self.hunger_sensor = 0;
        self.target = [-1, -1]