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

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include <memory>
       4             : 
       5             : #include "Dynamic/Dynamic.hpp"
       6             : #include "Log/ProgressLogger.hpp"
       7             : 
       8             : namespace Dynamic {
       9             : namespace Env {
      10             : class Env;
      11             : class Connection;
      12             : class TAZ;
      13             : class Lane;
      14             : class Action;
      15             : }  // namespace Env
      16             : 
      17             : class Vehicle;
      18             : 
      19             : class Action;
      20             : 
      21             : /**
      22             :  * @brief Vehicle path selection policy.
      23             :  *
      24             :  * A vehicle policy is the strategy used by a vehicle to select the next
      25             :  * connection to take.
      26             :  *
      27             :  * This sort of software design follows the Strategy pattern, but I decided
      28             :  * to use the term "policy" for its parallel with the concept of policy in
      29             :  * reinforcement learning, where the policy is expected to be always
      30             :  * changing and improving based on feedback.
      31             :  */
      32           0 : class Policy {
      33             :    private:
      34             :     typedef long VehicleID;
      35             : 
      36             :    public:
      37             :     /**
      38             :      * @brief Policy factory.
      39             :      *
      40             :      * Used by demand loaders to generate policies for new vehicles.
      41             :      */
      42           0 :     class Factory {
      43             :        public:
      44             :         /**
      45             :          * @brief Create a policy for a vehicle.
      46             :          *
      47             :          * @param id        Vehicle ID.
      48             :          * @param depart    Departure time.
      49             :          * @param from      Origin edge.
      50             :          * @param to        Destination edge.
      51             :          * @return std::shared_ptr<Policy>  Policy.
      52             :          */
      53             :         virtual std::shared_ptr<Policy> create(
      54             :             VehicleID       id,
      55             :             Time            depart,
      56             :             const Env::TAZ &fromTAZ,
      57             :             const Env::TAZ &toTAZ
      58             :         ) = 0;
      59             :     };
      60             : 
      61             :     /**
      62             :      * @brief Logger.
      63             :      *
      64             :      * Allows a policy or a policy factory to log information to a ProgressLogger.
      65             :      */
      66           0 :     class Logger {
      67             :        public:
      68             :         virtual void header(Log::ProgressLogger &logger);
      69             :         virtual void log(Log::ProgressLogger &logger);
      70             :     };
      71             : 
      72             :     /**
      73             :      * @brief Pick an initial lane.
      74             :      *
      75             :      * @param vehicle   Vehicle.
      76             :      * @param env       Environment.
      77             :      * @return const Env::Lane&     Picked lane.
      78             :      */
      79             :     virtual Env::Lane &pickInitialLane(
      80             :         Vehicle  &vehicle,
      81             :         Env::Env &env
      82             :     ) = 0;
      83             : 
      84             :     /**
      85             :      * @brief Pick a connection.
      86             :      *
      87             :      * @param env   Environment.
      88             :      * @return const Env::Connection&   Picked connection.
      89             :      */
      90             :     virtual std::shared_ptr<Env::Action> pickConnection(Env::Env &env) = 0;
      91             : };
      92             : 
      93             : }  // namespace Dynamic

Generated by: LCOV version 1.14