Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[sumo-dev] Error with two or more switches of network with traci.load and .savestate

Dear all,

in my simulation I switch between two similar networks (with minor differences due to a closd lane) using a python code sequence like this

        if laneClosed.get() == 0:
          # open lane
          networkName = networkPriority
        else:
          # close lane
          networkName = networkRipped
        newTime = step + 1
        stateFileName = 'autobahn.savestate' + str(newTime)
        traci.simulation.saveState(stateFileName);
        sumoArgs[1] = networkName
        traci.load(sumoArgs + ['--load-state', stateFileName, '--load-state.offset', str(newTime), '--start'])

I'm using also the --load-state.offset argument to have a continious time.

If I have traffic in my network (with departed) vehicles, then the second switch creates a statefile with negativ departure times

In the first simulation step two vehicle are create at a time of 310 resp 312 sek.

simStep create dyn-truck80-0        0.0146 0.0147 310.0
simStep create dyn-truck80-1        0.0127 0.0147 312.0

At a time of 424 sek I do the first switch over, the savestate file shows

autobahn.savestate424:    <vehicle id="dyn-truck80-0" type="truck80" depart="310.00" route="A2EastWest" speedFactor="1.02" state="310000 2 7.20 0 422000" pos="1439.83" speed="21.87" posLat="0.00"> autobahn.savestate424-        <device id="tripinfo_dyn-truck80-0" state="-gneE0.0.0_0 0.00 22.22"/>
autobahn.savestate424:    </vehicle>
autobahn.savestate424:    <vehicle id="dyn-truck80-1" type="truck80" depart="312.00" route="A2EastWest" speedFactor="0.85" state="312000 2 7.20 0 422000" pos="1396.20" speed="21.61" posLat="0.00"> autobahn.savestate424-        <device id="tripinfo_dyn-truck80-1" state="-gneE0.0.0_0 0.00 22.22"/>
autobahn.savestate424:    </vehicle>

At the second switchover the savestate file looks like

autobahn.savestate462:    <vehicle id="dyn-truck80-0" type="truck80" depart="-114.00" route="A2EastWest" speedFactor="1.02" state="-114000 2 7.20 0 460000" pos="2273.75" speed="22.09" posLat="0.00"> autobahn.savestate462-        <device id="tripinfo_dyn-truck80-0" state="-gneE0.0.0_0 0.00 22.22"/>
autobahn.savestate462:    </vehicle>
autobahn.savestate462:    <vehicle id="dyn-truck80-1" type="truck80" depart="-112.00" route="A2EastWest" speedFactor="0.85" state="-112000 2 7.20 0 460000" pos="2228.39" speed="22.10" posLat="0.00"> autobahn.savestate462-        <device id="tripinfo_dyn-truck80-1" state="-gneE0.0.0_0 0.00 22.22"/>
autobahn.savestate462:    </vehicle>

-114 is 310 (original start time) - 424 (first switch over)

This is the code with regard to the departure time in MSVehicle.cpp:

5013-void
5014:MSVehicle::saveState(OutputDevice& out) {
...

5018:    internals.push_back(toString(myDeparture));
--
5038-void
5039:MSVehicle::loadState(const SUMOSAXAttributes& attrs, const SUMOTime offset) {
5040-    if (!attrs.hasAttribute(SUMO_ATTR_POSITION)) {
--
5044-    std::istringstream bis(attrs.getString(SUMO_ATTR_STATE));
5045:    bis >> myDeparture;
...

5050:    if (hasDeparted()) {
5051-        myCurrEdge += routeOffset;
5052:        myDeparture -= offset;
5053-    }

Best regards

Harald




Attachment: smime.p7s
Description: S/MIME Cryptographic Signature


Back to the top