#1594 - Managed to get the evaluation of rllib agents working. A test has been added to test_primaite_session.py that now tests the full RLlib agent from end-to-end. I;ve also updated the tests in here to check that the mean reward per episode plot is created for both too. This will need a bit of a re-design further down the line, but for now, it works. Added a custom exception for RLlib eval only error.

This commit is contained in:
Chris McCarthy
2023-07-20 19:58:48 +01:00
parent 0a6078df65
commit df52236a7d
9 changed files with 268 additions and 41 deletions

View File

@@ -261,10 +261,12 @@ class Primaite(Env):
self, transaction_writer=True, learning_session=True
)
self.is_eval = False
@property
def actual_episode_count(self) -> int:
"""Shifts the episode_count by -1 for RLlib."""
if self.training_config.agent_framework is AgentFramework.RLLIB:
"""Shifts the episode_count by -1 for RLlib learning session."""
if self.training_config.agent_framework is AgentFramework.RLLIB and not self.is_eval:
return self.episode_count - 1
return self.episode_count
@@ -276,6 +278,7 @@ class Primaite(Env):
self.step_count = 0
self.total_step_count = 0
self.episode_steps = self.training_config.num_eval_steps
self.is_eval = True
def _write_av_reward_per_episode(self) -> None:
if self.actual_episode_count > 0: