LCOV - code coverage report
Current view: top level - app/include/Dynamic/Policy - RandomPolicy.hpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 2 0.0 %
Date: 2023-08-17 16:45:52 Functions: 0 0 -

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include <random>
       4             : 
       5             : #include "Dynamic/Policy/Action.hpp"
       6             : #include "Dynamic/Policy/Policy.hpp"
       7             : #include "Dynamic/Vehicle.hpp"
       8             : 
       9             : namespace Dynamic {
      10             : 
      11             : /**
      12             :  * @brief Policy that picks a random connection.
      13             :  *
      14             :  * This is a simple policy, used only for testing. It selects a random
      15             :  * connection from the set of allowed connections. If there is no possible
      16             :  * connection (e.g., if the vehicle is on a dead-end), it returns the `LEAVE`
      17             :  * connection to instruct the environment to remove the vehicle (as if the
      18             :  * vehicle had arrived at its destination).
      19             :  */
      20           0 : class RandomPolicy: public Policy {
      21             :    public:
      22             :     struct Action: public Env::Action {
      23             :         Action(Env::Connection &connection, Env::Lane &lane);
      24             : 
      25             :         virtual void reward(Reward r) override;
      26             :     };
      27             : 
      28             :    private:
      29             :     Vehicle::ID id;
      30             : 
      31             :     std::shared_ptr<std::mt19937> gen;
      32             : 
      33             :    public:
      34             :     RandomPolicy(Vehicle::ID id, std::shared_ptr<std::mt19937> gen);
      35             : 
      36             :     virtual Env::Lane &pickInitialLane(
      37             :         Vehicle  &vehicle,
      38             :         Env::Env &env
      39             :     ) override;
      40             : 
      41             :     virtual std::shared_ptr<Env::Action> pickConnection(
      42             :         Env::Env &env
      43             :     ) override;
      44             : 
      45             :     /**
      46             :      * @brief Factory for random policy.
      47             :      *
      48             :      * Instantiates RandomPolicy.
      49             :      */
      50           0 :     class Factory: public Policy::Factory {
      51             :         std::shared_ptr<std::mt19937> gen;
      52             : 
      53             :        public:
      54             :         Factory();
      55             :         Factory(std::random_device::result_type seed);
      56             :         virtual std::shared_ptr<Policy> create(
      57             :             Vehicle::ID     id,
      58             :             Time            depart,
      59             :             const Env::TAZ &fromTAZ,
      60             :             const Env::TAZ &toTAZ
      61             :         ) override;
      62             :     };
      63             : };
      64             : 
      65             : }  // namespace Dynamic

Generated by: LCOV version 1.14