SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ROJTRRouter.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // Computes routes using junction turning percentages
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
12 // Copyright (C) 2001-2014 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include <router/RONet.h>
34 #include "ROJTRRouter.h"
35 #include "ROJTREdge.h"
37 
38 #ifdef CHECK_MEMORY_LEAKS
39 #include <foreign/nvwa/debug_new.h>
40 #endif // CHECK_MEMORY_LEAKS
41 
42 
43 // ===========================================================================
44 // method definitions
45 // ===========================================================================
46 ROJTRRouter::ROJTRRouter(RONet& net, bool unbuildIsWarningOnly, bool acceptAllDestinations,
47  int maxEdges, bool ignoreClasses, bool allowLoops) :
48  SUMOAbstractRouter<ROEdge, ROVehicle>("JTRRouter"),
49  myNet(net), myUnbuildIsWarningOnly(unbuildIsWarningOnly),
50  myAcceptAllDestination(acceptAllDestinations), myMaxEdges(maxEdges),
51  myIgnoreClasses(ignoreClasses), myAllowLoops(allowLoops)
52 { }
53 
54 
56 
57 
58 void
59 ROJTRRouter::compute(const ROEdge* from, const ROEdge* /*to*/,
60  const ROVehicle* const vehicle,
61  SUMOTime time, std::vector<const ROEdge*>& into) {
62  const ROJTREdge* current = static_cast<const ROJTREdge*>(from);
63  // route until a sinks has been found
64  while (current != 0
65  &&
66  current->getType() != ROEdge::ET_SINK
67  &&
68  (int) into.size() < myMaxEdges) {
69 
70  into.push_back(current);
71  time += (SUMOTime) current->getTravelTime(vehicle, time);
72  current = current->chooseNext(myIgnoreClasses ? 0 : vehicle, time);
73  assert(myIgnoreClasses || current == 0 || !current->prohibits(vehicle));
74  }
75  // check whether no valid ending edge was found
76  if ((int) into.size() >= myMaxEdges) {
78  return;
79  } else {
81  mh->inform("The route starting at edge '" + from->getID() + "' could not be closed.");
82  }
83  }
84  // append the sink
85  if (current != 0) {
86  into.push_back(current);
87  }
88 }
89 
90 
92 ROJTRRouter::recomputeCosts(const std::vector<const ROEdge*>& edges, const ROVehicle* const v, SUMOTime time) const {
93  SUMOReal costs = 0;
94  for (std::vector<const ROEdge*>::const_iterator i = edges.begin(); i != edges.end(); ++i) {
95  costs += (*i)->getTravelTime(v, time);
96  }
97  return costs;
98 }
99 
100 
101 
102 /****************************************************************************/
103