Skip to main content

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

the simulation time is supposed to be continuous without using the option --load-state.offset.
If you do not set a --begin option, the simulation continues at the time of the saved state.
The offset option is only required when resetting the time (e.g. to start again with time zero after simulating a full day).
When using this option, negative times are expected as all time values are shifted backwards by the specified amount.


2018-06-28 20:09 GMT+02:00 Harald Schaefer <haraldschaefer@xxxxxxxxxxx>:
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
          # close lane
          networkName = networkRipped
        newTime = step + 1
        stateFileName = 'autobahn.savestate' + str(newTime)
        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:

5014:MSVehicle::saveState(OutputDevice& out) {

5018:    internals.push_back(toString(myDeparture));
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


sumo-dev mailing list
To change your delivery options, retrieve your password, or unsubscribe from this list, visit

Back to the top