Skip to content

Commit

Permalink
from 171
Browse files Browse the repository at this point in the history
  • Loading branch information
mengzili committed Mar 25, 2019
1 parent 3ccc79c commit e7a18c1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
7 changes: 2 additions & 5 deletions robustmpc.py
Expand Up @@ -29,6 +29,8 @@
# NN_MODEL = './models/nn_model_ep_5900.ckpt'

CHUNK_COMBO_OPTIONS = []
for combo in itertools.product([0, 1, 2, 3, 4, 5], repeat=5):
CHUNK_COMBO_OPTIONS.append(combo)

# past errors in bandwidth
past_errors = []
Expand Down Expand Up @@ -70,10 +72,6 @@ def main(self, args, net_env=None):

video_count = 0

# make chunk combination options
for combo in itertools.product([0, 1, 2, 3, 4, 5], repeat=5):
CHUNK_COMBO_OPTIONS.append(combo)

while True: # serve video forever
# the action is from the last decision
# this is to make the framework similar to the real
Expand Down Expand Up @@ -241,7 +239,6 @@ def predict(self, state):
# bitrates are in Mbits/s, rebuffer in seconds, and smoothness_diffs in Mbits/s

reward = (bitrate_sum / 1000.) - (REBUF_PENALTY * curr_rebuffer_time) - (smoothness_diffs / 1000.)
# reward = bitrate_sum - (8*curr_rebuffer_time) - (smoothness_diffs)

if reward >= max_reward:
if (best_combo != ()) and best_combo[0] < combo[0]:
Expand Down
10 changes: 5 additions & 5 deletions server.py
Expand Up @@ -79,7 +79,7 @@ def do_POST(self):
video_chunk_remain = env_post_data['video_chunk_remain']
next_video_chunk_sizes = env_post_data['next_video_chunk_sizes']

if self.args == 'pensieve':
if self.args.abr == 'pensieve':
state = np.zeros((S_INFO_P, S_LEN))
state[0, -1] = VIDEO_BIT_RATE[last_bit_rate] / float(np.max(VIDEO_BIT_RATE)) # last quality
state[1, -1] = buffer_size / BUFFER_NORM_FACTOR # 10 sec
Expand All @@ -90,7 +90,7 @@ def do_POST(self):

bit_rate = self.teacher.predict(state)

elif self.args == 'robustmpc':
elif self.args.abr == 'robustmpc':
state = np.zeros((S_INFO_R, S_LEN))
state[0, -1] = VIDEO_BIT_RATE[last_bit_rate] / float(np.max(VIDEO_BIT_RATE)) # last quality
state[1, -1] = buffer_size / BUFFER_NORM_FACTOR
Expand All @@ -100,7 +100,7 @@ def do_POST(self):

bit_rate = self.teacher.predict(state)

elif self.args == 'hotdash':
elif self.args.abr == 'hotdash':
hotspot_chunks_remain = env_post_data['hotspot_chunks_remain']
last_hotspot_bit_rate = env_post_data['last_hotspot_bit_rate']
next_hotspot_chunk_sizes = env_post_data['next_hotspot_chunk_sizes']
Expand Down Expand Up @@ -155,7 +155,7 @@ def do_POST(self):
self.send_header('Content-Length', len(send_data))
self.send_header('Access-Control-Allow-Origin', "*")
self.end_headers()
self.wfile.write(send_data)
self.wfile.write(bytes(send_data, encoding='utf-8'))

def do_GET(self):
print("do_GET")
Expand All @@ -165,7 +165,7 @@ def do_GET(self):
content = "RL Server No Training: {}".format(input_dict['log_file_path'])
self.send_header('Content-Length', len(content))
self.end_headers()
self.wfile.write(content)
self.wfile.write(bytes(content, encoding='utf-8'))
mlog(fnc="do_GET()", msg="Response to GET req: {}".format(content))

def log_message(self, format, *args):
Expand Down

0 comments on commit e7a18c1

Please sign in to comment.