uxsim.DTAsolvers.SolverDSO_GA

class uxsim.DTAsolvers.SolverDSO_GA(func_World)[source]

Solve Dynamic System Optimum (DSO) problem using genetic algorithm. WIP

Parameters:

func_World (function) – function that returns a World object with nodes, links, and demand specifications

Notes

This is based on the standard genetic algorithm. For some scenarios, this method works well.

__init__(func_World)[source]

Solve Dynamic System Optimum (DSO) problem using genetic algorithm. WIP

Parameters:

func_World (function) – function that returns a World object with nodes, links, and demand specifications

Notes

This is based on the standard genetic algorithm. For some scenarios, this method works well.

Methods

__init__(func_World)

Solve Dynamic System Optimum (DSO) problem using genetic algorithm.

plot_convergence()

Plot the convergence of total travel time across iterations.

plot_link_stats()

Plot the traffic volume and average travel time for each link across iterations.

plot_vehicle_stats([orig, dest])

Plot vehicle travel time statistics based on route logs.

solve(max_iter[, n_routes_per_od, pop_size, ...])

Solve Dynamic System Optimum (DSO) problem using genetic algorithm. The objective function is

plot_convergence()[source]

Plot the convergence of total travel time across iterations. This method generates a plot showing how the total travel time changes throughout the solution iterations, which helps visualize the convergence of the traffic assignment algorithm.

Plot the traffic volume and average travel time for each link across iterations. This function creates two separate figures: one for traffic volume and one for average travel time. For each link, it plots the values across all iterations and adds a legend with link identifiers.

plot_vehicle_stats(orig=None, dest=None)[source]

Plot vehicle travel time statistics based on route logs. This function generates a plot that shows average travel times with standard deviations for vehicles, filtered by optional origin and destination locations.

Parameters:
  • orig (str, optional) – Origin location name to filter vehicles. If None, all origins are included.

  • dest (str, optional) – Destination location name to filter vehicles. If None, all destinations are included.

solve(max_iter, n_routes_per_od=10, pop_size=50, elite_size=2, mutation_occur_rate=0.1, mutation_gene_rate=0.05, n_crossover_points=2, print_progress=True, initial_solution_World=None)[source]
Solve Dynamic System Optimum (DSO) problem using genetic algorithm. The objective function is

total_travel_time + simulation_duration*number_of_vehicles_that_could_not_complete_their_trip.

The second term should be zero for reasonable results.

Parameters:
  • n_routes_per_od (int) – number of routes to enumerate for each OD pair. If initial_solution_World is given, this arg is ignored and the value in initial_solution_World is used.

  • pop_size (int) – population size

  • max_iter (int) – number of generations

  • mutation_occur_rate (float) – mutation rate for individual

  • mutation_gene_rate (float) – mutation rate for gene

  • n_crossover_points (int) – number of crossover points

  • print_progress_detailed (bool) – whether to print the detailed information

  • initial_solution_World (World) – initial solution (starting point) for the optimization algorithm. It must have the same structure as the output of func_World, and its simulation has been already executed. Recommended example: W_init = solve_DUE(func_World); W = solve_DSO(func_World, initial_solution_World=W_init) For unknown reason, this World is not always reproduced extactly. Sometimes small number of vehicles cannot find the routes chosen in DUE solution. TODO: fix

Returns:

W – World object with near DSO solution (if properly converged)

Return type:

World

Notes

self.W_sol is the final solution. self.W_intermid_solution is a latest solution in the iterative process. Can be used when an user terminate the solution algorithm.

GA part is initially written by ChatGPT o1-preview, and reviewed and overwritten by human.