34#define DEBUG_COND (veh.isSelected())
52#ifdef DEBUG_WANTS_CHANGE
55 std::cout <<
SIMTIME <<
" veh=" << veh.
getID() <<
" getRoundaboutDistBonus bonusParam=" << bonusParam
66 int roundaboutJunctionsAhead = 0;
67 bool enteredRoundabout =
false;
73 if (lane ==
nullptr) {
78#ifdef DEBUG_WANTS_CHANGE
80 std::cout <<
" noBonus: inner does not continue (lane=" << lane->
getID() <<
")\n";
87#ifdef DEBUG_WANTS_CHANGE
89 std::cout <<
" noBonus: seen=" << seen <<
" (lane=" << lane->
getID() <<
")\n";
96 enteredRoundabout =
true;
98 roundaboutJunctionsAhead++;
100 }
else if (enteredRoundabout) {
107 if (roundaboutJunctionsAhead < 2) {
113 double occupancyOuter = 0;
114 double occupancyInner = 0;
115 double distanceInRoundabout = 0;
116 MSLane* prevNormal =
nullptr;
117 MSLane* prevInner =
nullptr;
118 enteredRoundabout =
false;
121 if (lane ==
nullptr) {
125 enteredRoundabout =
true;
126 }
else if (enteredRoundabout) {
131 if (prevNormal !=
nullptr) {
133 if (link->getLane() == lane) {
134 via = link->getViaLane();
138 if (enteredRoundabout) {
139 distanceInRoundabout += lane->
getLength();
140 if (via !=
nullptr) {
141 distanceInRoundabout += via->
getLength();
149#ifdef DEBUG_WANTS_CHANGE
151 std::cout <<
" lane=" << lane->
getID() <<
" occ=" << lane->
getBruttoVehLenSum() <<
" discount=" << upstreamDiscount <<
" outer=" << occupancyOuter <<
"\n";
154 if (via !=
nullptr) {
156#ifdef DEBUG_WANTS_CHANGE
158 std::cout <<
" via=" << via->
getID() <<
" occ=" << via->
getBruttoVehLenSum() <<
" outer=" << occupancyOuter <<
"\n";
165#ifdef DEBUG_WANTS_CHANGE
167 std::cout <<
" inner=" << innerLane->
getID() <<
" occ=" << innerLane->
getBruttoVehLenSum() <<
" discount=" << upstreamDiscount <<
" inner=" << occupancyInner <<
"\n";
170 if (prevInner !=
nullptr) {
172 if (link->getLane() == innerLane && link->getViaLane() !=
nullptr) {
173 occupancyInner += link->getViaLane()->getBruttoVehLenSum();
174#ifdef DEBUG_WANTS_CHANGE
176 std::cout <<
" innerVia=" << link->getViaLane()->getID() <<
" occ=" << link->getViaLane()->getBruttoVehLenSum() <<
" inner=" << occupancyInner <<
"\n";
182 prevInner = innerLane;
186#ifdef DEBUG_WANTS_CHANGE
188 std::cout <<
" distanceInRoundabout=" << distanceInRoundabout
189 <<
" roundaboutJunctionsAhead=" << roundaboutJunctionsAhead
190 <<
" occupancyInner=" << occupancyInner
191 <<
" occupancyOuter=" << occupancyOuter
196 const double maxOccupancy =
MAX2(occupancyInner, occupancyOuter);
197 if (maxOccupancy == 0) {
202 const double bonus = roundaboutJunctionsAhead * 7.5;
203 const double relativeJam = (occupancyOuter - occupancyInner + bonus) / (maxOccupancy + bonus);
205 double jamFactor =
MAX2(0.0, relativeJam);
211 const double result = distanceInRoundabout * jamFactor * bonusParam * 9;
212#ifdef DEBUG_WANTS_CHANGE
214 std::cout <<
" relativeJam=" << relativeJam
215 <<
" jamFactor=" << jamFactor
216 <<
" distanceBonus=" << result
226#ifdef DEBUG_SAVE_BLOCKER_LENGTH
229 <<
" veh=" << veh.
getID()
242#ifdef DEBUG_SAVE_BLOCKER_LENGTH
245 <<
" veh=" << veh.
getID()
247 <<
" saving myLeadingBlockerLength=" << leadingBlockerLength
256#ifdef DEBUG_SAVE_BLOCKER_LENGTH
259 <<
" veh=" << veh.
getID()
262 <<
" potential=" << potential
263 <<
" myReserved=" << leadingBlockerLength
264 <<
" canReserve=" << canReserve
265 <<
" reliefConnection=" << reliefConnection
269 if (!canReserve && !reliefConnection) {
275#ifdef DEBUG_SAVE_BLOCKER_LENGTH
277 std::cout <<
" reserving anyway to avoid deadlock (will cause emergency braking)\n";
292#ifdef DEBUG_SAVE_BLOCKER_LENGTH
294 std::cout <<
SIMTIME <<
" canSaveBlockerLength veh=" << veh.
getID() <<
" requested=" << requested <<
" leftSpace=" << leftSpace <<
" potential=" << potential <<
"\n";
297 return potential >= requested;
315 const double nextGap = currentGap +
SPEED2DIST(leaderPlannedSpeed - follower.
getSpeed());
317 if (nextGap >= sGap) {
335 if (leader ==
nullptr) {
340 if (lane1 ==
nullptr && lane2 ==
nullptr) {
343 bool result = std::find(cont.begin(), cont.end(), lane1) != cont.end();
344 if (!result && lane1 != lane2 && lane2 !=
nullptr) {
345 result = std::find(cont.begin(), cont.end(), lane2) != cont.end();
353 if (follower ==
nullptr) {
360 if (lane1 !=
nullptr) {
361 result = std::find(route.begin(), route.end(), &lane1->
getEdge()) != route.end();
363 if (!result && lane1 != lane2 && lane2 !=
nullptr) {
364 result = std::find(route.begin(), route.end(), &lane2->
getEdge()) != route.end();
std::vector< const MSEdge * > ConstMSEdgeVector
LaneChangeAction
The state of a vehicle's lane-change behavior.
@ LCA_URGENT
The action is urgent (to be defined by lc-model)
@ LCA_STRATEGIC
The action is needed to follow the route (navigational lc)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
virtual bool saveBlockerLength(double, double)
reserve space at the end of the lane to avoid dead locks
virtual bool debugVehicle() const
whether the current vehicles shall be debugged
const MSRoute & getRoute() const
Returns the current route.
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
virtual double maxNextSpeed(double speed, const MSVehicle *const veh) const
Returns the maximum speed given the current speed.
virtual double minNextSpeed(double speed, const MSVehicle *const veh=0) const
Returns the minimum speed given the current speed (depends on the numerical update scheme and its ste...
virtual double getSecureGap(const MSVehicle *const veh, const MSVehicle *const, const double speed, const double leaderSpeed, const double leaderMaxDecel) const
Returns the minimum gap to reserve if the leader is braking at maximum (>=0)
double brakeGap(const double speed) const
Returns the distance the vehicle needs to halt including driver's reaction time tau (i....
double getMaxDecel() const
Get the vehicle type's maximal comfortable deceleration [m/s^2].
virtual double followSpeed(const MSVehicle *const veh, double speed, double gap2pred, double predSpeed, double predMaxDecel, const MSVehicle *const pred=0, const CalcReason usage=CalcReason::CURRENT) const =0
Computes the vehicle's follow speed (no dawdling)
const MSJunction * getToJunction() const
const MSJunction * getFromJunction() const
bool isRoundabout() const
The base class for an intersection.
const ConstMSEdgeVector & getOutgoing() const
const ConstMSEdgeVector & getIncoming() const
static bool isBidiFollower(const MSVehicle *ego, const MSVehicle *follower)
static bool canSaveBlockerLength(const MSVehicle &veh, double requested, double leftSpace)
static double getSpeedPreservingSecureGap(const MSVehicle &leader, const MSVehicle &follower, double currentGap, double leaderPlannedSpeed)
static double getRoundaboutDistBonus(const MSVehicle &veh, double bonusParam, const MSVehicle::LaneQ &curr, const MSVehicle::LaneQ &neigh, const MSVehicle::LaneQ &best)
static bool isBidiLeader(const MSVehicle *leader, const std::vector< MSLane * > &cont)
static bool updateBlockerLength(const MSVehicle &veh, MSVehicle *blocker, int lcaCounter, double leftSpace, bool reliefConnection, double &leadingBlockerLength)
static bool divergentRoute(const MSVehicle &v1, const MSVehicle &v2)
return whether the vehicles are on the same junction but on divergent paths
Representation of a lane in the micro simulation.
const MSLane * getNormalSuccessorLane() const
get normal lane following this internal lane, for normal lanes, the lane itself is returned
double getBruttoVehLenSum() const
Returns the sum of lengths of vehicles, including their minGaps, which were on the lane during the la...
double getLength() const
Returns the lane's length.
int getIndex() const
Returns the lane's index.
MSLane * getBidiLane() const
retrieve bidirectional lane or nullptr
MSEdge & getEdge() const
Returns the lane's edge.
const MSLane * getNormalPredecessorLane() const
get normal lane leading to this internal lane, for normal lanes, the lane itself is returned
const std::vector< MSLink * > & getLinkCont() const
returns the container with all links !!!
const ConstMSEdgeVector & getEdges() const
Representation of a vehicle in the micro simulation.
MSAbstractLaneChangeModel & getLaneChangeModel()
double getActionStepLengthSecs() const
Returns the vehicle's action step length in secs, i.e. the interval between two action points.
const MSLane * getLane() const
Returns the lane the vehicle is on.
double getSpeed() const
Returns the vehicle's current speed.
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
double getPositionOnLane() const
Get the vehicle's position along the lane.
double getLengthWithGap() const
Get vehicle's length including the minimum gap [m].
static std::string getIDSecure(const T *obj, const std::string &fallBack="NULL")
get an identifier for Named-like object which may be Null
const std::string & getID() const
Returns the id.
A structure representing the best lanes for continuing the current route starting at 'lane'.
std::vector< MSLane * > bestContinuations
MSLane * lane
The described lane.