45 #ifdef CHECK_MEMORY_LEAKS 47 #endif // CHECK_MEMORY_LEAKS 63 : myBegin(begin), myEnd(end), myAdditiveTraffic(additiveTraffic), myAdaptionFactor(adaptionFactor), myNet(net), myMatrix(matrix), myRouter(router) {
83 }
else if (roadClass == 0 || roadClass == 1) {
85 }
else if (roadClass == 2 && edge->
getSpeed() <= 11.) {
87 }
else if (roadClass == 2 && edge->
getSpeed() > 11. && edge->
getSpeed() <= 16.) {
89 }
else if (roadClass == 2 && edge->
getSpeed() > 16.) {
91 }
else if (roadClass == 3 && edge->
getSpeed() <= 11.) {
93 }
else if (roadClass == 3 && edge->
getSpeed() > 11. && edge->
getSpeed() <= 13.) {
95 }
else if (roadClass == 3 && edge->
getSpeed() > 13. && edge->
getSpeed() <= 16.) {
97 }
else if (roadClass == 3 && edge->
getSpeed() > 16.) {
99 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() <= 5.) {
101 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 5. && edge->
getSpeed() <= 7.) {
103 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 7. && edge->
getSpeed() <= 9.) {
105 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 9. && edge->
getSpeed() <= 11.) {
107 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 11. && edge->
getSpeed() <= 13.) {
109 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 13. && edge->
getSpeed() <= 16.) {
111 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 16. && edge->
getSpeed() <= 18.) {
113 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 18. && edge->
getSpeed() <= 22.) {
115 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 22. && edge->
getSpeed() <= 26.) {
117 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 26.) {
136 }
else if (roadClass == 0 || roadClass == 1) {
137 return edge->
getLength() / edge->
getSpeed() * (1. + 1.*(flow / (capacity * 1.3)) * 2.);
138 }
else if (roadClass == 2 && edge->
getSpeed() <= 11.) {
139 return edge->
getLength() / edge->
getSpeed() * (1. + 1.*(flow / (capacity * 0.9)) * 3.);
140 }
else if (roadClass == 2 && edge->
getSpeed() > 11. && edge->
getSpeed() <= 16.) {
141 return edge->
getLength() / edge->
getSpeed() * (1. + 1.*(flow / (capacity * 1.)) * 2.);
142 }
else if (roadClass == 2 && edge->
getSpeed() > 16.) {
143 return edge->
getLength() / edge->
getSpeed() * (1. + 1.*(flow / (capacity * 1.3)) * 2.);
144 }
else if (roadClass == 3 && edge->
getSpeed() <= 11.) {
145 return edge->
getLength() / edge->
getSpeed() * (1. + 1.*(flow / (capacity * 0.9)) * 3.);
146 }
else if (roadClass == 3 && edge->
getSpeed() > 11. && edge->
getSpeed() <= 13.) {
147 return edge->
getLength() / edge->
getSpeed() * (1. + 1.*(flow / (capacity * 0.9)) * 3.);
148 }
else if (roadClass == 3 && edge->
getSpeed() > 13. && edge->
getSpeed() <= 16.) {
149 return edge->
getLength() / edge->
getSpeed() * (1. + 1.7 * (flow / (capacity * 1.)) * 2.);
150 }
else if (roadClass == 3 && edge->
getSpeed() > 16.) {
151 return edge->
getLength() / edge->
getSpeed() * (1. + 1.*(flow / (capacity * 1.3)) * 2.);
152 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() <= 5.) {
153 return edge->
getLength() / edge->
getSpeed() * (1. + 1.*(flow / (capacity * 0.5)) * 3.);
154 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 5. && edge->
getSpeed() <= 7.) {
155 return edge->
getLength() / edge->
getSpeed() * (1. + 1.*(flow / (capacity * 0.5)) * 3.);
156 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 7. && edge->
getSpeed() <= 9.) {
157 return edge->
getLength() / edge->
getSpeed() * (1. + 1.*(flow / (capacity * 0.8)) * 3.);
158 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 9. && edge->
getSpeed() <= 11.) {
159 return edge->
getLength() / edge->
getSpeed() * (1. + 1.*(flow / (capacity * 0.9)) * 3.);
160 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 11. && edge->
getSpeed() <= 13.) {
161 return edge->
getLength() / edge->
getSpeed() * (1. + 1.*(flow / (capacity * 0.9)) * 3.);
162 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 13. && edge->
getSpeed() <= 16.) {
163 return edge->
getLength() / edge->
getSpeed() * (1. + 1.7 * (flow / (capacity * 1.)) * 2.);
164 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 16. && edge->
getSpeed() <= 18.) {
165 return edge->
getLength() / edge->
getSpeed() * (1. + 1.*(flow / (capacity * 1.)) * 2.);
166 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 18. && edge->
getSpeed() <= 22.) {
167 return edge->
getLength() / edge->
getSpeed() * (1. + 1.*(flow / (capacity * 1.)) * 2.);
168 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 22. && edge->
getSpeed() <= 26.) {
169 return edge->
getLength() / edge->
getSpeed() * (1. + 1.*(flow / (capacity * 1.)) * 2.);
170 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 26.) {
171 return edge->
getLength() / edge->
getSpeed() * (1. + 1.*(flow / (capacity * 1.)) * 2.);
173 return edge->
getLength() / edge->
getSpeed() * (1. + 1.*(flow / (capacity * 0.9)) * 3.);
180 for (std::vector<RORoute*>::const_iterator p = paths.begin(); p != paths.end(); p++) {
181 if (edges == (*p)->getEdgeVector()) {
187 paths.push_back(
new RORoute(routeId, costs, prob, edges, 0, std::vector<SUMOVehicleParameter::Stop>()));
200 for (
int k = 0; k < kPaths; k++) {
203 for (ConstROEdgeVector::iterator e = edges.begin(); e != edges.end(); e++) {
226 std::vector<int> intervals;
229 if ((*i)->begin != lastBegin) {
230 intervals.push_back(count);
231 lastBegin = (*i)->begin;
236 for (std::vector<int>::const_iterator offset = intervals.begin(); offset != intervals.end(); offset++) {
238 if (offset != intervals.end() - 1) {
242 std::map<const ROMAEdge*, SUMOReal> loadedTravelTimes;
249 for (
int t = 0; t < numIter; t++) {
250 for (std::vector<ODCell*>::const_iterator i =
myMatrix.
getCells().begin() + (*offset); i != end; i++) {
259 for (ConstROEdgeVector::iterator e = edges.begin(); e != edges.end(); e++) {
265 if (loadedTravelTimes.count(edge) != 0) {
277 lastBegin = intervalStart;
285 std::map<const SUMOReal, SUMOReal> intervals;
293 for (
int outer = 0; outer < maxOuterIteration; outer++) {
294 for (
int inner = 0; inner < maxInnerIteration; inner++) {
319 int unstableEdges = 0;
320 for (std::map<const SUMOReal, SUMOReal>::const_iterator i = intervals.begin(); i != intervals.end(); ++i) {
326 if (inner == 0 && outer == 0) {
329 newFlow += (edge->
getHelpFlow(i->first) - oldFlow) / (inner + 1);
333 if (
abs(newFlow - oldFlow) / newFlow > tolerance) {
336 }
else if (newFlow == 0.) {
337 if (oldFlow != 0. && (
abs(newFlow - oldFlow) / oldFlow > tolerance)) {
344 edge->
setFlow(i->first, i->second, newFlow);
351 if (unstableEdges == 0) {
358 bool newRoute =
false;
390 const std::map<const ROEdge* const, SUMOReal>::const_iterator i =
myPenalties.find(e);
397 const std::map<const ROEdge* const, SUMOReal>::const_iterator i =
myPenalties.find(e);
void incremental(const int numIter)
const std::vector< ODCell * > & getCells()
SUMOAbstractRouter< ROEdge, ROVehicle > & myRouter
SUMOReal getFlow(const SUMOReal time) const
ROEdge * getEdge(const std::string &name) const
Retrieves an edge from the network.
ROMAAssignments(const SUMOTime begin, const SUMOTime end, const bool additiveTraffic, const SUMOReal adaptionFactor, RONet &net, ODMatrix &matrix, SUMOAbstractRouter< ROEdge, ROVehicle > &router)
Constructor.
const ConstROEdgeVector & getEdgeVector() const
Returns the list of edges this route consists of.
void setProbability(SUMOReal prob)
Sets the probability of the route.
EdgeFunc getFunc() const
Returns the function of the edge.
void setFlow(const SUMOReal begin, const SUMOReal end, const SUMOReal flow)
unsigned int getLaneNo() const
Returns the number of lanes this edge has.
std::vector< const ROEdge * > ConstROEdgeVector
std::vector< RORoute * > pathsVector
the list of paths / routes
const bool myAdditiveTraffic
const std::string DEFAULT_VTYPE_ID
void addTravelTime(SUMOReal value, SUMOReal timeBegin, SUMOReal timeEnd)
Adds a travel time value.
const std::map< std::string, ROEdge * > & getEdgeMap() const
void addProbability(SUMOReal prob)
add additional vehicles/probability
bool hasLoadedTravelTime(SUMOReal time) const
Returns whether a travel time for this edge was loaded.
A vehicle as used by router.
A single O/D-matrix cell.
void setHelpFlow(const SUMOReal begin, const SUMOReal end, const SUMOReal flow)
std::string origin
Name of the origin district.
static SUMOReal getPenalizedTT(const ROEdge *const e, const ROVehicle *const v, SUMOReal t)
Returns the traveltime on an edge including penalties.
void sue(const int maxOuterIteration, const int maxInnerIteration, const int kPaths, const SUMOReal penalty, const SUMOReal tolerance, const std::string routeChoiceMethod)
An O/D (origin/destination) matrix.
SUMOReal getProbability() const
Returns the probability the driver will take this route with.
void setCosts(SUMOReal costs)
Sets the costs of the route.
~ROMAAssignments()
Destructor.
SUMOReal vehicleNumber
The number of vehicles.
static std::map< const ROEdge *const, SUMOReal > myPenalties
static SUMOReal getTravelTime(const ROEdge *const e, const ROVehicle *const v, SUMOReal t)
Returns the traveltime on an edge without penalties.
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
static SUMOReal getPenalizedEffort(const ROEdge *const e, const ROVehicle *const v, SUMOReal t)
Returns the effort to pass an edge including penalties.
SUMOTime begin
The begin time this cell describes.
A basic edge for routing applications.
SUMOReal getHelpFlow(const SUMOReal time) const
static SUMOReal getCapacity(const ROEdge *edge)
The router's network representation.
Structure representing possible vehicle parameter.
int getPriority() const
get edge priority (road class)
SUMOReal getLength() const
Returns the length of the edge.
ROVehicle * myDefaultVehicle
SUMOReal getEffort(const ROVehicle *const veh, SUMOReal time) const
Returns the effort for this edge.
void getKPaths(const int kPaths, const SUMOReal penalty)
get the k shortest paths
virtual SUMOReal recomputeCosts(const std::vector< const E * > &edges, const V *const v, SUMOTime msTime) const =0
std::string destination
Name of the destination district.
bool addRoute(ConstROEdgeVector &edges, std::vector< RORoute * > &paths, std::string routeId, SUMOReal costs, SUMOReal prob)
add a route and check for duplicates
virtual void compute(const E *from, const E *to, const V *const vehicle, SUMOTime msTime, std::vector< const E * > &into)=0
Builds the route between the given edges using the minimum effort at the given time The definition of...
SUMOVTypeParameter * getVehicleTypeSecure(const std::string &id)
Retrieves the named vehicle type.
SUMOReal getTravelTime(const ROVehicle *const veh, SUMOReal time) const
Returns the travel time for this edge.
static RouteCostCalculator< R, E, V > & getCalculator()
SUMOTime end
The end time this cell describes.
An edge representing a whole district.
SUMOReal capacityConstraintFunction(const ROEdge *edge, const SUMOReal flow) const
A basic edge for routing applications.
SUMOReal getSpeed() const
Returns the speed allowed on this edge.
A complete router's route.
const SUMOReal myAdaptionFactor