Difference between revisions of "Tools/Trip"

From Sumo
Jump to navigation Jump to search
(validated output)
(documented intermediate option)
Line 43: Line 43:
 
To generate random pedestrian traffic instead of vehicular traffic, the option {{Option|--pedestrians}} may be used. It is recommended to combined this with the option {{Option|--max-distance}} to avoid walks of excessive length. See [[Simulation/Pedestrians]] for addition information on the simulation of pedestrians.
 
To generate random pedestrian traffic instead of vehicular traffic, the option {{Option|--pedestrians}} may be used. It is recommended to combined this with the option {{Option|--max-distance}} to avoid walks of excessive length. See [[Simulation/Pedestrians]] for addition information on the simulation of pedestrians.
  
==customized weights==
+
==Intermediate Way Points==
Using option {{Option|weights-output-prefix foo}} will cause three files (''foo.src.xml, foo.dst.xml, foo.via.xml'') to be generated  which contain the used edge probabilities. Any of these files can be loaded in [[SUMO-GUI]] for visualization, i.e. using the options {{Option|--weight-file ''foo.src.xml''}} {{Option|--weight-attribute ''value''}}. In [[SUMO-GUI]] lane-coloring ''by loaded weight'' must be selected to make the data visible.
+
To generate longer trips within a network, intermediate way points may be generated using the option {{Option|--intermediate {{DT_INT}}}}.
 +
This will add the given number of [[Definition_of_Vehicles,_Vehicle_Types,_and_Routes#Incomplete_Routes_.28trips_and_flows.29|via-edges]] to the trip definitions.
 +
 
 +
==Customized Weights==
 +
Using option {{Option|weights-output-prefix foo}} will cause three files (''foo.src.xml, foo.dst.xml, foo.via.xml'') to be generated  which contain the used edge probabilities.  
 +
* ''.src.xml'' contains the probabilities for an edge to be selected as {{XML|from}}-edge
 +
* ''.dst.xml'' contains the probabilities for an edge to be selected as {{XML|to}}-edge
 +
* ''.via.xml'' contains the probabilities for an edge to be selected as {{XML|via}}-edge (only used when option {{Option|--intermediate}} is set).
 +
 
 +
Any of these files can be loaded in [[SUMO-GUI]] for visualization, i.e. using the options {{Option|--weight-file ''foo.src.xml''}} {{Option|--weight-attribute ''value''}}. In [[SUMO-GUI]] lane-coloring ''by loaded weight'' must be selected to make the data visible.
  
 
Files in this format can be loaded to specify explicit edge probabilities for being a source/destination/via edge.
 
Files in this format can be loaded to specify explicit edge probabilities for being a source/destination/via edge.

Revision as of 10:32, 4 January 2016

randomTrips.py

"randomTrips.py" generates a set of random trips for a given network (option -n). It does so by choosing source and destination edge either uniformly at random or weighted by length (option -l), by number of lanes (option -L) or both. The resulting trips are stored in an xml file (option -o, default trips.trips.xml) suitable for the DUAROUTER which is called automatically if the -r option (with a filename for the resulting route file) is given. The trips are distributed evenly in an interval defined by begin (option -b, default 0) and end time (option -e, default 3600) in seconds. The number of trips is defined by the repetition rate (option -p, default 1) in seconds. Every trip has an id consisting of a prefix (option --prefix, default "") and a running number. Example call:

<SUMO_HOME>/tools/randomTrips.py -n input_net.net.xml -e 50 -l

The script does not check whether the chosen destination may be reached from the source. This task is performed by the router. If the network is not fully connected some of the trips may be discarded.

The option --min-distance <FLOAT> ensures a minimum straight-line distance (in meter) between start and end edges of a trip. The script will keep sampling from the edge distribution until enough trips with sufficient distance are found.

The option --fringe-factor <FLOAT> increases the probability that trips will start/end at the fringe of the network. If the value 10 is given, edges that have no successor or no predecessor will be 10 times more likely to be chosen as start- or endpoint of a trip. This is useful when modelling through-traffic which starts and ends at the outside of the simulated area.

For additional ways to influence edge probabilities call

<SUMO_HOME>/tools/randomTrips.py --help

Arrival rate

The arrival rate is controlled by option --period <FLOAT> (default 1). By default this generates vehicles with a constant period and arrival rate of (1/period) per second. By using values below 1, multiple arrivals per second can be achieved.

When adding option --binomial <INT> the arrivals will be randomized using a binomial distribution where n (the maximum number of simultaneous arrivals) is given by the argument to --binomial and the expected arrival rate is 1/period (this option is not yet available in version 0.23.0).

Validated routes and trips

When using the option --route-file, an output file with valid vehicle routes will be generated. This works by automatically calling DUAROUTER in the background to turn the random trips into routes and automatically discard disconnected trips. It may be necessary to increase the number of generated random trips to account for a fraction disconnected, discarded trips.

Caution:
When using a network with vehicle class restrictions, it is necessary to use the randomTrips.py-options --vClass and --vehicle-class with the correct value to ensure valid routes. In most cases, the correct value for regular vehicles is is passenger

Sometimes it is desirable to obtain validated trips rather than routes (i.e. to make use of one-shot route assignment. In this case the additional option --validate may be used to generate validated trips (by first generating valid routes and then converting them back into trips).

Generating vehicles with additional parameters

With the option --trip-attributes <STRING>, additional parameters can be given to the generated vehicles (note, usage of the quoting characters).

 <SUMO_HOME>/tools/randomTrips.py -n input_net.net.xml --trip-attributes="departLane=\"best\" departSpeed=\"max\" departPos=\"random\""

This would make the random vehicles be distributed randomly on their starting edges and inserted with high speed on a reasonable lane.

If the generated vehicles should have a specific vehicle type, an additional-file needs to be prepared:

<additional>
  <vType id="myType" maxSpeed="27" vClass="passenger"/>
</additional>

Then load this file (assume it was saved as type.add.xml) with the option --additional-file

<SUMO_HOME>/tools/randomTrips.py -n input_net.net.xml --trip-attributes="type=\"myType\"" --additional-file type.add.xml 
   --vclass passenger

Note the use of the option --vclass which ensures that random start- and arrival-edges allow a specific vehicle class.

To generate random pedestrian traffic instead of vehicular traffic, the option --pedestrians may be used. It is recommended to combined this with the option --max-distance to avoid walks of excessive length. See Simulation/Pedestrians for addition information on the simulation of pedestrians.

Intermediate Way Points

To generate longer trips within a network, intermediate way points may be generated using the option --intermediate <INT>. This will add the given number of via-edges to the trip definitions.

Customized Weights

Using option weights-output-prefix foo will cause three files (foo.src.xml, foo.dst.xml, foo.via.xml) to be generated which contain the used edge probabilities.

  • .src.xml contains the probabilities for an edge to be selected as from-edge
  • .dst.xml contains the probabilities for an edge to be selected as to-edge
  • .via.xml contains the probabilities for an edge to be selected as via-edge (only used when option --intermediate is set).

Any of these files can be loaded in SUMO-GUI for visualization, i.e. using the options --weight-file foo.src.xml --weight-attribute value. In SUMO-GUI lane-coloring by loaded weight must be selected to make the data visible.

Files in this format can be loaded to specify explicit edge probabilities for being a source/destination/via edge. To obtain trips from a specific location to random destinations you may provide a modified .src.xml file which only contains a value for the desired start location. Then load that file using the option --weights-prefix foo.src.xml

When loading weights, missing edges will default to probability 0 and missing files (i.e. missing foo.dst.xml) will default to normal randomization.

route2trips.py

This script generates a trip file from a route file by stripping all route information except for start and end edge. It has a single parameter which is the route file and prints the trip file to stdout. Example:

<SUMO_HOME>/tools/route2trips.py input_routes.rou.xml