This is a simulation project used for modelling the Braess's paradox meant for traffic modelling. It gives an idea on how resources can be added or removed from an existing network in order to increase the overall efficiency of it.
The basis of the paradox relies on the Nash equilibrium that is established in a network when there is a flow of persons who would operate on a selfish or greedy behaviour. This looks at how allocation of resources can modify or impact the overall states of the network and all the users. This project is a simulation outline of the scenarios possible or encountered when the network is operational and can be modified and extended to cover a greater range of situations where networks may be involved and resources need to be allocated.
The STREAM github repository contains the necessary files and requirements for the tool.
The detailed findings and report of this simulation and analysis is attached below :
pip install networkx
build_graph.py
: Script to build the graph from a JSON file containing edge data.update_weights.py
: Script to update the weights of the edges based on traffic flow data.shortest_path.py
: Script to find the shortest path for a new person entering the network.analyze_braess.py
: Script to analyze Braess's paradox by removing and adding edges.main.py
: Script to loop through each pair of nodes, perturb each possibility, and analyze Braess's paradox.graph_data.json
: JSON file containing the graph structure.graph_flow.json
: JSON file containing the flow state of each edge in the graph.braess_analysis_results.json
: Output JSON file containing the results of the Braess's paradox analysis.build_graph.py
Constructs the graph from graph_data.json
.
python build_graph.py
------------------------------------------------
update_weights.py
Updates the weights of the edges based on traffic flow data from graph_flow.json
.
python update_weights.py
------------------------------------------------
shortest_path.py
Finds the shortest path for a given source and destination node in the graph.
python shortest_path.py
When run, it will prompt for the source and destination nodes.
------------------------------------------------
analyse_braess.py
Analyses Braess's paradox by removing and adding edges and checking the effect on the shortest path.
python analyse_braess.py
When run, it will prompt for the source and destination nodes.
------------------------------------------------
main.py
Loops through each pair of nodes, perturbs each possibility by removing and adding edges, and analyzes Braess's paradox.
python main.py
Runs the entire analysis of the network by running the above simulations.
graph_data.json
Contains the graph structure with the following format:
{
"edges": [
{"start": "A", "end": "B", "base_weight": 1, "linear_factor": 1},
{"start": "B", "end": "D", "base_weight": 1, "linear_factor": 1},
{"start": "A", "end": "C", "base_weight": 1, "linear_factor": 1},
{"start": "C", "end": "D", "base_weight": 1, "linear_factor": 1},
{"start": "B", "end": "C", "base_weight": 1, "linear_factor": 1}
]
}
------------------------------------------------
graph_flow.json
Contains the flow state of each edge in the graph with the following format:
{
"flows": {
"('A', 'B')": 10,
"('B', 'D')": 10,
"('A', 'C')": 10,
"('C', 'D')": 10,
"('B', 'C')": 0
}
}
For the defaults, the json files have been included with basic random states for the purpose of providing examples.
------------------------------------------------
braess_analysis_results.json
Contains the results of the Braess's paradox analysis. Generated by running main.py
.
graph_data.json
and graph_flow.json
files are properly set up.main.py
to perform a comprehensive analysis of Braess's paradox on your graph:python main.py
braess_analysis_results.json
.This project is licensed under the MIT License.
This project/tool was created by @SidZRed as a part of a Game Theory reading and analysis project. Any contributions to the above are most welcome!