Professional Documents
Culture Documents
No Op - Py
No Op - Py
/usr/bin/env python3
# -*- coding: utf-8 -*-
import argparse
import time
import numpy as np
from ns3gym import ns3env
port = 5551
simTime = 10 # seconds
stepTime = 0.1 # seconds
seed = 0
simArgs = {"--simTime": simTime,
"--testArg": 123,
"--nodeNum": 5,
"--distance": 500}
debug = False
ob_space = env.observation_space
ac_space = env.action_space
print("Observation space: ", ob_space, ob_space.dtype)
print("Action space: ", ac_space, ac_space.dtype)
stepIdx = 0
currIt = 0
allRxPkts = 0
def get_no_op_action(obs):
# cwValue 0 is not applied, so no_op
action = np.zeros(shape=len(obs), dtype=np.uint32)
return action
try:
while True:
print("Start iteration: ", currIt)
obs = env.reset()
reward = 0
print("Step: ", stepIdx)
print("---obs: ", obs)
while True:
stepIdx += 1
allRxPkts += reward
action = get_no_op_action(obs)
print("---action: ", action)
if done:
stepIdx = 0
print("All rx pkts num: ", allRxPkts)
allRxPkts = 0
currIt += 1
if currIt == iterationNum:
break
except KeyboardInterrupt:
print("Ctrl-C -> Exit")
finally:
env.close()
print("Done")