void RODFDetector::computeSplitProbabilities(const RODFNet* net, const RODFDetectorCon& detectors, const RODFDetectorFlows& flows, SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset) { if (myRoutes == 0) { return; } // compute edges to determine split probabilities const std::vector<RODFRouteDesc>& routes = myRoutes->get(); std::vector<RODFEdge*> nextDetEdges; std::set<ROEdge*> preSplitEdges; for (std::vector<RODFRouteDesc>::const_iterator i = routes.begin(); i != routes.end(); ++i) { const RODFRouteDesc& rd = *i; bool hadSplit = false; for (ROEdgeVector::const_iterator j = rd.edges2Pass.begin(); j != rd.edges2Pass.end(); ++j) { if (hadSplit && net->hasDetector(*j)) { if (find(nextDetEdges.begin(), nextDetEdges.end(), *j) == nextDetEdges.end()) { nextDetEdges.push_back(static_cast<RODFEdge*>(*j)); } myRoute2Edge[rd.routename] = static_cast<RODFEdge*>(*j); break; } if (!hadSplit) { preSplitEdges.insert(*j); } if ((*j)->getNumSuccessors() > 1) { hadSplit = true; } } } std::map<ROEdge*, SUMOReal> inFlows; if (OptionsCont::getOptions().getBool("respect-concurrent-inflows")) { for (std::vector<RODFEdge*>::const_iterator i = nextDetEdges.begin(); i != nextDetEdges.end(); ++i) { std::set<ROEdge*> seen(preSplitEdges); ROEdgeVector pending; pending.push_back(*i); seen.insert(*i); while (!pending.empty()) { ROEdge* e = pending.back(); pending.pop_back(); for (ROEdgeVector::const_iterator it = e->getPredecessors().begin(); it != e->getPredecessors().end(); it++) { ROEdge* e2 = *it; if (e2->getNumSuccessors() == 1 && seen.count(e2) == 0) { if (net->hasDetector(e2)) { inFlows[*i] += detectors.getAggFlowFor(e2, 0, 0, flows); } else { pending.push_back(e2); } seen.insert(e2); } } } } } // compute the probabilities to use a certain direction int index = 0; for (SUMOTime time = startTime; time < endTime; time += stepOffset, ++index) { mySplitProbabilities.push_back(std::map<RODFEdge*, SUMOReal>()); SUMOReal overallProb = 0; // retrieve the probabilities for (std::vector<RODFEdge*>::const_iterator i = nextDetEdges.begin(); i != nextDetEdges.end(); ++i) { SUMOReal flow = detectors.getAggFlowFor(*i, time, 60, flows) - inFlows[*i]; overallProb += flow; mySplitProbabilities[index][*i] = flow; } // norm probabilities if (overallProb > 0) { for (std::vector<RODFEdge*>::const_iterator i = nextDetEdges.begin(); i != nextDetEdges.end(); ++i) { mySplitProbabilities[index][*i] = mySplitProbabilities[index][*i] / overallProb; } } } }