Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/web/docs/Simulation/Meso.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ The headways are scaled according to the inverse of the lane number
Each of these values is multiplied with the 'tau' configure in the vehicle type (`vType`) of the considered vehicle (default 'tau' is *1*).

!!! note
The values tauff, taufj and taujf denote net-time gaps (vehicle front bumper to leader back-bumper). The actual gross time gap is computed from this by taking into account the vehicle length.
The values tauff, taufj and taujf denote net-time gaps (vehicle front bumper to leader back-bumper). The gross time gap adds the time needed to cover the vehicle length and minimum gap at that vehicle's free-flow speed.

The value taujj configures the speed with which the jam front moves
upstream when a multi-segment jam clears.
Expand Down
3 changes: 1 addition & 2 deletions src/mesosim/MELSegment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ MELSegment::computeHeadway(Queue& /*q*/, const Queue& /*qNext*/, const MESegment
// and every leader car that uses tau_jf applies queing timeLoss to it's followers
const SUMOTime waiting = veh->getWaitingTime();
SUMOTime headway = tauWithVehLength(waiting > 0 ? myTau_ff + MIN2(waiting, myTau_jf - myTau_ff) : myTau_ff,
veh->getVehicleType().getLengthWithGap(),
veh->getVehicleType().getCarFollowModel().getHeadwayTime());
*veh, veh->getQueIndex());
if (myTLSPenalty) {
const MSLink* const tllink = getLink(veh, true);
if (tllink != nullptr && tllink->isTLSControlled()) {
Expand Down
28 changes: 19 additions & 9 deletions src/mesosim/MESegment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,15 +375,15 @@ MESegment::prepareDetectorForWriting(MSMoveReminder& data, int queueIndex) {
for (std::vector<MEVehicle*>::const_reverse_iterator i = q.getVehicles().rbegin(); i != q.getVehicles().rend(); ++i) {
const SUMOTime exitTime = MAX2(earliestExitTime, (*i)->getEventTime());
(*i)->updateDetectorForWriting(&data, currentTime, exitTime);
earliestExitTime = exitTime + tauWithVehLength(myTau_ff, (*i)->getVehicleType().getLengthWithGap(), (*i)->getVehicleType().getCarFollowModel().getHeadwayTime());
earliestExitTime = exitTime + getMinTauWithVehLength((*i)->getQueIndex(), **i);
}
}
} else {
SUMOTime earliestExitTime = currentTime;
for (std::vector<MEVehicle*>::const_reverse_iterator i = myQueues[queueIndex].getVehicles().rbegin(); i != myQueues[queueIndex].getVehicles().rend(); ++i) {
const SUMOTime exitTime = MAX2(earliestExitTime, (*i)->getEventTime());
(*i)->updateDetectorForWriting(&data, currentTime, exitTime);
earliestExitTime = exitTime + tauWithVehLength(myTau_ff, (*i)->getVehicleType().getLengthWithGap(), (*i)->getVehicleType().getCarFollowModel().getHeadwayTime());
earliestExitTime = exitTime + getMinTauWithVehLength(queueIndex, **i);
}
}
}
Expand Down Expand Up @@ -517,7 +517,7 @@ MESegment::getMeanSpeed(bool useCached) const {
count += q.size();
for (std::vector<MEVehicle*>::const_reverse_iterator veh = q.getVehicles().rbegin(); veh != q.getVehicles().rend(); ++veh) {
v += (*veh)->getConservativeSpeed(earliestExitTime); // earliestExitTime is updated!
earliestExitTime += tauWithVehLength(tau, (*veh)->getVehicleType().getLengthWithGap(), (*veh)->getVehicleType().getCarFollowModel().getHeadwayTime());
earliestExitTime += tauWithVehLength(tau, **veh, (*veh)->getQueIndex());
}
}
if (count == 0) {
Expand Down Expand Up @@ -559,7 +559,7 @@ MESegment::updateMesoPositions() const {
double maxPos = segmentOffset + segLength;
const double oldPos = MAX2(0., veh->getMesoPosition());
if (i > 0) {
earliestExitTime += getMinTauWithVehLength(vehLength, veh->getVehicleType().getCarFollowModel().getHeadwayTime());
earliestExitTime += getMinTauWithVehLength(qIdx, *veh);
maxPos = MIN2(maxPos, prevPos - vehLength / lanesCovered);
}
const double entry = veh->getLastEntryTimeSeconds();
Expand Down Expand Up @@ -723,7 +723,7 @@ MESegment::computeHeadway(Queue& /*q*/, const Queue& qNext, const MESegment* con
? (nextFree ? myTau_ff : myTau_fj)
: (nextFree ? myTau_jf : getTauJJ((double)qNext.size(), next->myQueueCapacity, next->myJamThreshold)));
assert(tau >= 0);
SUMOTime headway = tauWithVehLength(tau, veh->getVehicleType().getLengthWithGap(), veh->getVehicleType().getCarFollowModel().getHeadwayTime());
SUMOTime headway = tauWithVehLength(tau, *veh, veh->getQueIndex());
if (myTLSPenalty) {
const MSLink* const tllink = getLink(veh, true);
if (tllink != nullptr && tllink->isTLSControlled()) {
Expand Down Expand Up @@ -817,6 +817,16 @@ MESegment::getVehicleMaxSpeed(const MEVehicle& veh, int queueIndex) const {
}


SUMOTime
MESegment::tauWithVehLength(SUMOTime tau, const MEVehicle& veh, int qIdx) const {
const double speed = MAX2(MESO_MIN_SPEED, getVehicleMaxSpeed(veh, qIdx));
const double laneScale = myQueueCapacity / myLength;
const double tauLength = (double)TIME2STEPS(1) / speed / laneScale;
const MSVehicleType& type = veh.getVehicleType();
return (SUMOTime)((double)tau * type.getCarFollowModel().getHeadwayTime() + type.getLengthWithGap() * tauLength);
}


void
MESegment::receive(MEVehicle* veh, const int qIdx, SUMOTime time, const bool isDepart, const bool isTeleport, const bool newEdge) {
const double speed = isDepart ? -1 : MAX2(veh->getSpeed(), MESO_MIN_SPEED); // on the previous segment
Expand Down Expand Up @@ -873,7 +883,7 @@ MESegment::receive(MEVehicle* veh, const int qIdx, SUMOTime time, const bool isD
}
cars.insert(cars.begin() + 1, veh);
} else {
tleave = MAX2(leaderOut + tauWithVehLength(myTau_ff, cars[0]->getVehicleType().getLengthWithGap(), cars[0]->getVehicleType().getCarFollowModel().getHeadwayTime()), tleave);
tleave = MAX2(leaderOut + getMinTauWithVehLength(qIdx, *cars[0]), tleave);
cars.insert(cars.begin(), veh);
}
}
Expand All @@ -883,7 +893,7 @@ MESegment::receive(MEVehicle* veh, const int qIdx, SUMOTime time, const bool isD
if (!isDepart && !isTeleport) {
// departs and teleports could take place anywhere on the edge so they should not block regular flow
// the -1 facilitates interleaving of multiple streams
q.setEntryBlockTime(time + tauWithVehLength(myTau_ff, veh->getVehicleType().getLengthWithGap(), veh->getVehicleType().getCarFollowModel().getHeadwayTime()) - 1);
q.setEntryBlockTime(time + getMinTauWithVehLength(qIdx, *veh) - 1);
}
q.setOccupancy(MIN2(myQueueCapacity, q.getOccupancy() + veh->getVehicleType().getLengthWithGap()));
veh->setEventTime(tleave);
Expand Down Expand Up @@ -932,7 +942,7 @@ MESegment::setSpeedForQueue(double newSpeed, SUMOTime currentTime, SUMOTime bloc
SUMOTime oldEarliestExitTime = currentTime;
const SUMOTime oldExit = MAX2(oldEarliestExitTime, v->getEventTime());
v->updateDetectors(currentTime, oldExit, false);
oldEarliestExitTime = oldExit + tauWithVehLength(myTau_ff, v->getVehicleType().getLengthWithGap(), v->getVehicleType().getCarFollowModel().getHeadwayTime());
oldEarliestExitTime = oldExit + getMinTauWithVehLength(v->getQueIndex(), *v);
SUMOTime newEvent = MAX2(newArrival(v, newSpeed, currentTime), blockTime);
if (v->getEventTime() != newEvent) {
MSGlobals::gMesoNet->removeLeaderCar(v);
Expand All @@ -942,7 +952,7 @@ MESegment::setSpeedForQueue(double newSpeed, SUMOTime currentTime, SUMOTime bloc
for (std::vector<MEVehicle*>::const_reverse_iterator i = vehs.rbegin() + 1; i != vehs.rend(); ++i) {
const SUMOTime oldExitTime = MAX2(oldEarliestExitTime, (*i)->getEventTime());
(*i)->updateDetectors(currentTime, oldExitTime, false);
const SUMOTime minTau = tauWithVehLength(myTau_ff, (*i)->getVehicleType().getLengthWithGap(), (*i)->getVehicleType().getCarFollowModel().getHeadwayTime());
const SUMOTime minTau = getMinTauWithVehLength((*i)->getQueIndex(), **i);
oldEarliestExitTime = oldExitTime + minTau;
newEvent = MAX2(newArrival(*i, newSpeed, currentTime), newEvent + minTau);
(*i)->setEventTime(newEvent);
Expand Down
13 changes: 8 additions & 5 deletions src/mesosim/MESegment.h
Original file line number Diff line number Diff line change
Expand Up @@ -543,15 +543,15 @@ class MESegment : public Named {
}

/// @brief convert net time gap (leader back to follower front) to gross time gap (leader front to follower front)
inline SUMOTime getMinTauWithVehLength(double lengthWithGap, double vehicleTau) const {
return (SUMOTime)((double)myTau_ff * vehicleTau + lengthWithGap * myTau_length);
inline SUMOTime getMinTauWithVehLength(int qIdx, const MEVehicle& veh) const {
return tauWithVehLength(myTau_ff, veh, qIdx);
}

/// @brief like getMinTauWithVehLength but using the jam-state dependent net time gap of the given queue (as in getMeanSpeed)
inline SUMOTime getTauWithVehLength(int qIdx, double lengthWithGap, double vehicleTau) const {
inline SUMOTime getTauWithVehLength(int qIdx, const MEVehicle& veh) const {
assert(qIdx >= 0 && qIdx < (int)myQueues.size());
const SUMOTime tau = myQueues[qIdx].getOccupancy() < myJamThreshold ? myTau_ff : myTau_jf;
return tauWithVehLength(tau, lengthWithGap, vehicleTau);
return tauWithVehLength(tau, veh, qIdx);
}

protected:
Expand Down Expand Up @@ -580,11 +580,14 @@ class MESegment : public Named {
/// @brief whether the given link may be passed because the option meso-junction-control.limited is set
bool limitedControlOverride(const MSLink* link) const;

/// @brief convert net time gap (leader back to follower front) to gross time gap (leader front to follower front)
/// @brief Gross time gap at the nominal segment speed, used for calibration.
inline SUMOTime tauWithVehLength(SUMOTime tau, double lengthWithGap, double vehicleTau) const {
return (SUMOTime)((double)tau * vehicleTau + lengthWithGap * myTau_length);
}

/// @brief Gross time gap at the vehicle's free-flow speed for the given queue.
SUMOTime tauWithVehLength(SUMOTime tau, const MEVehicle& veh, int qIdx) const;

SUMOTime getTauJJ(double nextQueueSize, double nextQueueCapacity, double nextJamThreshold) const;

/// @brief compute current headway depending on traffic state
Expand Down
4 changes: 2 additions & 2 deletions src/microsim/output/MSQueueExport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ MSQueueExport::writeMesoQueue(OutputDevice* of, const MSEdge& edge, const MESegm
conservativeExitTime = MAX2(conservativeExitTime, veh->getEventTime());
double maxPos = segmentEnd;
if (i > 0) {
earliestExitTime += segment.getMinTauWithVehLength(lengthWithGap, veh->getVehicleType().getCarFollowModel().getHeadwayTime());
conservativeExitTime += segment.getTauWithVehLength(qIdx, lengthWithGap, veh->getVehicleType().getCarFollowModel().getHeadwayTime());
earliestExitTime += segment.getMinTauWithVehLength(qIdx, *veh);
conservativeExitTime += segment.getTauWithVehLength(qIdx, *veh);
maxPos = MIN2(maxPos, prevPos - lengthWithGap / lanesCovered);
}
const double entry = veh->getLastEntryTimeSeconds();
Expand Down
46 changes: 23 additions & 23 deletions tests/complex/state/meso/actuated_detectors/state.complex.meso
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,15 @@
</vType>
<vehicle id="WE.64" depart="256.000" route="WE" distance="579.200000000 0" speedFactor="0.972900000" state="2208 256000 1 0 2 0 300397 293254 9223372036854774807 0 0 0 572 300397"/>
<vehicle id="WE.65" depart="260.000" route="WE" distance="579.200000000 0" speedFactor="0.940100000" state="2208 260000 1 0 2 0 305951 298558 9223372036854774807 0 0 0 568 305951"/>
<vehicle id="WE.66" depart="264.000" route="WE" distance="579.200000000 0" speedFactor="1.055700000" state="2208 264000 1 0 1 0 299392 292024 9223372036854774807 0 0 0 578 299392"/>
<vehicle id="WE.66" depart="264.000" route="WE" distance="579.200000000 0" speedFactor="1.055700000" state="2208 264000 1 0 1 0 299410 292059 9223372036854774807 0 0 0 578 299410"/>
<vehicle id="WE.67" depart="268.000" route="WE" distance="579.200000000 0" speedFactor="0.955100000" state="2208 268000 1 0 1 0 305953 298676 9223372036854774807 0 0 0 565 305953"/>
<vehicle id="WE.68" depart="272.000" route="WE" distance="579.200000000 0" speedFactor="0.984900000" state="2208 272000 1 0 0 0 301744 294688 9223372036854774807 0 0 0 579 301744"/>
<vehicle id="WE.69" depart="276.000" route="WE" distance="579.200000000 0" speedFactor="1.032500000" state="2208 276000 1 0 0 0 304374 297643 9223372036854774807 0 0 0 576 304374"/>
<vehicle id="WE.70" depart="280.000" route="WE" distance="0.000000000 0" speedFactor="0.981900000" state="2208 280000 0 0 2 0 301234 294156 9223372036854774807 0 0 0 575 301234"/>
<vehicle id="SN.7" depart="280.000" route="SN" distance="0.000000000 0" speedFactor="1.007300000" state="2208 280000 0 0 2 0 300697 293798 9223372036854774807 0 0 0 570 300697"/>
<vehicle id="bSN.4" type="busType" depart="280.000" route="SN" distance="0.000000000 0" speedFactor="1.000000000" state="2210 280000 0 0 2 0 302416 295466 9223372036854774807 0 0 0 573 302416">
<device id="tripinfo_bSN.4" state="SC_0 12.483296694 -0.000000000 783 0 0 0 -1 -1000 NONE -1.000000000 0.000000000 -1.000000000 1566"/>
<rem id="tripinfo_bSN.4" time="295466" pos="193.066666667"/>
<vehicle id="bSN.4" type="busType" depart="280.000" route="SN" distance="0.000000000 0" speedFactor="1.000000000" state="2210 280000 0 0 2 0 302413 295463 9223372036854774807 0 0 0 573 302413">
<device id="tripinfo_bSN.4" state="SC_0 12.484911192 -0.000000000 781 0 0 0 -1 -1000 NONE -1.000000000 0.000000000 -1.000000000 1563"/>
<rem id="tripinfo_bSN.4" time="295463" pos="193.066666667"/>
</vehicle>
<vehicle id="WE.71" depart="284.000" route="WE" distance="0.000000000 0" speedFactor="1.086900000" state="2208 284000 0 0 2 0 303182 296788 9223372036854774807 0 0 0 571 303182"/>
<vehicle id="WE.72" depart="288.000" route="WE" distance="0.000000000 0" speedFactor="1.034500000" state="2208 288000 0 0 1 0 301436 294718 9223372036854774807 0 0 0 577 301436"/>
Expand All @@ -135,47 +135,47 @@
<flowState id="SN" begin="0.000" end="1000.000" period="40" next="320.000000000" route="SN" done="8" index="8"/>
<flowState id="bSN" type="busType" begin="0.000" end="1000.000" period="70" next="350.000000000" route="SN" done="5" index="5"/>
<segment id=":C_7:0">
<vehicles time="266103" blockTime="264465" value=""/>
<vehicles time="266154" blockTime="264516" value=""/>
</segment>
<segment id=":C_10:0">
<vehicles time="299312" blockTime="297861" value=""/>
<vehicles time="299295" blockTime="297844" value=""/>
</segment>
<segment id="CE:0">
<vehicles time="299510" blockTime="298476" value="WE.69 WE.68"/>
<vehicles time="299523" blockTime="298468" value="WE.69 WE.68"/>
</segment>
<segment id="CE:1">
<vehicles time="299392" blockTime="299509" value="WE.67 WE.66"/>
<vehicles time="299410" blockTime="299522" value="WE.67 WE.66"/>
</segment>
<segment id="CE:2">
<vehicles time="294228" blockTime="299391" value="WE.65 WE.64"/>
<vehicles time="294228" blockTime="299409" value="WE.65 WE.64"/>
</segment>
<segment id="CN:0">
<vehicles time="272867" blockTime="265267" value=""/>
<vehicles time="272893" blockTime="265293" value=""/>
</segment>
<segment id="CN:1">
<vehicles time="280466" blockTime="272866" value=""/>
<vehicles time="280492" blockTime="272892" value=""/>
</segment>
<segment id="CN:2">
<vehicles time="287231" blockTime="280465" value=""/>
<vehicles time="287231" blockTime="280491" value=""/>
</segment>
<segment id="SC:0">
<vehicles time="288819" blockTime="-9223372036854775808" value=""/>
<vehicles time="288818" blockTime="-9223372036854775808" value=""/>
</segment>
<segment id="SC:1">
<vehicles time="296552" blockTime="288818" value=""/>
<vehicles time="296549" blockTime="288817" value=""/>
</segment>
<segment id="SC:2">
<vehicles time="264466" blockTime="297638" value="bSN.4 SN.7"/>
<vehicles time="264517" blockTime="297635" value="bSN.4 SN.7"/>
<vehicles time="-1" blockTime="-9223372036854775808" value=""/>
</segment>
<segment id="WC:0">
<vehicles time="299797" blockTime="-9223372036854775808" value="WE.74"/>
<vehicles time="299798" blockTime="-9223372036854775808" value="WE.74"/>
</segment>
<segment id="WC:1">
<vehicles time="297622" blockTime="299796" value="WE.73 WE.72"/>
<vehicles time="297601" blockTime="299797" value="WE.73 WE.72"/>
</segment>
<segment id="WC:2">
<vehicles time="297862" blockTime="298456" value="WE.71 WE.70"/>
<vehicles time="297845" blockTime="298413" value="WE.71 WE.70"/>
<vehicles time="-1" blockTime="-9223372036854775808" value=""/>
</segment>
<tlLogic id="C" programID="0" phase="0" duration="30000" until="303000" cycleTime="30000" active="0"/>
Expand All @@ -184,9 +184,9 @@
<inductionLoop id="C_P1_D0.1" time="-3600.000000000" next="" last="" headway="-1000"/>
<inductionLoop id="C_P1_D1.0" time="-3600.000000000" next="" last="" headway="-1000"/>
<inductionLoop id="C_P1_D1.1" time="-3600.000000000" next="" last="" headway="-1000"/>
<inductionLoop id="C_P1_D2.0" time="-3600.000000000" next="299018 300725" last="261466" headway="1669"/>
<inductionLoop id="C_P1_D2.1" time="-3600.000000000" next="" last="" headway="1669"/>
<inductionLoop id="C_P1_D3.0" time="-3600.000000000" next="299511 301626" last="296531" headway="1669"/>
<inductionLoop id="C_P1_D3.1" time="-3600.000000000" next="" last="" headway="1669"/>
<inductionLoop id="dBus" time="-3600.000000000" next="295936" last="225234" headway="1669"/>
<inductionLoop id="C_P1_D2.0" time="-3600.000000000" next="299018 300722" last="261466" headway="1720"/>
<inductionLoop id="C_P1_D2.1" time="-3600.000000000" next="" last="" headway="1720"/>
<inductionLoop id="C_P1_D3.0" time="-3600.000000000" next="299511 301626" last="296540" headway="1652"/>
<inductionLoop id="C_P1_D3.1" time="-3600.000000000" next="" last="" headway="1652"/>
<inductionLoop id="dBus" time="-3600.000000000" next="295933" last="225234" headway="1720"/>
</snapshot>
Loading
Loading