Skip to content

Commit

Permalink
Fix errors
Browse files Browse the repository at this point in the history
  • Loading branch information
toruseo committed May 10, 2024
1 parent d518a09 commit c489c77
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
8 changes: 5 additions & 3 deletions demos_and_examples/demo_notebook_07en_optimal_routing.ipynb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 11 additions & 5 deletions demos_and_examples/example_22en_routing_optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@

##############################################################
# Compute DUO as a reference
print("####"*20)
print("Deriving DUO")
W.exec_simulation()
display(W.analyzer.basic_to_pandas())
print(W.analyzer.basic_to_pandas())

W_duo= W.copy()

Expand All @@ -46,6 +47,7 @@
for od_pair in od_pairs:
routes[od_pair] = Utilities.enumerate_k_shortest_routes(W, od_pair[0], od_pair[1], n_routes)

print("available routes for each OD pair")
for key in routes:
for route in routes[key]:
print(key, route)
Expand Down Expand Up @@ -85,10 +87,11 @@ def specify_routes(W, genome):

##############################################################
# Execute genetic algorithm
print("####"*20)
print("Deriving DSO using genetic algorithm")
NPOP = 30
NPOP = 20
CXPB, MUTPB = 0.5, 0.2
NGEN = 30
NGEN = 20

# Initial population
pop = toolbox.population(n=NPOP)
Expand Down Expand Up @@ -132,7 +135,7 @@ def specify_routes(W, genome):
print("")
print("Best individual: ", best_ind)
print("Fitness: ", best_ind.fitness.values[0])
display(best_ind.W.analyzer.basic_to_pandas())
print(best_ind.W.analyzer.basic_to_pandas())

# Update the population
pop[:] = offspring
Expand All @@ -142,11 +145,14 @@ def specify_routes(W, genome):
##############################################################
# Compare DUO and near-DSO

print("####"*20)
print("DUO")
print(W_duo.analyzer.basic_to_pandas())
W_duo.analyzer.macroscopic_fundamental_diagram()
W_duo.analyzer.network_anim(file_name="out/grid_duo.gif", detailed=1, network_font_size=0, figsize=(6,6))

print("near-DUO")
print("near-DSO")
print(W_dso.analyzer.basic_to_pandas())
W_dso.analyzer.macroscopic_fundamental_diagram()
W_dso.analyzer.network_anim(file_name="out/grid_dso.gif", detailed=1, network_font_size=0, figsize=(6,6))

Expand Down

0 comments on commit c489c77

Please sign in to comment.