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_TraCI.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_TraCI
38 : * @brief A dispatch algorithm that services customers in reservation order and always sends the closest available taxi
39 : */
40 : class MSDispatch_TraCI : public MSDispatch {
41 : public:
42 91 : MSDispatch_TraCI(const Parameterised::Map& params) :
43 91 : MSDispatch(params)
44 : { }
45 :
46 : /// @brief add a new reservation
47 : Reservation* addReservation(MSTransportable* person,
48 : SUMOTime reservationTime,
49 : SUMOTime pickupTime,
50 : SUMOTime earliestPickupTime,
51 : const MSEdge* from, double fromPos,
52 : const MSStoppingPlace* fromStop,
53 : const MSEdge* to, double toPos,
54 : const MSStoppingPlace* toStop,
55 : std::string group,
56 : const std::string& line,
57 : int maxCapacity,
58 : int maxContainerCapacity) override;
59 :
60 : /// @brief remove person from reservation. If the whole reservation is removed, return its id
61 : std::string removeReservation(MSTransportable* person,
62 : const MSEdge* from, double fromPos,
63 : const MSEdge* to, double toPos,
64 : std::string group) override;
65 :
66 : /// @brief do nothing (dispatch happens via TraCI calls)
67 689 : void computeDispatch(SUMOTime /*now*/, const std::vector<MSDevice_Taxi*>& /*fleet*/) override {}
68 :
69 : /// @brief trigger taxi dispatch. @note: method exists so subclasses can inject code at this point (ride sharing)
70 : void interpretDispatch(MSDevice_Taxi* taxi, const std::vector<std::string>& reservationsIDs);
71 :
72 : /// @brief split existing reservations and return the new reservation id
73 : std::string splitReservation(std::string resID, std::vector<std::string> personIDs);
74 :
75 : /// @brief erase reservation from storage
76 : void fulfilledReservation(const Reservation* res) override;
77 :
78 : private:
79 : StringBijection<const Reservation*> myReservationLookup;
80 :
81 : private:
82 : /// @brief Invalidated assignment operator.
83 : MSDispatch_TraCI& operator=(const MSDispatch_TraCI&) = delete;
84 :
85 : };
|