original_docstring: 
          Test the experiment's agent whose model is defined with the given checkpoint metagraph for a certain number
          of episodes per volley and a certain number of volleys.
  
          This generates a tensorflow session and initialize both environment and agent associated with the experiment.
          After this is run all test results are accessible as properties.
  
          :param logger: the logger used to print the experiment information, warnings and errors
          :param episodes: the number of episodes for each test volley, must be greater than zero
          :param volleys: the number of test volleys, must be greater than zero
          :param episode_length: the max length in steps of each episode, must be greater than zero
          :param restore_path: the path where the metagraph of the model to test is stored
          :param render: boolean flag to render or not the environment
          
docstring: Test the experiment's agent whose model is defined with the given checkpoint metagraph for a certain number
  of episodes per volley and a certain number of volleys.
  
  This generates a tensorflow session and initialize both environment and agent associated with the experiment.
  After this is run all test results are accessible as properties.
docstring_tokens: Test the experiment ' s agent whose model is defined with the given checkpoint metagraph for a certain number of episodes per volley and a certain number of volleys . This generates a tensorflow session and initialize both environment and agent associated with the experiment . After this is run all test results are accessible as properties .
code: def test(self,
               logger: logging.Logger,
               episodes: int, volleys: int,
               episode_length: int,
               restore_path: str,
               render: bool = True):
          """
          Test the experiment's agent whose model is defined with the given checkpoint metagraph for a certain number
          of episodes per volley and a certain number of volleys.
  
          This generates a tensorflow session and initialize both environment and agent associated with the experiment.
          After this is run all test results are accessible as properties.
  
          :param logger: the logger used to print the experiment information, warnings and errors
          :param episodes: the number of episodes for each test volley, must be greater than zero
          :param volleys: the number of test volleys, must be greater than zero
          :param episode_length: the max length in steps of each episode, must be greater than zero
          :param restore_path: the path where the metagraph of the model to test is stored
          :param render: boolean flag to render or not the environment
          """
          # Make sure parameters are valid
          assert(episodes > 0 and volleys > 0 and episode_length > 0)
          # Start experiment testing process
          logger.info("Experiment " + self._id + ": testing process started")
          # Define the session
          with tensorflow.Session(config=self._tensorflow_config) as session:
              # Initialize the environment and the agent
              logger.info("Initializing the environment...")
              self._environment.initialize(logger, session)
              logger.info("Environment initialized")
              logger.info("Initializing the agent..")
              self._agent.initialize(logger, session)
              logger.info("Agent initialized")
              # Load the pre-trained model at given checkpoint path (if defined) and restore the agent
              if restore_path is None or not restore_path:
                  logger.info("Restoring agent graph without checkpoint path")
              else:
                  logger.info("Restoring agent graph with checkpoint path: " + restore_path)
              if not self._agent.restore(logger, session, restore_path):
                  return
              logger.info("Agent restored")
              # Generate test volley
              self._test_volley = EpisodeVolley(self._environment, self._agent, self._interface, self._parallel,
                                                EpisodeVolleyType.test, self._plots_path, self._plots_dpi,
                                                episodes, episode_length)
              # Execute test volleys
              start: int = self._test_volley_counter
              for volley_index in range(start, volleys):
                  # Setup and run test volley
                  logger.info("Setup of test volley " + str(self._test_volley_counter) + "...")
                  if not self._test_volley.setup():
                      logger.error("Test volley failed to setup. Exiting...")
                      return
                  self._test_volley.run(logger, session, render)
                  # Store test volley statistics
                  self._test_rewards.append(self._test_volley.rewards.copy())
                  self._test_total_rewards.append(self._test_volley.total_rewards.copy())
                  self._test_avg_total_rewards.append(self._test_volley.avg_total_reward)
                  self._test_scaled_rewards.append(self._test_volley.scaled_rewards.copy())
                  self._test_avg_scaled_rewards.append(self._test_volley.avg_scaled_reward)
                  self._test_std_total_rewards.append(self._test_volley.std_total_reward)
                  self._test_std_scaled_rewards.append(self._test_volley.std_scaled_reward)
                  self._test_episode_lengths.append(self._test_volley.episode_lengths.copy())
                  self._test_avg_episode_lengths.append(self._test_volley.avg_episode_length)
                  self._test_avg_actions_durations.append(self._test_volley.avg_action_duration)
                  # Increase test volley counter
                  self._test_volley_counter += 1
              logger.info("End of test")
              # Store the average and the best total and scaled rewards over all test volleys
              self._avg_test_avg_total_reward = numpy.round(numpy.average(self._test_avg_total_rewards), 3)
              self._max_test_avg_total_reward = numpy.round(numpy.max(self._test_avg_total_rewards), 3)
              self._avg_test_avg_scaled_reward = numpy.round(numpy.average(self._test_avg_scaled_rewards), 3)
              self._max_test_avg_scaled_reward = numpy.round(numpy.max(self._test_avg_scaled_rewards), 3)
              # Store the average and the minimum standard deviation of total and scaled rewards over test volleys
              self._avg_test_std_total_reward = numpy.round(numpy.average(self._test_std_total_rewards), 3)
              self._min_test_std_total_reward = numpy.round(numpy.min(self._test_std_total_rewards), 3)
              self._avg_test_std_scaled_reward = numpy.round(numpy.average(self._test_std_scaled_rewards), 3)
              self._min_test_std_scaled_reward = numpy.round(numpy.min(self._test_std_scaled_rewards), 3)
              # Store the average episode length over all test volleys
              self._avg_test_avg_episode_length = numpy.rint(numpy.average(self._test_avg_episode_lengths))
              # Store the max, min and average action duration in milliseconds (msec) over all test volleys
              self._max_test_avg_actions_duration = numpy.round(numpy.max(self._test_avg_actions_durations), 3)
              self._min_test_avg_actions_duration = numpy.round(numpy.min(self._test_avg_actions_durations), 3)
              self._avg_test_avg_actions_duration = numpy.round(numpy.average(self._test_avg_actions_durations), 3)
              # Print test results
              logger.info("Results over " + str(volleys) + " test volleys of " + str(episodes) + " episodes each are:")
              logger.info("Average test total reward: " + str(self._avg_test_avg_total_reward))
              logger.info("Average test scaled reward: " + str(self._avg_test_avg_scaled_reward))
              logger.info("Max test total reward: " + str(self._max_test_avg_total_reward))
              logger.info("Max test scaled reward: " + str(self._max_test_avg_scaled_reward))
              logger.info("Average test standard deviation of total reward: " + str(self._avg_test_std_total_reward))
              logger.info("Average test standard deviation of scaled reward: " + str(self._avg_test_std_scaled_reward))
              logger.info("Min test standard deviation of total reward: " + str(self._min_test_std_total_reward))
              logger.info("Min test standard deviation of scaled reward: " + str(self._min_test_std_scaled_reward))
              logger.info("Average test episode length: " + str(self._avg_test_avg_episode_length))
              logger.info("Max test average action duration: " + str(self._max_test_avg_actions_duration) + " msec")
              logger.info("Min test average action duration: " + str(self._min_test_avg_actions_duration) + " msec")
              logger.info("Average test action duration: " + str(self._avg_test_avg_actions_duration) + " msec")
              # Check if test is successful
              self._successful = self._is_successful(logger)
              if self._successful:
                  logger.info("The experiment terminated successfully")
              else:
                  logger.info("The experiment terminated without meeting the requirements")
code_tokens: def test ( self , logger : logging . Logger , episodes : int , volleys : int , episode_length : int , restore_path : str , render : bool = True ) : assert ( episodes > 0 and volleys > 0 and episode_length > 0 ) logger . info ( "Experiment " + self . _id + ": testing process started" ) with tensorflow . Session ( config = self . _tensorflow_config ) as session : logger . info ( "Initializing the environment..." ) self . _environment . initialize ( logger , session ) logger . info ( "Environment initialized" ) logger . info ( "Initializing the agent.." ) self . _agent . initialize ( logger , session ) logger . info ( "Agent initialized" ) if restore_path is None or not restore_path : logger . info ( "Restoring agent graph without checkpoint path" ) else : logger . info ( "Restoring agent graph with checkpoint path: " + restore_path ) if not self . _agent . restore ( logger , session , restore_path ) : return logger . info ( "Agent restored" ) self . _test_volley = EpisodeVolley ( self . _environment , self . _agent , self . _interface , self . _parallel , EpisodeVolleyType . test , self . _plots_path , self . _plots_dpi , episodes , episode_length ) start : int = self . _test_volley_counter for volley_index in range ( start , volleys ) : logger . info ( "Setup of test volley " + str ( self . _test_volley_counter ) + "..." ) if not self . _test_volley . setup ( ) : logger . error ( "Test volley failed to setup. Exiting..." ) return self . _test_volley . run ( logger , session , render ) self . _test_rewards . append ( self . _test_volley . rewards . copy ( ) ) self . _test_total_rewards . append ( self . _test_volley . total_rewards . copy ( ) ) self . _test_avg_total_rewards . append ( self . _test_volley . avg_total_reward ) self . _test_scaled_rewards . append ( self . _test_volley . scaled_rewards . copy ( ) ) self . _test_avg_scaled_rewards . append ( self . _test_volley . avg_scaled_reward ) self . _test_std_total_rewards . append ( self . _test_volley . std_total_reward ) self . _test_std_scaled_rewards . append ( self . _test_volley . std_scaled_reward ) self . _test_episode_lengths . append ( self . _test_volley . episode_lengths . copy ( ) ) self . _test_avg_episode_lengths . append ( self . _test_volley . avg_episode_length ) self . _test_avg_actions_durations . append ( self . _test_volley . avg_action_duration ) self . _test_volley_counter += 1 logger . info ( "End of test" ) self . _avg_test_avg_total_reward = numpy . round ( numpy . average ( self . _test_avg_total_rewards ) , 3 ) self . _max_test_avg_total_reward = numpy . round ( numpy . max ( self . _test_avg_total_rewards ) , 3 ) self . _avg_test_avg_scaled_reward = numpy . round ( numpy . average ( self . _test_avg_scaled_rewards ) , 3 ) self . _max_test_avg_scaled_reward = numpy . round ( numpy . max ( self . _test_avg_scaled_rewards ) , 3 ) self . _avg_test_std_total_reward = numpy . round ( numpy . average ( self . _test_std_total_rewards ) , 3 ) self . _min_test_std_total_reward = numpy . round ( numpy . min ( self . _test_std_total_rewards ) , 3 ) self . _avg_test_std_scaled_reward = numpy . round ( numpy . average ( self . _test_std_scaled_rewards ) , 3 ) self . _min_test_std_scaled_reward = numpy . round ( numpy . min ( self . _test_std_scaled_rewards ) , 3 ) self . _avg_test_avg_episode_length = numpy . rint ( numpy . average ( self . _test_avg_episode_lengths ) ) self . _max_test_avg_actions_duration = numpy . round ( numpy . max ( self . _test_avg_actions_durations ) , 3 ) self . _min_test_avg_actions_duration = numpy . round ( numpy . min ( self . _test_avg_actions_durations ) , 3 ) self . _avg_test_avg_actions_duration = numpy . round ( numpy . average ( self . _test_avg_actions_durations ) , 3 ) logger . info ( "Results over " + str ( volleys ) + " test volleys of " + str ( episodes ) + " episodes each are:" ) logger . info ( "Average test total reward: " + str ( self . _avg_test_avg_total_reward ) ) logger . info ( "Average test scaled reward: " + str ( self . _avg_test_avg_scaled_reward ) ) logger . info ( "Max test total reward: " + str ( self . _max_test_avg_total_reward ) ) logger . info ( "Max test scaled reward: " + str ( self . _max_test_avg_scaled_reward ) ) logger . info ( "Average test standard deviation of total reward: " + str ( self . _avg_test_std_total_reward ) ) logger . info ( "Average test standard deviation of scaled reward: " + str ( self . _avg_test_std_scaled_reward ) ) logger . info ( "Min test standard deviation of total reward: " + str ( self . _min_test_std_total_reward ) ) logger . info ( "Min test standard deviation of scaled reward: " + str ( self . _min_test_std_scaled_reward ) ) logger . info ( "Average test episode length: " + str ( self . _avg_test_avg_episode_length ) ) logger . info ( "Max test average action duration: " + str ( self . _max_test_avg_actions_duration ) + " msec" ) logger . info ( "Min test average action duration: " + str ( self . _min_test_avg_actions_duration ) + " msec" ) logger . info ( "Average test action duration: " + str ( self . _avg_test_avg_actions_duration ) + " msec" ) self . _successful = self . _is_successful ( logger ) if self . _successful : logger . info ( "The experiment terminated successfully" ) else : logger . info ( "The experiment terminated without meeting the requirements" )
short_docstring: Test the experiment's agent whose model is defined with the given checkpoint metagraph for a certain number
  of episodes per volley and a certain number of volleys.
short_docstring_tokens: Test the experiment ' s agent whose model is defined with the given checkpoint metagraph for a certain number of episodes per volley and a certain number of volleys .
comment: """
          Test the experiment's agent whose model is defined with the given checkpoint metagraph for a certain number
          of episodes per volley and a certain number of volleys.
  
          This generates a tensorflow session and initialize both environment and agent associated with the experiment.
          After this is run all test results are accessible as properties.
  
          :param logger: the logger used to print the experiment information, warnings and errors
          :param episodes: the number of episodes for each test volley, must be greater than zero
          :param volleys: the number of test volleys, must be greater than zero
          :param episode_length: the max length in steps of each episode, must be greater than zero
          :param restore_path: the path where the metagraph of the model to test is stored
          :param render: boolean flag to render or not the environment
          """$SEP$# Make sure parameters are valid$SEP$# Start experiment testing process$SEP$# Define the session$SEP$# Initialize the environment and the agent$SEP$# Load the pre-trained model at given checkpoint path (if defined) and restore the agent$SEP$# Generate test volley$SEP$# Execute test volleys$SEP$# Setup and run test volley$SEP$# Store test volley statistics$SEP$# Increase test volley counter$SEP$# Store the average and the best total and scaled rewards over all test volleys$SEP$# Store the average and the minimum standard deviation of total and scaled rewards over test volleys$SEP$# Store the average episode length over all test volleys$SEP$# Store the max, min and average action duration in milliseconds (msec) over all test volleys$SEP$# Print test results$SEP$# Check if test is successful