예제 #1
0
 def init_mdp_old(self):    
     #get all network nodes
     node_count = len(traci.junction.getIDList())
     mdp = []        
     for node in range(0, node_count):
         no = (self.network.getNode(str(node+1)))
         list_edges = Node.getOutgoing(no)
         #for each node find all outgoing edges
         states = []
         for l in list_edges:
             #add the actions (edges) to the states (nodes): edge-id, q-value, reward (travel time on link)
             states.append([str(Edge.getID(l)), -50*random.random(), -50*random.random()])
         mdp.append(states)
     return mdp
예제 #2
0
 def init_mdp(self):    
     #get all network nodes
     junction_list = traci.junction.getIDList()
     usefull = [i for i in junction_list if not ':' in i]
     mdp = dict([(x, []) for x in usefull])
     for node in usefull:
         no = (self.network.getNode(node))
         list_edges = Node.getOutgoing(no)
         states = dict([(x.getID(), []) for x in list_edges if not ':' in x.getID()])
         #for each node find all outgoing edgesTrue
         for e in list_edges:
             #add the actions (edges) to the states (nodes): edge-id, q-value, reward (travel time on link)
             states[e.getID()] = ([10*random.random(), 10*random.random()])
         mdp[node] = states
     return mdp