A1) see https://github.com/eclipse/sumo/issues/5829 (workaround is to
remove the edge that starts with ':' from the findRoute result).

The result of edge.getTraveltime is quite reliable for long edges but may
fluctuate strongly on short edges (especially in urban traffic when subject
to traffic lights). For this reason, sumo can also compute averaged travel
times: https://sumo.dlr.de/wiki/Demand/Automatic_Routing#Edge_weights.
TraCI also allows manipulating these averaged travel times though the API
is a bit more arcane (look for 'device.rerouting'):
https://sumo.dlr.de/wiki/TraCI/Vehicle_Value_Retrieval#Supported_Device_Parameters
https://sumo.dlr.de/wiki/TraCI/Change_Vehicle_State#Supported_Device_Parameters



Am Fr., 12. Juli 2019 um 12:03 Uhr schrieb Hoffmann, Pascal <
[email protected]>:

> Thanks. A2 and A3 helped a lot. I'm wondering, if, when I just need the
> current travel times and not the starting edge travel times, whether I just
> can reset the travel times with setting them back to
> trace.edge.getTraveltime in the beginning of the function?
>
>
> Unfortunately the vClass was correct and traci.vehicle.getTypeID(vehID)
> didnt solve the problem. The print out of the new routes looks correct
> ('edgeID', 'edgeID,...). But I was wondering, whether the .setRoute is
> working, when there is a junction (e.g. ':gneJ32_10') in the list of the
> new route? Because I'm using traci.vehicle.getRoadID(vehID)to get the
> current position of the vehicle.
>
> ------------------------------
> *Von:* [email protected] <[email protected]> im
> Auftrag von Jakob Erdmann <[email protected]>
> *Gesendet:* Freitag, 12. Juli 2019 09:11:26
> *An:* Sumo project User discussions
> *Betreff:* Re: [sumo-user] Using own created assignment
>
> A1) possibly your vehicle has a different vClass from the defaut
> vClass="passenger" assumed by simulation.findRoute. You can avoid this by
> calling findRoute(from, to, traci.vehicle.getTypeID(vehID)).
> If that doesn't solve it, print the found route and then insert a vehicle
> on this route via XML inputs for a more comprehensive error message.
>
> A2) the function simulation.findRoute uses the global edge travel times
> whereas you only penalized the vehicle-specific traveltimes
> (traci.vehicle.setAdaptedTraveltime). Use traci.edge.adaptTraveltime
> instead.
> The values of vehicle.setAdaptedTraveltime are only used when calling
> traci.vehicle.rerouteTraveltime.
>
> A3) Either by calling edge.adaptTravelTime(traci.edge.getTravelTime) for
> all edges or by using findRoute(...,
> routingMode=traci.constants.ROUTING_MODE_AGGREGATED) - see
> https://sumo.dlr.de/wiki/Simulation/Routing#Travel-time_values_for_routing
>
> A4) you cannot reset edge traveltimes at the moment ( see
> https://github.com/eclipse/sumo/issues/5827 ) but you can limit the scope
> of the change by setting the begin,end arguments (or just setting it
> explicitly to length/speedLimit).
>
> regards,
> Jakob
>
> Am Do., 11. Juli 2019 um 16:58 Uhr schrieb Hoffmann, Pascal <
> [email protected]>:
>
>> First of all .. Thank you very much for the help!
>>
>>
>> I tried to apply the penalties with a basic code consisting out of
>> .setAdaptedTraveltime and search for new routes with .findRoute . But
>> unfortunately when I want to .setRoute the new route of .findRoute, I get
>> an error. Furthermore the actually supposed to be different routes
>> (route_1,route_2 and route_3) are all the same. So my questions for the
>> code below:
>>
>>
>> Q1: Why is the setRoute function not working for the .findRoute -->
>> new_route ?
>>
>> Q2: Why is findRoute not finding different routes due to the penalyzed
>> weights of the edges with setAdaptedTraveltime?
>>
>> Q3: Is the findRoute using the currentTravelTimes like reroute and if
>> not, how is it possible?
>>
>> Q4: How can I set the adapedTraveltime back to the current after finding
>> a new route?
>>
>>
>> def run():
>>     step = 0
>>     while traci.simulation.getMinExpectedNumber() >0:
>>         traci.simulationStep()
>>         print(step)
>>         step+=1
>>         det_vehs = traci.inductionloop.getLastStepVehicleIDs("det_0")   
>> #creates an induction loop
>>         IDlist = traci.vehicle.getIDList()                              
>> #creates a list of all current vehicle in the simulation
>>         assign = 1
>>         if step > 40:
>>             for veh in det_vehs:
>>                 traci.vehicle.setSpeed(veh, 0.0)                        
>> #sets the speed of the vehicle,
>>                                                                         # 
>> which drives on the induction loop, to zero
>>                 for veh_1 in IDlist:
>>                     traci.vehicle.setRoutingMode(veh_1, 1)              
>> #sets the RoutingMode to aggregated
>>                     #traci.vehicle.rerouteTraveltime(veh_1)             
>> #reroutes the vehicles
>>
>>                     current_start = traci.vehicle.getRoadID(veh_1)
>>                     trip = traci.vehicle.getRoute(veh_1)
>>                     end = trip[-1]
>>
>>                     if assign == 1:                                          
>>            #assignment on/off
>>                         route_inf_1 = 
>> traci.simulation.findRoute(current_start, end)    #findRoute with all 
>> information
>>                         route_1 = route_inf_1[4]                             
>>            #just list of edges of findRoute
>>
>>                         for edges1 in route_1:                               
>>            #penalyzing
>>                              traci.vehicle.setAdaptedTraveltime(veh_1, 
>> edges1, 90.0)
>>                         route__inf_2 = 
>> traci.simulation.findRoute(current_start, end)   #new route find with 
>> penalyzed
>>                         route_2 = route__inf_2[4]                            
>>            #just list of edges of findRoute
>>                         for edges2 in route_2:
>>                              traci.vehicle.setAdaptedTraveltime(veh_1, 
>> edges2, 90.0 )   #penalyzing
>>                         route_inf_3 = 
>> traci.simulation.findRoute(current_start, end)    #new route find with 
>> penalyzed
>>                         route_3 = route_inf_3[4]                             
>>            #just list of edges of findRoute
>>
>>                         new_route = random.choice([route_1, route_2, 
>> route_3])
>>                         if len(new_route) > 1:                               
>>            #check vehicle is at final
>>                             traci.vehicle.setRoute(veh_1, new_route)
>>     traci.close()
>>     sys.stdout.flush()
>>
>>
>> --> Error:
>> Traceback (most recent call last):
>>   File 
>> "G:/TE-F1/Studenten/Hoffmann_Pascal/04_Simulation/ma_routing_via_traci/input.py",
>>  line 78, in <module>
>>     run()
>>   File 
>> "G:/TE-F1/Studenten/Hoffmann_Pascal/04_Simulation/ma_routing_via_traci/input.py",
>>  line 61, in run
>>     traci.vehicle.setRoute(veh_1, new_route)
>>   File "C:\Program Files (x86)\Eclipse\Sumo\tools\traci\_vehicle.py", line 
>> 1124, in setRoute
>>     self._connection._sendExact()
>>   File "C:\Program Files (x86)\Eclipse\Sumo\tools\traci\connection.py", line 
>> 112, in _sendExact
>>     raise TraCIException(err, prefix[1], _RESULTS[prefix[2]])
>> traci.exceptions.TraCIException: Route replacement failed for carflow_1.1
>>
>>
>> ------------------------------
>> *Von:* [email protected] <[email protected]> im
>> Auftrag von Jakob Erdmann <[email protected]>
>> *Gesendet:* Montag, 8. Juli 2019 16:46:16
>> *An:* Sumo project User discussions
>> *Betreff:* Re: [sumo-user] Using own created assignment
>>
>> 1) start sumo with option --routing-algorithm astar
>> 2) You can apply the penalties yourself by increasing the
>> weight/traveltime for all edges in the previously found routes.
>> 3) Yes. See
>> https://sumo.dlr.de/wiki/Simulation/Routing#Travel-time_values_for_routing
>>
>> regards,
>> Jakob
>>
>> Am Mo., 8. Juli 2019 um 16:28 Uhr schrieb Hoffmann, Pascal <
>> [email protected]>:
>>
>>> Dear sumo-users,
>>>
>>>
>>> I am using SUMO via TraCI. My target is to assign vehicles in case of
>>> congestion randomly on a set of alternative path to reduce waiting times.
>>> So far I'm rerouting with the TraCI rerouters, but now I want to implement
>>> my own assignment. Therefore I want to ask some questions:
>>>
>>>
>>> Q1: Is it possible to use the "build in" astar routing algorithm
>>> (AStarRouter.h?) via TraCI and if, how?
>>>
>>>
>>> Q2: I know that SUMO uses the penalty method in the MARouter to find
>>> alternative routes. But so far, I couldn't find, where and how it was
>>> realized to adapt this method for the astar multi-path.
>>>
>>>
>>> Q3: Is it possible to adapt the traci.vehicle.rerouteTraveltime
>>> especially with the aggregated travel times in a new external python script
>>> to use the "new" made routing algorithm concerned in Q1&Q2?
>>>
>>>
>>> Thanks in advance!
>>>
>>>
>>> Best regards,
>>>
>>> Pascal
>>> _______________________________________________
>>> sumo-user mailing list
>>> [email protected]
>>> To change your delivery options, retrieve your password, or unsubscribe
>>> from this list, visit
>>> https://www.eclipse.org/mailman/listinfo/sumo-user
>>>
>> _______________________________________________
>> sumo-user mailing list
>> [email protected]
>> To change your delivery options, retrieve your password, or unsubscribe
>> from this list, visit
>> https://www.eclipse.org/mailman/listinfo/sumo-user
>>
> _______________________________________________
> sumo-user mailing list
> [email protected]
> To change your delivery options, retrieve your password, or unsubscribe
> from this list, visit
> https://www.eclipse.org/mailman/listinfo/sumo-user
>
_______________________________________________
sumo-user mailing list
[email protected]
To change your delivery options, retrieve your password, or unsubscribe from 
this list, visit
https://www.eclipse.org/mailman/listinfo/sumo-user

Reply via email to