Skip to content

Commit d3185c0

Browse files
author
Rui Li
committed
add jupyter notebook file for plots; readme updates; etc.
1 parent 8fb458c commit d3185c0

File tree

5 files changed

+510
-17
lines changed

5 files changed

+510
-17
lines changed

README.md

+29-4
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,40 @@ Simulation scripts for the mobility management of UAV base stations project main
33

44
# Requirements
55
* python2.7
6-
* numpy
6+
* numpy==1.16.2
77
* tensorflow
88
* IPython
99
* matplotlib
1010

1111
# Files
12-
* main.py
13-
* channel.py
12+
* main.py
13+
** main simulation script with A3C (V. Mnih et al. 2016. Asynchronous methods for deep reinforcement learning. In ICML. 1928–1937.) implementation
14+
** multi-threading to initialise parallel training of multiple workers in parallel spaces (MobiEnvironments)
15+
** each worker creates a MobiEnvironment instance and starts training in this environment
16+
** there is a pair of global AC nets and local AC nets for worker. Workers train their own nets individually while push the gradients to the global nets periodically, then the global nets optimise uploaded gradients from all workers and distribute the same optimal gradients to all workers.
17+
** choices of CNN and MLP are implimented. Default MLP nets perform as well as CNN in prior work with less training complexity
18+
1419
* mobile_env.py
20+
** followed openAI's gym implementation structure for a wireless mobile environment.
21+
** creates a LTE wireless channel which provides computation of SINR values and handover functionality
22+
** step() and step_test() take action from the RL agent and returns updated state, reward, and customisable information to the RL agent. Please be careful here to make the two function consistant. It is not ideal to have two functions one for training and one for testing, but the reason to do this is to enable different user mobility models while keep both training and testing steps computationally cheap (rather than switching between if conditions per step).
23+
** during training the user moves following the group reference model
24+
** during testing the users move using preloaded trace (ue_trace_10k.npy), which is generated from the group reference model
25+
** reward function currently consists of a reward on mean sinr value and a penalty on number of outaged users. which is open for improvement
26+
27+
* channel.py
28+
** downlink and uplink SINR
29+
** In the WAIN work we take only downlink sinr
30+
31+
* ue_mobility.py
32+
** a couple of mobility models for UE's movement
33+
** group reference (X. Hong et al. 1999. A group mobility model for ad hoc wireless networks. In ACM MSWiM. 53–60.) model is used in the WAIN paper. please check the WAIN paper for more details
1534

1635
* main_test.py
36+
** load trained model to test (taking input AC model from ./train/Global_A_PARA%.npy where % can be the training step, 2000 by default)
37+
** test is done on controlled ue mobility trace by loading a file ./ue_trace_10k.npy
38+
** at each test step, the output of nn is argmax-ed to make control decisions of UAV movements
39+
** per step reward, SINR, and computation time are recorded for performance evaluation (output to ./test)
1740

1841
# Build virtual environment
1942
` virtualenv env `
@@ -23,4 +46,6 @@ Simulation scripts for the mobility management of UAV base stations project main
2346
` mkdir train `
2447
` python main.py `
2548

26-
49+
# Run testing
50+
` mkdir test `
51+
` python main_test.py `

coverage_plot.ipynb

+463
Large diffs are not rendered by default.

gradient.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from itertools import product
77

88
FILE_NAME_APPEND = ""
9-
OUTPUT_DIR = "test/"
9+
OUTPUT_DIR = "gradient/"
1010
OUTPUT_FILE_NAME = OUTPUT_DIR + "reward" + FILE_NAME_APPEND
1111
N_BS = 4
1212

@@ -39,7 +39,7 @@ def Choose_Act_Gradient(actual_env, s, n_step):
3939
def Run_Test(reward_file_name):
4040
MAX_STEP = 10000
4141
#if reading mobility trace from file
42-
test_env = MobiEnvironment(N_BS, 40, 100, "read_trace", "../ue_trace_10k.npy")
42+
test_env = MobiEnvironment(N_BS, 40, 100, "read_trace", "./ue_trace_10k.npy")
4343

4444
s = np.array([np.ravel(test_env.reset())])
4545

main_test.py

+15-10
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22
TEST_ALGO = "A3C"
33

44
FILE_NAME_APPEND = "2000"
5-
OUTPUT_FILE_NAME = "test/" + FILE_NAME_APPEND
5+
OUTPUT_FILE_NAME = "test/" + FILE_NAME_APPEND + '_'
66

77
def Load_AC_Net():
8+
"""
9+
Load pre-trained A3C model for testing
10+
"""
811
file_name = "train/Global_A_PARA" + FILE_NAME_APPEND +".npz"
912
files = np.load(file_name)
1013

@@ -18,6 +21,9 @@ def Load_AC_Net():
1821
return G_AC_TEST
1922

2023
def Load_DPPO_Net():
24+
"""
25+
Load pre-trained DDPO model for testing
26+
"""
2127

2228
file_name = "test/PI_PARA" + FILE_NAME_APPEND +".npz"
2329
files = np.load(file_name)
@@ -32,13 +38,13 @@ def Load_DPPO_Net():
3238
return G_PPO_TEST
3339

3440
def Run_Test(g_test_net, reward_file_name):
41+
#maximum training step
3542
MAX_STEP = 10000
36-
#if reading mobility trace from file
43+
44+
#Reading mobility trace from file
3745
test_env = MobiEnvironment(N_BS, 40, 100, "read_trace", "./ue_trace_10k.npy")
38-
#if producing mobility trace
39-
# test_env = MobiEnvironment(N_BS, 40, 100, "group")
40-
# test_env.plot_sinr_map()
4146

47+
#reset states
4248
s = np.array([np.ravel(test_env.reset())])
4349

4450
done = False
@@ -70,10 +76,10 @@ def Run_Test(g_test_net, reward_file_name):
7076
np.save(reward_file_name + "time", time_all)
7177
# np.save("ue_trace_10k", ue_walk_trace)
7278

73-
if step % 5 == 0:
74-
np.save(reward_file_name +"ue_loc" + str(step), test_env.ueLoc)
75-
np.save(reward_file_name +"sinr_map" + str(step), test_env.sinr_map)
76-
np.save(reward_file_name +"assoc_sinr" + str(step), test_env.assoc_sinr)
79+
#if step % 5 == 0:
80+
#np.save(reward_file_name +"ue_loc" + str(step), test_env.ueLoc)
81+
#np.save(reward_file_name +"sinr_map" + str(step), test_env.sinr_map)
82+
#np.save(reward_file_name +"assoc_sinr" + str(step), test_env.assoc_sinr)
7783
# reset the environment every 2000 steps
7884
if step % 2000 == 0:
7985
s = np.array([np.ravel(test_env.reset())])
@@ -88,7 +94,6 @@ def Run_Test(g_test_net, reward_file_name):
8894
np.save(reward_file_name + "reward", reward_buf)
8995
np.save(reward_file_name + "sinr",sinr_all)
9096
np.save(reward_file_name + "time", time_all)
91-
# print np.shape(ue_walk_trace)
9297
# np.save("ue_trace_10k", ue_walk_trace)
9398

9499
if __name__ == "__main__":

ue_mobility.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Python code for 2D random walk.
1+
# Python code for 2D random walk, fixed direction, and group reference point mobility model.
22
import numpy as np
33
import pylab
44
import random

0 commit comments

Comments
 (0)