#pragma once
#include <config.h>
#include <utils/options/OptionsCont.h>
#include <utils/common/StdDefs.h>
#include <utils/common/SUMOTime.h>
#include <router/ROEdge.h>
#include <router/RONet.h>
#include "RODFDetector.h"
#include "RODFRouteDesc.h"
#include "RODFRouteCont.h"
class RODFNet : public RONet {
public:
RODFNet(bool amInHighwayMode);
~RODFNet();
void buildApproachList();
void computeTypes(RODFDetectorCon& dets,
bool sourcesStrict) const;
void buildRoutes(RODFDetectorCon& det, bool keepUnfoundEnds, bool includeInBetween,
bool keepShortestOnly, int maxFollowingLength) const;
double getAbsPos(const RODFDetector& det) const;
void buildEdgeFlowMap(const RODFDetectorFlows& flows,
const RODFDetectorCon& detectors,
SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset);
void revalidateFlows(const RODFDetectorCon& detectors,
RODFDetectorFlows& flows,
SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset);
void removeEmptyDetectors(RODFDetectorCon& detectors,
RODFDetectorFlows& flows);
void reportEmptyDetectors(RODFDetectorCon& detectors,
RODFDetectorFlows& flows);
void buildDetectorDependencies(RODFDetectorCon& detectors);
void mesoJoin(RODFDetectorCon& detectors, RODFDetectorFlows& flows);
bool hasDetector(ROEdge* edge) const;
const std::vector<std::string>& getDetectorList(ROEdge* edge) const;
double getMaxSpeedFactorPKW() const {
return myMaxSpeedFactorPKW;
}
double getMaxSpeedFactorLKW() const {
return myMaxSpeedFactorLKW;
}
double getAvgSpeedFactorPKW() const {
return myAvgSpeedFactorPKW;
}
double getAvgSpeedFactorLKW() const {
return myAvgSpeedFactorLKW;
}
protected:
void revalidateFlows(const RODFDetector* detector,
RODFDetectorFlows& flows,
SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset);
bool isSource(const RODFDetector& det,
const RODFDetectorCon& detectors, bool strict) const;
bool isFalseSource(const RODFDetector& det,
const RODFDetectorCon& detectors) const;
bool isDestination(const RODFDetector& det,
const RODFDetectorCon& detectors) const;
ROEdge* getDetectorEdge(const RODFDetector& det) const;
bool isSource(const RODFDetector& det, ROEdge* edge,
ROEdgeVector& seen, const RODFDetectorCon& detectors,
bool strict) const;
bool isFalseSource(const RODFDetector& det, ROEdge* edge,
ROEdgeVector& seen, const RODFDetectorCon& detectors) const;
bool isDestination(const RODFDetector& det, ROEdge* edge, ROEdgeVector& seen,
const RODFDetectorCon& detectors) const;
void computeRoutesFor(ROEdge* edge, RODFRouteDesc& base, int no,
bool keepUnfoundEnds,
bool keepShortestOnly,
ROEdgeVector& visited, const RODFDetector& det,
RODFRouteCont& into, const RODFDetectorCon& detectors,
int maxFollowingLength,
ROEdgeVector& seen) const;
void buildDetectorEdgeDependencies(RODFDetectorCon& dets) const;
bool hasApproaching(ROEdge* edge) const;
bool hasApproached(ROEdge* edge) const;
bool hasInBetweenDetectorsOnly(ROEdge* edge,
const RODFDetectorCon& detectors) const;
bool hasSourceDetector(ROEdge* edge,
const RODFDetectorCon& detectors) const;
bool isAllowed(const ROEdge* const edge) const;
struct IterationEdge {
int depth;
ROEdge* edge;
};
protected:
class DFRouteDescByTimeComperator {
public:
explicit DFRouteDescByTimeComperator() { }
~DFRouteDescByTimeComperator() { }
bool operator()(const RODFRouteDesc& nod1, const RODFRouteDesc& nod2) const {
return nod1.duration_2 > nod2.duration_2;
}
};
private:
struct idComp {
bool operator()(ROEdge* const lhs, ROEdge* const rhs) const {
return lhs->getID() < rhs->getID();
}
};
std::map<ROEdge*, ROEdgeVector > myApproachingEdges;
std::map<ROEdge*, ROEdgeVector > myApproachedEdges;
mutable std::map<ROEdge*, std::vector<std::string>, idComp> myDetectorsOnEdges;
mutable std::map<std::string, ROEdge*> myDetectorEdges;
bool myAmInHighwayMode;
mutable int mySourceNumber, mySinkNumber, myInBetweenNumber, myInvalidNumber;
std::vector<std::string> myDisallowedEdges;
SUMOVehicleClass myAllowedVClass;
bool myKeepTurnarounds;
double myMaxSpeedFactorPKW;
double myMaxSpeedFactorLKW;
double myAvgSpeedFactorPKW;
double myAvgSpeedFactorLKW;
};