代码拉取完成,页面将自动刷新
from __future__ import division, print_function
import numpy as np
from Environment import *
import matplotlib.pyplot as plt
# This py file using the random algorithm.
def main():
up_lanes = [3.5/2,3.5/2 + 3.5,250+3.5/2, 250+3.5+3.5/2, 500+3.5/2, 500+3.5+3.5/2]
down_lanes = [250-3.5-3.5/2,250-3.5/2,500-3.5-3.5/2,500-3.5/2,750-3.5-3.5/2,750-3.5/2]
left_lanes = [3.5/2,3.5/2 + 3.5,433+3.5/2, 433+3.5+3.5/2, 866+3.5/2, 866+3.5+3.5/2]
right_lanes = [433-3.5-3.5/2,433-3.5/2,866-3.5-3.5/2,866-3.5/2,1299-3.5-3.5/2,1299-3.5/2]
width = 750
height = 1299
n = 40
Env = Environ(down_lanes,up_lanes,left_lanes,right_lanes, width, height)
number_of_game = 500
n_step = 1000
V2I_Rate_List = np.zeros([number_of_game, n_step])
Fail_Percent = np.zeros([number_of_game, n_step])
for game_idx in range(number_of_game):
print (game_idx)
Env.new_random_game(n)
for i in range(n_step):
#print(i)
actions = np.random.randint(0,20,[n,3])
power_selection = np.zeros(actions.shape, dtype = 'int')
actions = np.concatenate((actions[..., np.newaxis],power_selection[...,np.newaxis]), axis = 2)
reward, percent = Env.act(actions)
V2I_Rate_List[game_idx, i] = np.sum(reward)
Fail_Percent[game_idx, i] = percent
print(np.sum(reward))
print ('percentage here is ', percent)
print ('The number of vehicles is ', n)
print ('mean of V2I rate is that ', np.mean(V2I_Rate_List))
print ('mean of percent is ', np.mean(Fail_Percent[:,-1]))
main()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。