LCOV - code coverage report
Current view: top level - src/microsim/devices - MSDispatch_Greedy.h (source / functions) Coverage Total Hit
Test: lcov.info Lines: 87.5 % 8 7
Test Date: 2026-03-02 16:00:03 Functions: 100.0 % 1 1

            Line data    Source code
       1              : /****************************************************************************/
       2              : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3              : // Copyright (C) 2007-2026 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          703 :     MSDispatch_Greedy(const Parameterised::Map& params) :
      43              :         MSDispatch(params),
      44         2109 :         myMaximumWaitingTime(TIME2STEPS(StringUtils::toInt(getParameter("maxWaitingTime", "300")))),
      45         2109 :         myRecheckTime(TIME2STEPS(StringUtils::toInt(getParameter("recheckTime", "120")))),
      46         2812 :         myRecheckSafety(TIME2STEPS(StringUtils::toInt(getParameter("recheckSafety", "3600"))))
      47          703 :     { }
      48              : 
      49              :     virtual void computeDispatch(SUMOTime now, const std::vector<MSDevice_Taxi*>& fleet);
      50              : 
      51              : protected:
      52              :     /// @brief trigger taxi dispatch. @note: method exists so subclasses can inject code at this point (ride sharing)
      53              :     virtual int dispatch(MSDevice_Taxi* taxi, std::vector<Reservation*>::iterator& resIt, SUMOAbstractRouter<MSEdge, SUMOVehicle>& router, std::vector<Reservation*>& reservations);
      54              : 
      55              :     /// @brief maximum time to arrive earlier at customer
      56              :     const SUMOTime myMaximumWaitingTime;
      57              : 
      58              :     /// @brief recheck interval for early reservations
      59              :     const SUMOTime myRecheckTime;
      60              :     const SUMOTime myRecheckSafety;
      61              : 
      62              : private:
      63              :     /// @brief Invalidated assignment operator.
      64              :     MSDispatch_Greedy& operator=(const MSDispatch_Greedy&) = delete;
      65              : 
      66              : };
      67              : 
      68              : 
      69              : /**
      70              :  * @class MSDispatch_GreedyClosest
      71              :  * @brief A dispatch algorithm that services the reservations with the shortest traveltime-to-pickup first
      72              :  */
      73              : class MSDispatch_GreedyClosest : public MSDispatch_Greedy {
      74              : public:
      75           18 :     MSDispatch_GreedyClosest(const Parameterised::Map& params) :
      76           18 :         MSDispatch_Greedy(params)
      77              :     {}
      78              : 
      79              :     void computeDispatch(SUMOTime now, const std::vector<MSDevice_Taxi*>& fleet);
      80              : 
      81              : };
        

Generated by: LCOV version 2.0-1