LCOV - code coverage report
Current view: top level - src/microsim/devices - MSDispatch_Greedy.h (source / functions) Hit Total Coverage
Test: lcov.info Lines: 8 9 88.9 %
Date: 2024-04-30 15:40:33 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /****************************************************************************/
       2             : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3             : // Copyright (C) 2007-2024 German Aerospace Center (DLR) and others.
       4             : // This program and the accompanying materials are made available under the
       5             : // terms of the Eclipse Public License 2.0 which is available at
       6             : // https://www.eclipse.org/legal/epl-2.0/
       7             : // This Source Code may also be made available under the following Secondary
       8             : // Licenses when the conditions for such availability set forth in the Eclipse
       9             : // Public License 2.0 are satisfied: GNU General Public License, version 2
      10             : // or later which is available at
      11             : // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
      12             : // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
      13             : /****************************************************************************/
      14             : /// @file    MSDispatch_Greedy.h
      15             : /// @author  Jakob Erdmann
      16             : /// @date    16.12.2019
      17             : ///
      18             : // An algorithm that performs dispatch for the taxi device
      19             : /****************************************************************************/
      20             : #pragma once
      21             : #include <config.h>
      22             : 
      23             : #include <set>
      24             : #include <vector>
      25             : #include <map>
      26             : #include <utils/common/Parameterised.h>
      27             : #include <utils/common/SUMOTime.h>
      28             : #include "MSDispatch.h"
      29             : #include "MSDevice_Taxi.h"
      30             : 
      31             : 
      32             : // ===========================================================================
      33             : // class definitions
      34             : // ===========================================================================
      35             : 
      36             : /**
      37             :  * @class MSDispatch_Greedy
      38             :  * @brief A dispatch algorithm that services customers in reservation order and always sends the closest available taxi
      39             :  */
      40           0 : class MSDispatch_Greedy : public MSDispatch {
      41             : public:
      42         479 :     MSDispatch_Greedy(const Parameterised::Map& params) :
      43             :         MSDispatch(params),
      44         479 :         myRoutingMode(StringUtils::toInt(getParameter("routingMode", "1"))),
      45         479 :         myMaximumWaitingTime(TIME2STEPS(StringUtils::toInt(getParameter("maxWaitingTime", "300")))),
      46         479 :         myRecheckTime(TIME2STEPS(StringUtils::toInt(getParameter("recheckTime", "120")))),
      47         958 :         myRecheckSafety(TIME2STEPS(StringUtils::toInt(getParameter("recheckSafety", "3600"))))
      48         479 :     { }
      49             : 
      50             :     virtual void computeDispatch(SUMOTime now, const std::vector<MSDevice_Taxi*>& fleet);
      51             : 
      52             : protected:
      53             :     /// @brief trigger taxi dispatch. @note: method exists so subclasses can inject code at this point (ride sharing)
      54             :     virtual int dispatch(MSDevice_Taxi* taxi, std::vector<Reservation*>::iterator& resIt, SUMOAbstractRouter<MSEdge, SUMOVehicle>& router, std::vector<Reservation*>& reservations);
      55             : 
      56             :     /// @brief which router/edge weights to use
      57             :     const int myRoutingMode;
      58             : 
      59             :     /// @brief maximum time to arrive earlier at customer
      60             :     const SUMOTime myMaximumWaitingTime;
      61             : 
      62             :     /// @brief recheck interval for early reservations
      63             :     const SUMOTime myRecheckTime;
      64             :     const SUMOTime myRecheckSafety;
      65             : 
      66             : private:
      67             :     /// @brief Invalidated assignment operator.
      68             :     MSDispatch_Greedy& operator=(const MSDispatch_Greedy&) = delete;
      69             : 
      70             : };
      71             : 
      72             : 
      73             : /**
      74             :  * @class MSDispatch_GreedyClosest
      75             :  * @brief A dispatch algorithm that services the reservations with the shortest traveltime-to-pickup first
      76             :  */
      77             : class MSDispatch_GreedyClosest : public MSDispatch_Greedy {
      78             : public:
      79          18 :     MSDispatch_GreedyClosest(const Parameterised::Map& params) :
      80          18 :         MSDispatch_Greedy(params)
      81             :     {}
      82             : 
      83             :     void computeDispatch(SUMOTime now, const std::vector<MSDevice_Taxi*>& fleet);
      84             : 
      85             : };

Generated by: LCOV version 1.14