Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MSStopOptimizer.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2025 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/****************************************************************************/
18// Optimizes prioritized stops
19/****************************************************************************/
20#pragma once
21#include <config.h>
22
23#include <string>
24#include <vector>
25#include "MSBaseVehicle.h"
26
27// ===========================================================================
28// class declarations
29// ===========================================================================
30
32
33// ===========================================================================
34// class definitions
35// ===========================================================================
42
43 friend class StopPathNode;
44
45public:
54 myVehicle(veh),
55 myRouter(router),
56 myT(t),
57 myMaxDelay(maxDelay)
58 {}
59
61 virtual ~MSStopOptimizer() {}
62
63
64 ConstMSEdgeVector optimizeSkipped(const MSEdge* source, double sourcePos, std::vector<StopEdgeInfo>& stops, ConstMSEdgeVector edges) const;
65
66
67private:
72
73private:
74
76 struct StopPathNode : public StopEdgeInfo, std::enable_shared_from_this<StopPathNode> {
79 so(_so) {
80 nameTag = o.nameTag;
81 delay = o.delay;
82 }
83
84 // ordering criterion (minimize in order)
86 // @brief sum of skipped stop priority between source and this node
87 double skippedPrio = 0;
88 // @brief sum of reached stop priority between source and this node
89 double reachedPrio = 0;
90
91 int trackChanges = 0;
92 double cost = 0;
93
95 int numSkipped = 0;
96 int altIndex = 0;
97 bool checked = false;
99 std::shared_ptr<StopPathNode> prev = nullptr;
100
101 std::shared_ptr<StopPathNode> getSuccessor(const std::vector<StopEdgeInfo>& stops, double minSkipped);
102 };
103
104 struct spnCompare {
105 bool operator()(const std::shared_ptr<StopPathNode>& a,
106 const std::shared_ptr<StopPathNode>& b) const {
107 if (a->skippedPrio == b->skippedPrio) {
108 if (a->trackChanges == b->trackChanges) {
109 return a->cost > b->cost;
110 }
111 return a->trackChanges > b->trackChanges;
112 }
113 return a->skippedPrio > b->skippedPrio;
114 }
115 };
116
117 bool reachableInTime(const MSEdge* from, double fromPos,
118 const MSEdge* to, double toPos,
119 SUMOTime arrival, ConstMSEdgeVector& into) const;
120
121};
long long int SUMOTime
Definition GUI.h:36
std::vector< const MSEdge * > ConstMSEdgeVector
Definition MSEdge.h:74
MSBaseVehicle::StopEdgeInfo StopEdgeInfo
The base class for microscopic and mesoscopic vehicles.
A road/street connecting two junctions.
Definition MSEdge.h:77
Finds a sequence of skips and stop alternatives to maximize priority of reached stops.
MSStopOptimizer(MSBaseVehicle *veh, SUMOAbstractRouter< MSEdge, SUMOVehicle > &router, SUMOTime t, SUMOTime maxDelay)
Constructor.
SUMOAbstractRouter< MSEdge, SUMOVehicle > & myRouter
ConstMSEdgeVector optimizeSkipped(const MSEdge *source, double sourcePos, std::vector< StopEdgeInfo > &stops, ConstMSEdgeVector edges) const
bool reachableInTime(const MSEdge *from, double fromPos, const MSEdge *to, double toPos, SUMOTime arrival, ConstMSEdgeVector &into) const
virtual ~MSStopOptimizer()
Destructor.
MSBaseVehicle * myVehicle
std::pair< std::string, SumoXMLTag > nameTag
optional info about stopping place
information used during skip/alternative optimization
const MSStopOptimizer & so
std::shared_ptr< StopPathNode > prev
std::shared_ptr< StopPathNode > getSuccessor(const std::vector< StopEdgeInfo > &stops, double minSkipped)
StopPathNode(const MSStopOptimizer &_so, const StopEdgeInfo &o)
bool operator()(const std::shared_ptr< StopPathNode > &a, const std::shared_ptr< StopPathNode > &b) const