From e7a18c147ee7739b83afe818bb67a50c8b796b2e Mon Sep 17 00:00:00 2001 From: "Zili@171" Date: Mon, 25 Mar 2019 05:18:55 -0400 Subject: [PATCH] from 171 --- robustmpc.py | 7 ++----- server.py | 10 +++++----- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/robustmpc.py b/robustmpc.py index f6a1976..e3fbaf7 100644 --- a/robustmpc.py +++ b/robustmpc.py @@ -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 = [] @@ -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 @@ -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]: diff --git a/server.py b/server.py index bf19d31..d2bd9d0 100644 --- a/server.py +++ b/server.py @@ -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 @@ -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 @@ -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'] @@ -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") @@ -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):