forked from m312z/simple_satellite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRL_Test.py
More file actions
33 lines (27 loc) · 1013 Bytes
/
RL_Test.py
File metadata and controls
33 lines (27 loc) · 1013 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import os
from simulation.RL_env import SimpleSat
from simulation.Simulation import SatelliteSim
from stable_baselines3 import PPO as agent
print('')
for filename in os.listdir("./RL/Agent"):
filename=filename[:-4]
print(filename)
filename = input('\nwhich file to evaluate? \n')
model = agent.load('RL/Agent/'+filename)
file_list = filename.split('_')
R_p = int(file_list[4])
Reward_version = int(file_list[3][1])
Simulation_version = int(file_list[1][1])
env = SimpleSat(Write_ouput=True, R_p=R_p, Reward_version=Reward_version, Simulation_version=Simulation_version)
obs = env.reset()
episode_length = SatelliteSim.MAX_ORBITS*env.SatSim.PERIOD
number_of_episodes=1
Total_reward = 0
for i in range(int(episode_length*number_of_episodes)):
action, _states = model.predict(obs)
obs, rewards, dones, info = env.step(action)
Total_reward += rewards
if i%(round(env.SatSim.PERIOD/4))== 0:
print('Accumulated Reward = {}'.format(Total_reward))
env.render()
env.close()