Skip to content

Commit

Permalink
Merge branch 'main' of github.com:eclipse-sumo/sumo into Netedit_dev
Browse files Browse the repository at this point in the history
  • Loading branch information
palvarezlopez committed Jan 27, 2025
2 parents 1094e78 + fffbb53 commit 4706c2a
Show file tree
Hide file tree
Showing 999 changed files with 10,240 additions and 7,486 deletions.
32 changes: 27 additions & 5 deletions src/marouter/ROMARouteHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ ROMARouteHandler::~ROMARouteHandler() {

void
ROMARouteHandler::myStartElement(int element, const SUMOSAXAttributes& attrs) {
if (element == SUMO_TAG_TRIP || element == SUMO_TAG_VEHICLE) {
myVehicleParameter = SUMOVehicleParserHelper::parseVehicleAttributes(element, attrs, true);
if (element == SUMO_TAG_TRIP || element == SUMO_TAG_VEHICLE || element == SUMO_TAG_FLOW) {
myVehicleParameter = (element == SUMO_TAG_FLOW
? SUMOVehicleParserHelper::parseFlowAttributes(SUMO_TAG_FLOW, attrs, true, true, 0, TIME2STEPS(3600))
: SUMOVehicleParserHelper::parseVehicleAttributes(element, attrs, true));
if (!myVehicleParameter->wasSet(VEHPARS_FROM_TAZ_SET) || myIgnoreTaz) {
if (attrs.hasAttribute(SUMO_ATTR_FROM)) {
myVehicleParameter->fromTaz = attrs.getString(SUMO_ATTR_FROM);
Expand Down Expand Up @@ -82,19 +84,39 @@ ROMARouteHandler::myStartElement(int element, const SUMOSAXAttributes& attrs) {

void
ROMARouteHandler::myEndElement(int element) {
if (element == SUMO_TAG_TRIP || element == SUMO_TAG_VEHICLE) {
if (element == SUMO_TAG_TRIP || element == SUMO_TAG_VEHICLE || element == SUMO_TAG_FLOW) {
if (myVehicleParameter->fromTaz == "" || myVehicleParameter->toTaz == "") {
WRITE_WARNINGF(TL("No origin or no destination given, ignoring '%'!"), myVehicleParameter->id);
} else {
int quota = getScalingQuota(myScale, myNumLoaded);
int quota = 1;
SUMOTime departOffset = 0;
if (element == SUMO_TAG_FLOW) {
int flowSize = 1;
double flowDur = STEPS2TIME(myVehicleParameter->repetitionEnd - myVehicleParameter->depart);
if (myVehicleParameter->repetitionNumber != std::numeric_limits<int>::max()) {
flowSize = myVehicleParameter->repetitionNumber;
} else if (myVehicleParameter->poissonRate > 0) {
flowSize = flowDur * myVehicleParameter->poissonRate;
} else if (myVehicleParameter->repetitionProbability > 0) {
flowSize = flowDur * myVehicleParameter->repetitionProbability;
}
quota = (int)(flowSize * myScale + 0.5);
myNumLoaded += flowSize;
departOffset = TIME2STEPS(flowDur) / quota;
} else {
quota = getScalingQuota(myScale, myNumLoaded);
myNumLoaded += 1;
}
SUMOTime depart = myVehicleParameter->depart;
for (int i = 0; i < quota; i++) {
SUMOVehicleParameter veh = *myVehicleParameter;
veh.id = i == 0 ? myVehicleParameter->id : myVehicleParameter->id + "." + toString(i);
veh.depart = depart;
myMatrix.add(veh,
!myVehicleParameter->wasSet(VEHPARS_FROM_TAZ_SET) || myIgnoreTaz,
!myVehicleParameter->wasSet(VEHPARS_TO_TAZ_SET) || myIgnoreTaz);
depart += departOffset;
}
myNumLoaded += 1;
}
delete myVehicleParameter;
}
Expand Down
2 changes: 1 addition & 1 deletion src/mesosim/MELoop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ MELoop::changeSegment(MEVehicle* veh, SUMOTime leaveTime, MESegment* const toSeg
MSNet::getInstance()->getVehicleControl().scheduleVehicleRemoval(veh);
return leaveTime;
} else if (!MSGlobals::gCheckRoutes && !ignoreLink && !MESegment::isInvalid(onSegment) && &onSegment->getEdge() != &toSegment->getEdge() &&
veh->getEdge()->allowedLanes(*veh->succEdge(1), veh->getVClass()) == nullptr) {
veh->getEdge()->allowedLanes(*veh->succEdge(1), veh->getVClass()) == nullptr) {
if (veh->isStopped()) {
veh->processStop();
}
Expand Down
20 changes: 10 additions & 10 deletions src/microsim/MSLane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4531,18 +4531,18 @@ MSLane::checkForPedestrians(const MSVehicle* aVehicle, double& speed, double& di
const MSLink* link = prev->getLinkTo(cur);
if (link->hasFoeCrossing()) {
for (const MSLane* foe : link->getFoeLanes()) {
if (foe->isCrossing() && (foe->hasPedestrians() ||
(foe->getIncomingLanes()[0].viaLink->getApproachingPersons() != nullptr
&& foe->getIncomingLanes()[0].viaLink->getApproachingPersons()->size() > 0))) {
if (foe->isCrossing() && (foe->hasPedestrians() ||
(foe->getIncomingLanes()[0].viaLink->getApproachingPersons() != nullptr
&& foe->getIncomingLanes()[0].viaLink->getApproachingPersons()->size() > 0))) {
#ifdef DEBUG_INSERTION
if (DEBUG_COND2(aVehicle)) std::cout << SIMTIME
<< " isInsertionSuccess lane=" << getID()
<< " veh=" << aVehicle->getID()
<< " pos=" << pos
<< " backCrossing=" << foe->getID()
<< " peds=" << joinNamedToString(foe->getEdge().getPersons(), " ")
<< " approaching=" << foe->getIncomingLanes()[0].viaLink->getApproachingPersons()->size()
<< " failed (@4550)!\n";
<< " isInsertionSuccess lane=" << getID()
<< " veh=" << aVehicle->getID()
<< " pos=" << pos
<< " backCrossing=" << foe->getID()
<< " peds=" << joinNamedToString(foe->getEdge().getPersons(), " ")
<< " approaching=" << foe->getIncomingLanes()[0].viaLink->getApproachingPersons()->size()
<< " failed (@4550)!\n";
#endif
return false;
}
Expand Down
8 changes: 4 additions & 4 deletions src/microsim/MSLink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ MSLink::opened(SUMOTime arrivalTime, double arrivalSpeed, double leaveSpeed, dou
}
#endif

if (MSGlobals::gUseMesoSim && impatience == 1) {
if (MSGlobals::gUseMesoSim && impatience == 1 && !myLane->getEdge().isRoundabout()) {
return true;
}
const bool lastWasContRed = lastWasContState(LINKSTATE_TL_RED);
Expand Down Expand Up @@ -936,7 +936,7 @@ MSLink::blockedAtTime(SUMOTime arrivalTime, SUMOTime leaveTime, double arrivalSp
for (const auto& it : *myApproachingPersons) {
//#ifdef MSLink_DEBUG_OPENED
// if (gDebugFlag1) {
// std::cout << SIMTIME << ": " << ego->getID() << " check person " << it.first->getID() << " aTime=" << arrivalTime << " foeATime=" << it.second.arrivalTime
// std::cout << SIMTIME << ": " << ego->getID() << " check person " << it.first->getID() << " aTime=" << arrivalTime << " foeATime=" << it.second.arrivalTime
// << " lTime=" << leaveTime << " foeLTime=" << it.second.leavingTime
// << " dist=" << dist << "\n";
// }
Expand Down Expand Up @@ -1739,7 +1739,7 @@ MSLink::getLeaderInfo(const MSVehicle* ego, double dist, std::vector<const MSPer
// advance up to the crossing point unless we have the same target or same source
// (for sameSource, the crossing point indicates the point of divergence)
const bool stopAsap = ((leader->isFrontOnLane(foeLane) ? cannotIgnore : (sameTarget || sameSource))
|| (ego != nullptr && ego->getVehicleType().getParameter().getJMParam(SUMO_ATTR_JM_ADVANCE, 1.0) == 0.0));
|| (ego != nullptr && ego->getVehicleType().getParameter().getJMParam(SUMO_ATTR_JM_ADVANCE, 1.0) == 0.0));
if (gDebugFlag1) {
std::cout << " leader=" << leader->getID() << " contLane=" << contLane << " cannotIgnore=" << cannotIgnore << " stopAsap=" << stopAsap << " gap=" << gap << "\n";
}
Expand All @@ -1762,7 +1762,7 @@ MSLink::getLeaderInfo(const MSVehicle* ego, double dist, std::vector<const MSPer
// @check lefthand?!
const bool wayIn = myConflicts[i].lengthBehindCrossing < myLaneBefore->getLength() * 0.5;
const double vehCenter = (foeDistToCrossing + myLaneBefore->getWidth() * 0.5
+ ego->getLateralPositionOnLane() * (wayIn ? -1 : 1));
+ ego->getLateralPositionOnLane() * (wayIn ? -1 : 1));
// can access the movement model here since we already checked for existing persons above
if (distToPeds >= -MSPModel::SAFETY_GAP && MSNet::getInstance()->getPersonControl().getMovementModel()->blockedAtDist(ego, foeLane, vehCenter, vehWidth,
ego->getVehicleType().getParameter().getJMParam(SUMO_ATTR_JM_CROSSING_GAP, JM_CROSSING_GAP_DEFAULT),
Expand Down
2 changes: 1 addition & 1 deletion src/microsim/MSMoveReminder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ StringBijection<MSMoveReminder::Notification>::Entry MSMoveReminder::Notificatio
};

StringBijection<MSMoveReminder::Notification> MSMoveReminder::Notifications(
MSMoveReminder::NotificationValues, MSMoveReminder::NOTIFICATION_NONE, false);
MSMoveReminder::NotificationValues, MSMoveReminder::NOTIFICATION_NONE, false);

// ===========================================================================
// method definitions
Expand Down
2 changes: 1 addition & 1 deletion src/microsim/MSNet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1642,7 +1642,7 @@ MSNet::warnOnce(const std::string& typeAndID) {
}


MSMapMatcher*
MSMapMatcher*
MSNet::getMapMatcher() const {
auto loader = myRouteLoaders->getFirstLoader();
if (loader != nullptr) {
Expand Down
4 changes: 2 additions & 2 deletions src/microsim/MSRouteHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1371,7 +1371,7 @@ MSRouteHandler::addStop(const SUMOSAXAttributes& attrs) {
edge = myActiveTransportablePlan->back()->getDestination();
stop.lane = edge->getLanes()[0]->getID();
stop.endPos = myActiveTransportablePlan->back()->unspecifiedArrivalPos() ?
MSStage::ARRIVALPOS_UNSPECIFIED : myActiveTransportablePlan->back()->getArrivalPos();
MSStage::ARRIVALPOS_UNSPECIFIED : myActiveTransportablePlan->back()->getArrivalPos();
stop.startPos = MAX2(0., stop.endPos - MIN_STOP_LENGTH);
}
} else {
Expand Down Expand Up @@ -1430,7 +1430,7 @@ MSRouteHandler::addStop(const SUMOSAXAttributes& attrs) {
double pos = (stop.startPos + stop.endPos) / 2.;
if (!myActiveTransportablePlan->empty()) {
pos = myActiveTransportablePlan->back()->unspecifiedArrivalPos() ?
MSStage::ARRIVALPOS_UNSPECIFIED : myActiveTransportablePlan->back()->getArrivalPos();
MSStage::ARRIVALPOS_UNSPECIFIED : myActiveTransportablePlan->back()->getArrivalPos();
}
myActiveTransportablePlan->push_back(new MSStageWaiting(edge, toStop, stop.duration, stop.until, pos, actType, false));
result = myActiveTransportablePlan->back();
Expand Down
4 changes: 2 additions & 2 deletions src/microsim/MSStateHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,8 @@ MSStateHandler::myStartElement(int element, const SUMOSAXAttributes& attrs) {
MSRailSignalConstraint_Predecessor::loadState(attrs);
break;
}
case SUMO_TAG_DRIVEWAY:
case SUMO_TAG_SUBDRIVEWAY: {
case SUMO_TAG_DRIVEWAY:
case SUMO_TAG_SUBDRIVEWAY: {
MSDriveWay::loadState(attrs, element);
break;
}
Expand Down
31 changes: 17 additions & 14 deletions src/microsim/devices/MSDevice_GLOSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ MSDevice_GLOSA::cleanup() {
// MSDevice_GLOSA-methods
// ---------------------------------------------------------------------------
MSDevice_GLOSA::MSDevice_GLOSA(SUMOVehicle& holder, const std::string& id, double minSpeed, double range, double maxSpeedFactor,
double addSwitchTime, bool useQueue, bool overrideSafety, bool ignoreCFModel) :
double addSwitchTime, bool useQueue, bool overrideSafety, bool ignoreCFModel) :
MSVehicleDevice(holder, id),
myVeh(dynamic_cast<MSVehicle&>(holder)),
myNextTLSLink(nullptr),
Expand Down Expand Up @@ -148,8 +148,11 @@ MSDevice_GLOSA::notifyMove(SUMOTrafficObject& /*tObject*/, double oldPos,
// The vehicle should then rather opt for the next phase (trade travel time for traffic flow)
int switchOffset = 0;

if (myNextTLSLink->haveGreen()) { currentPhaseGreen = true; }
else if (myNextTLSLink->haveRed() || myNextTLSLink->haveYellow()) { currentPhaseStop = true; }
if (myNextTLSLink->haveGreen()) {
currentPhaseGreen = true;
} else if (myNextTLSLink->haveRed() || myNextTLSLink->haveYellow()) {
currentPhaseStop = true;
}
// else if any other phase, GLOSA does not interfere
#if defined DEBUG_GLOSA || defined DEBUG_QUEUE
if (DEBUG_COND) {
Expand Down Expand Up @@ -192,7 +195,7 @@ MSDevice_GLOSA::notifyMove(SUMOTrafficObject& /*tObject*/, double oldPos,
}
}

// Search for the next passable phase, maximum 10 Phases
// Search for the next passable phase, maximum 10 Phases
for (int countwhile = 1; countwhile < 11; countwhile++) {
if (currentPhaseGreen) {
// reset nextSwitch because the queue matters only for the current Phase
Expand Down Expand Up @@ -222,9 +225,9 @@ MSDevice_GLOSA::notifyMove(SUMOTrafficObject& /*tObject*/, double oldPos,
const double yellowSlack = myVeh.getVehicleType().getParameter().getJMParam(SUMO_ATTR_JM_DRIVE_AFTER_YELLOW_TIME, 0);
#ifdef DEBUG_GLOSA
if (DEBUG_COND) {
std::cout << SIMTIME << " veh=" << myVeh.getID()
<< " vMax2=" << vMax2
<< " timetoJunction2=" << timetoJunction2
std::cout << SIMTIME << " veh=" << myVeh.getID()
<< " vMax2=" << vMax2
<< " timetoJunction2=" << timetoJunction2
<< " yellowSlack=" << yellowSlack << "\n";
}
#endif
Expand Down Expand Up @@ -253,7 +256,7 @@ MSDevice_GLOSA::notifyMove(SUMOTrafficObject& /*tObject*/, double oldPos,
if (DEBUG_COND) {
std::cout << SIMTIME << " veh=" << myVeh.getID() << " traffic light will be/is red" << "\n";
std::cout << SIMTIME << " veh=" << myVeh.getID()
<< " timeToJunction=" << timeToJunction
<< " timeToJunction=" << timeToJunction
<< " nextSwitch=" << nextSwitch
<< " myDistance=" << myDistance << "\n";
}
Expand Down Expand Up @@ -396,11 +399,11 @@ MSDevice_GLOSA::getTimeToNextSwitch(const MSLink* tlsLink, bool& currentPhaseGre
const auto& phase = phases[(cur + i) % n];
const char ls = phase->getState()[tlsLink->getTLIndex()];
if (currentPhaseGreen && (ls == 'g' || ls == 'G')) {
countOld = (cur + i)%n;
countOld = (cur + i) % n;
break;
}
if (currentPhaseStop && (ls != 'g' && ls != 'G')) {
countOld = (cur + i)%n;
countOld = (cur + i) % n;
break;
}
result += phase->duration;
Expand All @@ -425,7 +428,7 @@ MSDevice_GLOSA::timeGreen(const MSLink* tlsLink) {
for (int i = 1; i < n; i++) {
const auto& phase = phases[(cur - i) % n];
const char ls = phase->getState()[tlsLink->getTLIndex()];
if ( ls != 'g' && ls != 'G') {
if (ls != 'g' && ls != 'G') {
break;
}
result += phase->duration;
Expand Down Expand Up @@ -495,7 +498,7 @@ MSDevice_GLOSA::time_to_junction_at_continuous_accel(double d, double v) {


void
MSDevice_GLOSA::adaptSpeed(double distance, double /*timeToJunction*/, double timeToSwitch, bool &solved) {
MSDevice_GLOSA::adaptSpeed(double distance, double /*timeToJunction*/, double timeToSwitch, bool& solved) {
// ensure that myVehicle arrives at the
// junction with maximum speed when it switches to green
// car performs a slowDown at time z to speed x for duration y
Expand Down Expand Up @@ -539,7 +542,7 @@ MSDevice_GLOSA::adaptSpeed(double distance, double /*timeToJunction*/, double ti
#ifdef DEBUG_GLOSA
WRITE_WARNINGF("GLOSA error 1 root_argument=% s=% t=% v=%", root_argument, s, t, v);
#endif
// no reset of speedFactor because in this case, current speed can be kept
// no reset of speedFactor because in this case, current speed can be kept
solved = true;

return;
Expand Down Expand Up @@ -567,7 +570,7 @@ MSDevice_GLOSA::adaptSpeed(double distance, double /*timeToJunction*/, double ti
WRITE_WARNINGF("GLOSA error 2 x=% y=% s=% t=% v=%", x, y, s, t, v);
#endif
if (x < u) {
#ifdef DEBUG_GLOSA
#ifdef DEBUG_GLOSA
if (DEBUG_COND) {
std::cout << "veh=" << myVeh.getID() << " cant go slow enough" << "\n";
}
Expand Down
6 changes: 3 additions & 3 deletions src/microsim/devices/MSDevice_GLOSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class MSDevice_GLOSA : public MSVehicleDevice {
static double getTimeToSwitch(const MSLink* tlsLink, int& countOld);

/// @brief compute time to next (relevant) switch the vehicle can reach
static double getTimeToNextSwitch(const MSLink* tlsLink, bool &currentPhaseGreen, bool &currentPhaseStop, int& countOld);
static double getTimeToNextSwitch(const MSLink* tlsLink, bool& currentPhaseGreen, bool& currentPhaseStop, int& countOld);

static double timeGreen(const MSLink* tlsLink);

Expand All @@ -165,15 +165,15 @@ class MSDevice_GLOSA : public MSVehicleDevice {
double time_to_junction_at_continuous_accel(double d, double v);

/// @brief adapt speed to reach junction at green
void adaptSpeed(double distance, double timeToJunction, double timeToSwitch, bool &solved);
void adaptSpeed(double distance, double timeToJunction, double timeToSwitch, bool& solved);

/** @brief Constructor
*
* @param[in] holder The vehicle that holds this device
* @param[in] id The ID of the device
*/
MSDevice_GLOSA(SUMOVehicle& holder, const std::string& id, double minSpeed, double range, double maxSpeedFactor,
double addSwitchTime, bool useQueue, bool overrideSafety, bool ignoreCFModel);
double addSwitchTime, bool useQueue, bool overrideSafety, bool ignoreCFModel);



Expand Down
2 changes: 2 additions & 0 deletions src/microsim/output/MSMeanData_Net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ MSMeanData_Net::MSLaneMeanDataValues::notifyMoveInternal(
if (!veh.isStopped()) {
if (myParent != nullptr && meanSpeedVehicleOnLane < myParent->myHaltSpeed) {
waitSeconds += timeOnLane;
} else if (MSGlobals::gUseMesoSim) {
waitSeconds += STEPS2TIME(veh.getWaitingTime());
}
const double vmax = veh.getLane() == nullptr ? veh.getEdge()->getVehicleMaxSpeed(&veh) : veh.getLane()->getVehicleMaxSpeed(&veh);
if (vmax > 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/microsim/traffic_lights/MSDriveWay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ MSDriveWay::buildRoute(const MSLink* origin,
// larger countries (USA, Russia) might see blocks beyond 20km)
if (myRoute.size() == 0 || myBlockLengthWarnings.count(myRoute.front()) == 0) {
WRITE_WARNINGF("Block after % exceeds maximum length (stopped searching after edge '%' (length=%m).",
warnID, toLane->getEdge().getID(), length);
warnID, toLane->getEdge().getID(), length);
myBlockLengthWarnings.insert(myRoute.front());
}
myAbortedBuild = true;
Expand Down
Loading

0 comments on commit 4706c2a

Please sign in to comment.