Skip to content

Commit 9781c5c

Browse files
Update README.md
1 parent 00cd068 commit 9781c5c

File tree

1 file changed

+13
-22
lines changed

1 file changed

+13
-22
lines changed

README.md

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,11 @@ $ pip install aco_routing
2828

2929

3030
## 🎈 Usage <a name="usage"></a>
31-
> **_Check out:_** [aco_routing/example.py](https://github.com/hasnainroopawalla/Ant-Colony-Optimization/tree/master/aco_routing/example.py)
31+
> **_Check out:_** [example.py](https://github.com/hasnainroopawalla/Ant-Colony-Optimization/blob/00cd068597ab9a69a8eb81c8a3fd984797d2eefd/example.py)
3232
3333
Import all the dependencies.
3434
```python
35-
from aco_routing.utils.graph import Graph
36-
from aco_routing.dijkstra import Dijkstra
37-
from aco_routing.utils.simulator import Simulator
38-
from aco_routing.aco import ACO
35+
from aco_routing.utils.graph import Graph, Dijkstra, ACO
3936
```
4037

4138
Create a `Graph` object.
@@ -58,7 +55,7 @@ graph.add_edge("E", "D", travel_time=2)
5855
graph.add_edge("G", "E", travel_time=2)
5956
```
6057

61-
Define a `source` and `destination` as well create objects for the `Dijkstra` and `ACO` classes.
58+
Define a `source` and `destination` as well as create objects for the `Dijkstra` and `ACO` classes.
6259
```python
6360
source = "A"
6461
destination = "D"
@@ -76,49 +73,43 @@ print(f"ACO - path: {aco_path}, cost: {aco_cost}")
7673
print(f"Dijkstra - path: {dijkstra_path}, cost: {dijkstra_cost}")
7774
```
7875

79-
Simulate a real-life scenario with various episodes of stochastically updating traffic conditions in a city.
80-
```python
81-
Simulator(graph).simulate(source, destination, num_episodes=100, plot=True)
76+
Output:
77+
```
78+
ACO - path: ['A', 'H', 'G', 'E', 'D'], cost: 8.0
79+
Dijkstra - path: ['A', 'H', 'G', 'E', 'D'], cost: 8.0
8280
```
83-
8481

8582
## 📦 Contents <a name = "contents"></a>
8683

8784
### Graph
88-
`aco_routing.utils.graph.Graph`
85+
`aco_routing.Graph`
8986
- A Directed Graph class which consists of `Nodes` and `Edges`.
9087
- The `evaporation_rate` is initialized here.
9188

9289
### Node
93-
`aco_routing.utils.graph.Node`
90+
`aco_routing.Node`
9491
- A `Node` class which represents a node in the Graph and consists of various outgoing edges.
9592

9693
### Edge
97-
`aco_routing.utils.graph.Edge`
94+
`aco_routing.Edge`
9895
- An `Edge` class which represents a link between 2 nodes in the Graph.
9996
- Each `Edge` has 2 parameters:
10097
- `travel_time`: The amount of time it takes to traverse the edge. A high value indicates more traffic.
10198
- `pheromones`: A heuristic parameter i.e., the pheromone values deposited by the ants.
10299

103100
### Dijkstra
104-
`aco_routing.dijkstra.Dijkstra`
101+
`aco_routing.Dijkstra`
105102
- The baseline algorithm to compare the results of the candidate algorithm with.
106103
- The Dijkstra's algorithm ([source](https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm)) returns the shortest path between any 2 nodes in a graph.
107104

108105
### Ant
109-
`aco_routing.utils.ant.Ant`
106+
`aco_routing.Ant`
110107
- The `Ant` class representing an ant that traverses the graph.
111108

112109
### ACO
113-
`aco_routing.aco.ACO`
110+
`aco_routing.ACO`
114111
- The traditional Ant Colony Optimization algorithm that spawns various ants at random nodes and tries to find the shortest path between the specified source and destination.
115112

116-
### Simulator
117-
`aco_routing.utils.simulator.Simulator`
118-
- The simulator class is used to simulate and evaluate the performance of the candidate algorithm (ACO) with a baseline Dijkstra's Algorithm.
119-
- It simulates a real-life city, where the traffic conditions change every episode in a conditionally stochastic manner.
120-
- The ants continue to find the shortest path even after the traffic conditions change.
121-
122113
<hr>
123114

124115

0 commit comments

Comments
 (0)