1 Star 0 Fork 0

zhoub86/ResourceAllocationReinforcementLearning

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Baseline_random.py 1.57 KB
一键复制 编辑 原始数据 按行查看 历史
haoyye 提交于 2019-03-09 11:40 . Initial Version
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()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhoub86/ResourceAllocationReinforcementLearning.git
git@gitee.com:zhoub86/ResourceAllocationReinforcementLearning.git
zhoub86
ResourceAllocationReinforcementLearning
ResourceAllocationReinforcementLearning
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385