项目作者: maslab-ufrgs

项目描述 :
Route choice simulator.
高级语言: Python
项目地址: git://github.com/maslab-ufrgs/TAP_GA_QL.git
创建时间: 2015-10-28T13:05:38Z
项目社区:https://github.com/maslab-ufrgs/TAP_GA_QL

开源协议:

下载


IMPORTANT

Need to initialize the KSP submodule, to do so use the following command:

  1. git submodule init && git submodule update

Can get other networks from

Dependencies

Usage

  1. python route_choice.py [OPTIONS]

Or:

  1. ./route_choice.py [OPTIONS]

All the options have usable defaults so check them before running a experiment.

Use:

  1. python route_choice.py -h

To list all the options.

Checking the results

After the execution is complete, a new file in the “results_gaql_grouped” folder
should be created.

The name of the file will contain the parameters used to run the experiment
and the local time when it happened.

Examples

  • Run an experiment with the SF network and prints the travel time
    for the each pair of Origin and Destination

  • First get the SF network file from the link above.

  1. python route_choice.py -f /path/to/SF.net --printPairOD
  • Run an experiment with the OW network printing the link’s travel time at every
    100 generations with the mutations of 0.003 and 0.03

  • First get the OW network file from the link above.

    1. python route_choice.py -f /path/to/OW.net --printTravelTime --printInterval 100 --mutations 0.003 0.03
  • Run an experiment with the SF network using alphas 0.3 and 0.4,
    decays 0.9 and 0.99 and 1000 generations.

  1. python route_choice.py -f /path/to/SF.net --alphas 0.3 0.4 --decays 0.9 0.99 --generations 1000
  • Run an QL experiment with the OW network initiating the QL-table with random values.
  1. python route_choice.py -f /path/to/OW.net --experimentType 1 --ql-table-initiation random

Options

  1. arguments:
  2. -h, --help show this help message and exit
  3. -f FILE The network file. (default: None)
  4. -as {epsilon,boltzmann}, --action-selection {epsilon,boltzmann}
  5. How the agents should select their actions. (default:
  6. epsilon)
  7. -et {1,2,3,4,5,6,7,8,9,10}, --experimentType {1,2,3,4,5,6,7,8,9,10}
  8. 1 - QL only; 2 - GA only; 3 - QL builds solution for
  9. GA; 4 - GA and QL exchange solutions. 5 - UCB1 only 6
  10. - Thompson only 7 - UCB1 Discounted only 8 - UCB1
  11. Sliding Window only 9 - Rexp3 10- Rexp3MA (default: 1)
  12. -r REPETITIONS, --repetitions REPETITIONS
  13. How many times it should be repeated. (default: 1)
  14. -k KS [KS ...], --ks KS [KS ...]
  15. List of the 'K' hyperparameters for the KSP
  16. (K-ShortestPath) Algorithm. (default: [8])
  17. -g GENERATIONS, --generations GENERATIONS
  18. Generations\episodes in each configuration. (default:
  19. 100)
  20. -n FLOW, --flow FLOW Base flow in the network. (default: 0)
  21. -group GROUPING [GROUPING ...], --grouping GROUPING [GROUPING ...]
  22. List of group sizes for drivers in each configuration.
  23. This parameter is useful when the number of
  24. trips/drivers is huge; it sets how many drivers form a
  25. group; in a group all drivers/trips use the same OD
  26. pair, i.e., the granularity of the route choice can be
  27. individual based or group based. (default: [1])
  28. --printTravelTime Print link's travel time at each iteration in the
  29. output file. (default: False)
  30. --printDriversPerRoute
  31. Print the amount of drivers per route for each OD
  32. pair(Warning:QL only! Also, note that the number of OD
  33. pairs can be very large!). (default: False)
  34. --printDriversPerLink
  35. Print the number of drivers in each link in the output
  36. file. (default: False)
  37. --printEdges Print the travel time per edge. (default: False)
  38. --printODpair Print the average travel time in the header in the
  39. output file. (default: False)
  40. --printInterval PRINTINTERVAL
  41. Interval by which the messages are written in the
  42. output file. (default: 1)
  43. -e ELITE_SIZE, --elite_size ELITE_SIZE
  44. How many elite individuals should be kept after each
  45. generation. (default: 5)
  46. -p POPULATION, --population POPULATION
  47. Size of population for the genetic algorithm.
  48. (default: 100)
  49. -c CROSSOVERS [CROSSOVERS ...], --crossovers CROSSOVERS [CROSSOVERS ...]
  50. List of rate of crossover in the population in each
  51. configuration. (default: [0.2])
  52. -m MUTATIONS [MUTATIONS ...], --mutations MUTATIONS [MUTATIONS ...]
  53. List of rate of mutations in each configuration.
  54. (default: [0.001])
  55. -i EXCHANGEGAQL [EXCHANGEGAQL ...], --exchangeGAQL EXCHANGEGAQL [EXCHANGEGAQL ...]
  56. Interval of generations in which the GA sends its best
  57. solution to the QL. (default: [10])
  58. -tff TABLE_FILL_FILE Table fill file. (default: None)
  59. -qti {coupling,random,fixed}, --ql-table-initiation {coupling,random,fixed}
  60. How to initiate the Q-Table. (default: fixed)
  61. --max MAX Maximum value for the random initiation. Note that the
  62. random value(x) will be x <= max ! (default: 0.0)
  63. --min MIN Maximum value for the random initiation. Note that the
  64. random value(x) will be min <= x ! (default: 0.0)
  65. --fixed FIXED Fixed value for generating the Q table. (default: 0.0)
  66. -epl EPSILON [EPSILON ...], --epsilon EPSILON [EPSILON ...]
  67. List of epsilons(exploration rate) for Q-Learning,
  68. Rexp3 and Rexp3MA. (default: [1.0])
  69. -a ALPHAS [ALPHAS ...], --alphas ALPHAS [ALPHAS ...]
  70. List of learning rates in each configuration.
  71. (default: [0.5])
  72. -d DECAYS [DECAYS ...], --decays DECAYS [DECAYS ...]
  73. List of decays in each configuration; this sets the
  74. value by which epsilon is multiplied at each QL
  75. episode. Also used as the discount factor on
  76. Discounted UCB and Sliding window UCB, and the decay
  77. rate for the probability of forgetinf of the Rexp3MA
  78. algorithm (default: [0.99])
  79. -t TEMPERATURE, --temperature TEMPERATURE
  80. Temperature for the Boltzmann action selection.
  81. (default: None)
  82. -ws WINDOWSIZE [WINDOWSIZE ...], --windowsize WINDOWSIZE [WINDOWSIZE ...]
  83. Window size for Sliding Window UCB1 (default: [20])
  84. -io {1,2} [{1,2} ...], --initorder {1,2} [{1,2} ...]
  85. How UCB-based algorithms should be initiaded: 1-random
  86. order, 2-sequential order (default: [1])
  87. -pf PROBABILITYFORGET [PROBABILITYFORGET ...], --probabilityforget PROBABILITYFORGET [PROBABILITYFORGET ...]
  88. List of probabilities of forgetting for the Rexp3MA
  89. algorithms. (default: [1.0])