Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

7578 leftovers #15604

Merged
merged 8 commits into from
Oct 17, 2024
Merged
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 data/xsd/state_file.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@
<xsd:complexType name="driveWayStateType">
<xsd:attribute name="id" type="idType" use="required"/>
<xsd:attribute name="edges" type="xsd:string" use="required"/>
<xsd:attribute name="vehicles" type="xsd:string" use="required"/>
<xsd:attribute name="vehicles" type="xsd:string" use="optional"/>
</xsd:complexType>

</xsd:schema>
44 changes: 36 additions & 8 deletions src/microsim/traffic_lights/MSDriveWay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@
//#define SUBDRIVEWAY_WARN_NOCONFLICT

//#define DEBUG_BUILD_DRIVEWAY
//#define DEBUG_BUILD_SUBDRIVEWAY
//#define DEBUG_ADD_FOES
//#define DEBUG_BUILD_SIDINGS
//#define DEBUG_DRIVEWAY_BUILDROUTE
//#define DEBUG_CHECK_FLANKS
//#define DEBUG_SIGNALSTATE_PRIORITY
Expand Down Expand Up @@ -102,6 +99,8 @@ MSDriveWay::MSDriveWay(const MSLink* origin, const std::string& id, bool tempora
myFoundSignal(false),
myFoundJump(false),
myTerminateRoute(false),
myAbortedBuild(false),
myBidiEnded(false),
myIsSubDriveway(false)
{}

Expand Down Expand Up @@ -845,7 +844,11 @@ MSDriveWay::buildRoute(const MSLink* origin, double length,
" exceeds maximum length (stopped searching after edge '" + toLane->getEdge().getID() + "' (length=" + toString(length) + "m).");
}
myNumWarnings++;
myAbortedBuild = true;
// length exceeded
#ifdef DEBUG_DRIVEWAY_BUILDROUTE
if (gDebugFlag4) std::cout << " abort: length=" << length << "\n";
#endif
return;
}
#ifdef DEBUG_DRIVEWAY_BUILDROUTE
Expand Down Expand Up @@ -934,6 +937,10 @@ MSDriveWay::buildRoute(const MSLink* origin, double length,
if (link == origin) {
WRITE_WARNINGF(TL("Found circular block after % (% edges, length %)"), warnID, toString(myRoute.size()), toString(length));
//std::cout << getClickableTLLinkID(origin) << " circularBlock2=" << toString(myRoute) << "\n";
myAbortedBuild = true;
#ifdef DEBUG_DRIVEWAY_BUILDROUTE
if (gDebugFlag4) std::cout << " abort: found circle\n";
#endif
return;
}
seekForwardSignal = false;
Expand Down Expand Up @@ -981,6 +988,10 @@ MSDriveWay::buildRoute(const MSLink* origin, double length,
}
}
}
myBidiEnded = !seekBidiSwitch;
#ifdef DEBUG_DRIVEWAY_BUILDROUTE
if (gDebugFlag4) std::cout << " normalEnd myBidiEnded=" << myBidiEnded << "\n";
#endif
}


Expand Down Expand Up @@ -1379,7 +1390,7 @@ MSDriveWay::match(MSRouteIterator firstIt, MSRouteIterator endIt) const {
// if the vehicle arrives before the end of this driveway,
// we'd rather build a new driveway to avoid superfluous restrictions
if (match && itDwRoute == myRoute.end()
&& (itRoute == endIt || myFoundSignal || myFoundJump || myIsSubDriveway)) {
&& (itRoute == endIt || myAbortedBuild || myBidiEnded || myFoundJump || myIsSubDriveway)) {
//std::cout << " using dw=" << "\n";
if (itRoute != endIt) {
// check whether the current route requires an extended driveway
Expand Down Expand Up @@ -1722,7 +1733,7 @@ MSDriveWay::addSidings(MSDriveWay* foe, bool addToFoe) {
auto itFind = std::find(foeSearchBeg, foeSearchEnd, cur->getBidiEdge());
if (itFind != foeSearchEnd) {
#ifdef DEBUG_BUILD_SIDINGS
std::cout << "endSiding " << getID() << " foe=" << foe->getID() << " i=" << i << " curBidi=" << Named::getIDSecure(cur->getBidiEdge()) << " length=" << length << "\n";
std::cout << "endSiding " << getID() << " foe=" << foe->getID() << " i=" << i << " curBidi=" << Named::getIDSecure(cur->getBidiEdge()) << " length=" << toString(length) << "\n";
#endif
const int firstIndex = i + 1;
if (addToFoe) {
Expand Down Expand Up @@ -1876,15 +1887,28 @@ MSDriveWay::saveState(OutputDevice& out) {

void
MSDriveWay::_saveState(OutputDevice& out) const {
if (!myTrains.empty()) {
if (!myTrains.empty() || haveSubTrains()) {
out.openTag(myIsSubDriveway ? SUMO_TAG_SUBDRIVEWAY : SUMO_TAG_DRIVEWAY);
out.writeAttr(SUMO_ATTR_ID, getID());
out.writeAttr(SUMO_ATTR_EDGES, toString(myRoute));
out.writeAttr(SUMO_ATTR_VEHICLES, toString(myTrains));
if (!myTrains.empty()) {
out.writeAttr(SUMO_ATTR_VEHICLES, toString(myTrains));
}
out.closeTag();
}
}


bool
MSDriveWay::haveSubTrains() const {
for (MSDriveWay* sub : mySubDriveWays) {
if (!sub->myTrains.empty()) {
return true;
}
}
return false;
}

void
MSDriveWay::loadState(const SUMOSAXAttributes& attrs, int tag) {
if ((int)myDriveWayRouteLookup.size() < myGlobalDriveWayIndex) {
Expand All @@ -1906,6 +1930,8 @@ MSDriveWay::loadState(const SUMOSAXAttributes& attrs, int tag) {
if (tag == SUMO_TAG_DRIVEWAY) {
auto it = myDriveWayRouteLookup.find(route);
if (it == myDriveWayRouteLookup.end()) {
//WRITE_WARNING(TLF("Unknown driveWay '%' with route '%'", id, edges));
//return;
throw ProcessError(TLF("Unknown driveWay '%' with route '%'", id, edges));
}
dw = it->second;
Expand All @@ -1914,6 +1940,8 @@ MSDriveWay::loadState(const SUMOSAXAttributes& attrs, int tag) {
std::string parentID = id.substr(0, id.rfind('.'));
auto it = myDriveWayLookup.find(parentID);
if (it == myDriveWayLookup.end()) {
//WRITE_WARNING(TLF("Unknown parent driveway '%' for subDriveWay '%'", parentID, id));
//return;
throw ProcessError(TLF("Unknown parent driveway '%' for subDriveWay '%'", parentID, id));
}
MSDriveWay* parent = it->second;
Expand All @@ -1929,7 +1957,7 @@ MSDriveWay::loadState(const SUMOSAXAttributes& attrs, int tag) {
return;
}
}
const std::string vehicles = attrs.get<std::string>(SUMO_ATTR_VEHICLES, id.c_str(), ok);
const std::string vehicles = attrs.getOpt<std::string>(SUMO_ATTR_VEHICLES, id.c_str(), ok, "");
for (const std::string& vehID : StringTokenizer(vehicles).getVector()) {
MSBaseVehicle* veh = dynamic_cast<MSBaseVehicle*>(c.getVehicle(vehID));
if (veh == nullptr) {
Expand Down
6 changes: 6 additions & 0 deletions src/microsim/traffic_lights/MSDriveWay.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@ class MSDriveWay : public MSMoveReminder, public Named {
bool myFoundSignal;
bool myFoundJump;
bool myTerminateRoute;
/// @brief whether driveway building was aborted due to MAX_BLOCK_LENGTH
bool myAbortedBuild;
/// @brief whether driveway building was aborted when no further bidi edge was found
bool myBidiEnded;
bool myIsSubDriveway;

/* @brief the actual driveway part up to the next railsignal (halting position)
Expand Down Expand Up @@ -296,6 +300,8 @@ class MSDriveWay : public MSMoveReminder, public Named {

void addSwitchFoes(MSLink* link);

bool haveSubTrains() const;

static bool hasJoin(const SUMOVehicle* ego, const SUMOVehicle* foe);

static bool isSwitch(const MSLink* link);
Expand Down
1 change: 1 addition & 0 deletions tests/complex/state/rail/save_on_rail_signal/state.complex
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
</sumoConfiguration>
-->


<snapshot xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/state_file.xsd" version="v1_21_0+0063-40d747df57b" time="116.00" type="micro" rail="1">
<route id="!train2" state="0" edges="-e -b -d"/>
<route id="!train3" state="0" edges="-e -b -d"/>
Expand Down
7 changes: 6 additions & 1 deletion tests/complex/state/rail/save_rail_signal2/output.complex
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
Loading net-file from 'net.net.xml' ... done (5ms).
Loading done.

Simulation version v1_21_0+0063-40d747df57b started with time: 0.00.
Simulation ended at time: 54.00.

Reason: All vehicles have left the simulation.
Loading net-file from 'net.net.xml' ... done (6ms).
Loading state from 'state.xml' ... done (40ms).
Loading done.

Simulation version v1_20_0+0703-550959f676a started with time: 20.00.

Simulation version v1_21_0+0063-40d747df57b started with time: 20.00.
Simulation ended at time: 54.00.

Reason: All vehicles have left the simulation.
< <entry id="train" time="9.00" reason="1"/>
> <exit id="train" time="31.00" reason="9"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<!-- generated on 2024-10-17 10:24:01 by Eclipse SUMO sumo Version v1_21_0+0063-40d747df57b
<sumoConfiguration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/sumoConfiguration.xsd">


<input>
<net-file value="net.net.xml"/>
<route-files value="input_routes.rou.xml"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>


<!-- generated on 2024-10-17 10:24:01 by Eclipse SUMO sumo Version v1_21_0+0063-40d747df57b
<sumoConfiguration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/sumoConfiguration.xsd">


<input>
<net-file value="net.net.xml"/>
<load-state value="state.xml"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>


<!-- generated on 2024-10-17 10:24:01 by Eclipse SUMO sumo Version v1_21_0+0063-40d747df57b
<sumoConfiguration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/sumoConfiguration.xsd">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>


<!-- generated on 2024-10-17 10:24:01 by Eclipse SUMO sumo Version v1_21_0+0063-40d747df57b
<sumoConfiguration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/sumoConfiguration.xsd">


<input>
<net-file value="net.net.xml"/>
<load-state value="state.xml"/>
Expand Down
5 changes: 5 additions & 0 deletions tests/complex/state/rail/save_rail_signal2/state.complex
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>


<!-- generated on 2024-10-17 10:24:01 by Eclipse SUMO sumo Version v1_21_0+0063-40d747df57b
<sumoConfiguration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/sumoConfiguration.xsd">

Expand Down Expand Up @@ -28,7 +29,9 @@
</sumoConfiguration>
-->


<snapshot xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/state_file.xsd" version="v1_21_0+0063-40d747df57b" time="20.00" type="micro" rail="1">

<route id="!train" state="0" edges="a b c d"/>
<route id="!train2" state="0" edges="-d2 -c -b -a2"/>
<delay number="2" begin="2" end="0" depart="0.00" time="0.00"/>
Expand All @@ -55,4 +58,6 @@
<driveWay id="gneJ7.d0" edges="-d2 -c -b -a2" vehicles="train2"/>
<driveWay id="A.0" edges="b c d" vehicles="train"/>
<subDriveWay id="A.0.0" edges="b c" vehicles="train"/>
<driveWay id="gneJ7.d0" edges="-d2 -c -b -a2" vehicles="train2"/>

</snapshot>
22 changes: 12 additions & 10 deletions tests/complex/state/rail/save_rail_signal_constraint/output.complex
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
Loading net-file from 'net.net.xml' ... done (0ms).
Loading additional-files from 'input_additional.add.xml' ... done (11ms).
Loading additional-files from 'input_additional2.add.xml' ... done (10ms).

Loading additional-files from 'input_additional.add.xml' ... done (5ms).
Loading additional-files from 'input_additional2.add.xml' ... done (5ms).
Loading done.
Simulation version v1_21_0+0063-40d747df57b started with time: 0.00.
Simulation ended at time: 269.00.
Simulation version v1_20_0+0703-550959f676a started with time: 0.00.
Simulation ended at time: 269.00
Reason: All vehicles have left the simulation.
DijkstraRouter answered 8 queries and explored 1.88 edges on average.
DijkstraRouter answered 7 queries and explored 2.00 edges on average.
DijkstraRouter spent 0.00s answering queries (0.00ms on average).
Loading net-file from 'net.net.xml' ... done (0ms).
Loading additional-files from 'input_additional.add.xml' ... done (16ms).
Loading additional-files from 'input_additional2.add.xml' ... done (11ms).
Loading state from 'state.xml' ... done (13ms).
Loading additional-files from 'input_additional.add.xml' ... done (7ms).
Loading additional-files from 'input_additional2.add.xml' ... done (6ms).
Loading state from 'state.xml' ... done (6ms).
Loading done.
Simulation version v1_21_0+0063-40d747df57b started with time: 60.00.
Simulation ended at time: 269.00.
Simulation version v1_20_0+0703-550959f676a started with time: 60.00.
Simulation ended at time: 269.00

Reason: All vehicles have left the simulation.
DijkstraRouter answered 2 queries and explored 2.00 edges on average.
DijkstraRouter spent 0.00s answering queries (0.00ms on average).
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>


<!-- generated on 2024-10-17 10:24:01 by Eclipse SUMO sumo Version v1_21_0+0063-40d747df57b
<sumoConfiguration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/sumoConfiguration.xsd">
<input>
<net-file value="net.net.xml"/>
<route-files value="input_routes.rou.xml"/>
Expand All @@ -29,6 +31,7 @@
-->

<snapshot xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/state_file.xsd" version="v1_21_0+0063-40d747df57b" time="60.00" type="micro" rail="1">

<route id="!t0!var#1" state="0" edges="a b c"/>
<route id="!t1!var#1" state="0" edges="d e c"/>
<delay number="2" begin="3" end="1" depart="9.00" time="36.00"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>


<!-- generated on 2024-10-17 10:24:01 by Eclipse SUMO sumo Version v1_21_0+0063-40d747df57b
<sumoConfiguration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/sumoConfiguration.xsd">
<input>
<net-file value="net.net.xml"/>
<route-files value="input_routes.rou.xml"/>
Expand All @@ -28,7 +30,9 @@
</sumoConfiguration>
-->


<snapshot xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/state_file.xsd" version="v1_21_0+0063-40d747df57b" time="10.00" type="micro" rail="1">

<route id="!between" state="0" edges="d e"/>
<route id="!t0!var#1" state="0" edges="a b c"/>
<route id="!t1" state="0" edges="d c c"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
Loading net-file from 'net.net.xml' ... done (0ms).
Loading additional-files from 'input_additional.add.xml' ... done (9ms).
Loading additional-files from 'input_additional2.add.xml' ... done (27ms).

Loading net-file from 'net.net.xml' ... done (1ms).
Loading additional-files from 'input_additional.add.xml' ... done (6ms).
Loading additional-files from 'input_additional2.add.xml' ... done (5ms).
Loading done.
Simulation version v1_21_0+0063-40d747df57b started with time: 0.00.
Simulation ended at time: 269.00.
Simulation version v1_20_0+0703-550959f676a started with time: 0.00.
Simulation ended at time: 269.00
Reason: All vehicles have left the simulation.
DijkstraRouter answered 8 queries and explored 1.88 edges on average.
DijkstraRouter answered 7 queries and explored 2.00 edges on average.
DijkstraRouter spent 0.00s answering queries (0.00ms on average).
Loading net-file from 'net.net.xml' ... done (0ms).
Loading additional-files from 'input_additional.add.xml' ... done (12ms).
Loading state from 'state.xml' ... done (11ms).
Loading additional-files from 'input_additional.add.xml' ... done (9ms).
Loading state from 'state.xml' ... done (6ms).
Loading done.
Simulation version v1_21_0+0063-40d747df57b started with time: 60.00.
Simulation ended at time: 269.00.
Simulation version v1_20_0+0703-550959f676a started with time: 60.00.
Simulation ended at time: 269.00

Reason: All vehicles have left the simulation.
DijkstraRouter answered 2 queries and explored 2.00 edges on average.
DijkstraRouter spent 0.00s answering queries (0.00ms on average).
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>


<!-- generated on 2024-10-17 10:24:01 by Eclipse SUMO sumo Version v1_21_0+0063-40d747df57b
<sumoConfiguration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/sumoConfiguration.xsd">
<input>
<net-file value="net.net.xml"/>
<route-files value="input_routes.rou.xml"/>
Expand All @@ -29,7 +31,9 @@
</sumoConfiguration>
-->


<snapshot xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/state_file.xsd" version="v1_21_0+0063-40d747df57b" time="60.00" type="micro" constraints="1" rail="1">

<route id="!t0!var#1" state="0" edges="a b c"/>
<route id="!t1!var#1" state="0" edges="d e c"/>
<delay number="2" begin="3" end="1" depart="9.00" time="36.00"/>
Expand Down
Loading
Loading