36 double minSkipped = 0;
37 double maxReached = 0;
39 std::vector<StopEdgeInfo> bestStops = stops;
40 std::shared_ptr<StopPathNode> bestNode =
nullptr;
42 std::vector<int> skipped;
47 std::priority_queue<std::shared_ptr<StopPathNode>, std::vector<std::shared_ptr<StopPathNode> >,
spnCompare> queue;
49 auto prev = std::make_shared<StopPathNode>(*
this,
StopEdgeInfo(source, -1,
SIMSTEP, sourcePos));
51 prev->cost = bestCost;
56 for (
int i = 0; i < (int)stops.size(); i++) {
63 auto ptr = std::make_shared<StopPathNode>(*
this, stop);
64 ptr->skippedPrio = minSkipped;
65 ptr->reachedPrio = prev->reachedPrio + stop.
priority;
75#ifdef DEBUG_OPTIMIZE_SKIPPED
77 <<
" source=" << source->
getID() <<
" sourcePos=" << sourcePos
78 <<
" nStops=" << stops.size() <<
" skipped=" <<
toString(skipped) <<
" qSize=" << queue.size()
79 <<
" minSkipped=" << minSkipped <<
" maxReached=" << maxReached <<
"\n";
82 while (!queue.empty()) {
83 auto ptr = queue.top();
85#ifdef DEBUG_OPTIMIZE_SKIPPED
86 std::cout <<
" qSize=" << queue.size() <<
" topNode edge=" << ptr->edge->getID()
87 <<
" name='" << ptr->nameTag.first <<
"' skippedPrio=" << ptr->skippedPrio
88 <<
" trackChanges=" << ptr->trackChanges
89 <<
" cost=" << ptr->cost
90 <<
" reachedPrio=" << ptr->reachedPrio
91 <<
" stopIndex=" << ptr->stopIndex <<
"\n";
93 auto succ = ptr->getSuccessor(stops, minSkipped);
94 if (ptr->skippedPrio < minSkipped && ptr->reachedPrio > maxReached) {
95 minSkipped =
MIN2(minSkipped, totalPrio - ptr->reachedPrio);
96 maxReached = ptr->reachedPrio;
98#ifdef DEBUG_OPTIMIZE_SKIPPED
99 std::cout <<
" newBest minSkipped=" << minSkipped <<
" maxReached=" << maxReached <<
"\n";
102 if (succ !=
nullptr) {
107 for (
auto& stop : stops) {
110 stop.backtracked =
true;
115 while (bestNode !=
nullptr && bestNode->stopIndex >= 0) {
116 stops[bestNode->stopIndex].skipped =
false;
117 stops[bestNode->stopIndex].backtracked =
false;
118 stops[bestNode->stopIndex].origEdge = bestNode->origEdge;
119 if (!bestEdges.empty() && !bestNode->edges.empty()) {
120 bestNode->edges.pop_back();
122 bestEdges.insert(bestEdges.begin(), bestNode->edges.begin(), bestNode->edges.end());
123 bestNode = bestNode->prev;
130std::shared_ptr<MSStopOptimizer::StopPathNode>
136#ifdef DEBUG_OPTIMIZE_SKIPPED
137 std::cout <<
" prevIndex=" <<
prev->stopIndex <<
" prevEdge=" <<
prev->edge->getID() <<
" i=" <<
stopIndex <<
" edge=" <<
edge->
getID() <<
" unreachable\n";
141#ifdef DEBUG_OPTIMIZE_SKIPPED
148 while (nextIndex < (
int)stops.size()) {
152#ifdef DEBUG_OPTIMIZE_SKIPPED
153 std::cout <<
" i=" <<
stopIndex <<
" next=" << nextIndex <<
" unskipped\n";
158#ifdef DEBUG_OPTIMIZE_SKIPPED
159 std::cout <<
" i=" <<
stopIndex <<
" next=" << nextIndex <<
" numSkipped=" <<
numSkipped <<
" altIndex=" <<
altIndex <<
" nAlt=" << alternatives.size() <<
"\n";
163 auto succ = std::make_shared<StopPathNode>(
so, next);
167 succ->prev = shared_from_this();
168 succ->stopIndex = nextIndex;
171 while (
altIndex < (
int)alternatives.size()) {
178 auto succ = std::make_shared<StopPathNode>(
so, next);
179 if (altEdge != succ->edge) {
180 succ->origEdge = succ->edge;
181 succ->edge = altEdge;
187 succ->prev = shared_from_this();
188 succ->stopIndex = nextIndex;
194#ifdef DEBUG_OPTIMIZE_SKIPPED
195 std::cout <<
" i=" <<
stopIndex <<
" next=" << nextIndex <<
" skippedPrio=" <<
skippedPrio <<
" minSkipped=" << minSkipped <<
" pruned\n";
203#ifdef DEBUG_OPTIMIZE_SKIPPED
204 std::cout <<
" i=" <<
stopIndex <<
" noSuccessors\n";
212 const MSEdge* to,
double toPos,
216 if (into.size() > 0) {
std::vector< const MSEdge * > ConstMSEdgeVector
MSBaseVehicle::StopEdgeInfo StopEdgeInfo
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
SUMOVehicleClass getVClass() const
Returns the vehicle's access class.
A road/street connecting two junctions.
bool allowsVehicleClass(SUMOVehicleClass vclass) const
MSEdge & getEdge() const
Returns the lane's edge.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
const std::vector< MSStoppingPlace * > & getStoppingPlaceAlternatives(const std::string &name, SumoXMLTag category) const
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
MSBaseVehicle * myVehicle
A lane area vehicles can halt at.
double getEndLanePosition() const
Returns the end position of this stop.
const MSLane & getLane() const
Returns the lane this stop is located at.
const std::string & getID() const
Returns the id.
virtual bool compute(const E *from, const E *to, const V *const vehicle, SUMOTime msTime, std::vector< const E * > &into, bool silent=false)=0
Builds the route between the given edges using the minimum effort at the given time The definition of...
double recomputeCostsPos(const std::vector< const E * > &edges, const V *const v, double fromPos, double toPos, SUMOTime msTime, double *lengthp=nullptr) const
std::pair< std::string, SumoXMLTag > nameTag
optional info about stopping place
const MSStopOptimizer & so
std::shared_ptr< StopPathNode > prev
std::shared_ptr< StopPathNode > getSuccessor(const std::vector< StopEdgeInfo > &stops, double minSkipped)