aco-routing


Nameaco-routing JSON
Version 1.1.0 PyPI version JSON
download
home_pagehttps://github.com/hasnainroopawalla/ant-colony-optimization
SummaryA Python package to find the shortest path in a graph using Ant Colony Optimization (ACO)
upload_time2023-12-17 21:31:39
maintainer
docs_urlNone
authorHasnain Roopawalla
requires_python>=3.6
licenseMIT
keywords python machinelearning ai aco
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <h1 align="center">Ant Colony Optimization</h1>


[![Develop](https://github.com/hasnainroopawalla/Ant-Colony-Optimization/actions/workflows/develop.yml/badge.svg)](https://github.com/hasnainroopawalla/Ant-Colony-Optimization/actions/workflows/develop.yml)
[![Deploy](https://github.com/hasnainroopawalla/Ant-Colony-Optimization/actions/workflows/deploy.yml/badge.svg)](https://github.com/hasnainroopawalla/Ant-Colony-Optimization/actions/workflows/deploy.yml)
[![PyPi version](https://img.shields.io/pypi/v/aco_routing.svg)](https://pypi.python.org/pypi/aco_routing/)
![Downloads](https://img.shields.io/pypi/dm/aco_routing.svg)
<!-- [![Python versions](https://img.shields.io/pypi/pyversions/aco_routing.svg?style=plastic)](https://img.shields.io/pypi/pyversions/aco_routing.svg?style=plastic) -->


A Python package to find the shortest path in a graph using Ant Colony Optimization (ACO).


The Ant colony Optimization algorithm is a probabilistic technique for solving computational problems which can be reduced to finding good paths through graphs ([source](https://en.wikipedia.org/wiki/Ant_colony_optimization_algorithms)).

This implementation of the ACO algorithm uses the [NetworkX](https://networkx.org/) graph environment.

## 🏁 Getting Started <a name = "getting_started"></a>

### To install the package directly from PyPi:
```
$ pip install aco_routing
```

## 🎈 Usage <a name="usage"></a>
> **_Check out:_** [example.py](https://github.com/hasnainroopawalla/Ant-Colony-Optimization/blob/00cd068597ab9a69a8eb81c8a3fd984797d2eefd/example.py)

Import all the dependencies:
```python
from aco_routing import ACO
import networkx as nx
```

Create a `NetworkX.Graph` object with nodes and edges:
```python
G = nx.DiGraph()

G.add_edge("A", "B", cost=2)
G.add_edge("B", "C", cost=2)
G.add_edge("A", "H", cost=2)
G.add_edge("H", "G", cost=2)
G.add_edge("C", "F", cost=1)
G.add_edge("F", "G", cost=1)
G.add_edge("G", "F", cost=1)
G.add_edge("F", "C", cost=1)
G.add_edge("C", "D", cost=10)
G.add_edge("E", "D", cost=2)
G.add_edge("G", "E", cost=2)
```

Use ACO to find the shortest path and cost between the `source` and `destination`:
```python
aco = ACO(G, ant_max_steps=100, num_iterations=100, ant_random_spawn=True)

aco_path, aco_cost = aco.find_shortest_path(
    source="A",
    destination="D",
    num_ants=100,
)
```

Output:
```
ACO path: A -> H -> G -> E -> D
ACO path cost: 8.0
```

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

### Ant
`aco_routing.Ant`
- An `Ant` that traverses the graph.

### ACO
`aco_routing.ACO`
- The traditional Ant Colony Optimization algorithm that spawns ants at various nodes in the graph and finds the shortest path between the specified source and destination ([pseudo code](https://en.wikipedia.org/wiki/Ant_colony_optimization_algorithms#Algorithm_and_formula)).


## Contributing

- Post any issues and suggestions on the GitHub [issues](https://github.com/hasnainroopawalla/Ant-Colony-Optimization/issues) page.
- To contribute, fork the project and then create a pull request back to master.


## License
This project is licensed under the MIT License - see the [LICENSE](https://github.com/hasnainroopawalla/Ant-Colony-Optimization/blob/73b65a6fd14e3e5517b479cfecac1140f0ae7899/LICENSE) file for details.



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/hasnainroopawalla/ant-colony-optimization",
    "name": "aco-routing",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "python,machinelearning,ai,aco",
    "author": "Hasnain Roopawalla",
    "author_email": "hasnain.roopawalla@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/e7/b6/ecb1e8e293ab41ef5def1f8bb6efd02fc7b27d8b06b8fc3c32563ddf6463/aco_routing-1.1.0.tar.gz",
    "platform": null,
    "description": "<h1 align=\"center\">Ant Colony Optimization</h1>\n\n\n[![Develop](https://github.com/hasnainroopawalla/Ant-Colony-Optimization/actions/workflows/develop.yml/badge.svg)](https://github.com/hasnainroopawalla/Ant-Colony-Optimization/actions/workflows/develop.yml)\n[![Deploy](https://github.com/hasnainroopawalla/Ant-Colony-Optimization/actions/workflows/deploy.yml/badge.svg)](https://github.com/hasnainroopawalla/Ant-Colony-Optimization/actions/workflows/deploy.yml)\n[![PyPi version](https://img.shields.io/pypi/v/aco_routing.svg)](https://pypi.python.org/pypi/aco_routing/)\n![Downloads](https://img.shields.io/pypi/dm/aco_routing.svg)\n<!-- [![Python versions](https://img.shields.io/pypi/pyversions/aco_routing.svg?style=plastic)](https://img.shields.io/pypi/pyversions/aco_routing.svg?style=plastic) -->\n\n\nA Python package to find the shortest path in a graph using Ant Colony Optimization (ACO).\n\n\nThe Ant colony Optimization algorithm is a probabilistic technique for solving computational problems which can be reduced to finding good paths through graphs ([source](https://en.wikipedia.org/wiki/Ant_colony_optimization_algorithms)).\n\nThis implementation of the ACO algorithm uses the [NetworkX](https://networkx.org/) graph environment.\n\n## \ud83c\udfc1 Getting Started <a name = \"getting_started\"></a>\n\n### To install the package directly from PyPi:\n```\n$ pip install aco_routing\n```\n\n## \ud83c\udf88 Usage <a name=\"usage\"></a>\n> **_Check out:_** [example.py](https://github.com/hasnainroopawalla/Ant-Colony-Optimization/blob/00cd068597ab9a69a8eb81c8a3fd984797d2eefd/example.py)\n\nImport all the dependencies:\n```python\nfrom aco_routing import ACO\nimport networkx as nx\n```\n\nCreate a `NetworkX.Graph` object with nodes and edges:\n```python\nG = nx.DiGraph()\n\nG.add_edge(\"A\", \"B\", cost=2)\nG.add_edge(\"B\", \"C\", cost=2)\nG.add_edge(\"A\", \"H\", cost=2)\nG.add_edge(\"H\", \"G\", cost=2)\nG.add_edge(\"C\", \"F\", cost=1)\nG.add_edge(\"F\", \"G\", cost=1)\nG.add_edge(\"G\", \"F\", cost=1)\nG.add_edge(\"F\", \"C\", cost=1)\nG.add_edge(\"C\", \"D\", cost=10)\nG.add_edge(\"E\", \"D\", cost=2)\nG.add_edge(\"G\", \"E\", cost=2)\n```\n\nUse ACO to find the shortest path and cost between the `source` and `destination`:\n```python\naco = ACO(G, ant_max_steps=100, num_iterations=100, ant_random_spawn=True)\n\naco_path, aco_cost = aco.find_shortest_path(\n    source=\"A\",\n    destination=\"D\",\n    num_ants=100,\n)\n```\n\nOutput:\n```\nACO path: A -> H -> G -> E -> D\nACO path cost: 8.0\n```\n\n## \ud83d\udce6 Contents <a name = \"contents\"></a>\n\n### Ant\n`aco_routing.Ant`\n- An `Ant` that traverses the graph.\n\n### ACO\n`aco_routing.ACO`\n- The traditional Ant Colony Optimization algorithm that spawns ants at various nodes in the graph and finds the shortest path between the specified source and destination ([pseudo code](https://en.wikipedia.org/wiki/Ant_colony_optimization_algorithms#Algorithm_and_formula)).\n\n\n## Contributing\n\n- Post any issues and suggestions on the GitHub [issues](https://github.com/hasnainroopawalla/Ant-Colony-Optimization/issues) page.\n- To contribute, fork the project and then create a pull request back to master.\n\n\n## License\nThis project is licensed under the MIT License - see the [LICENSE](https://github.com/hasnainroopawalla/Ant-Colony-Optimization/blob/73b65a6fd14e3e5517b479cfecac1140f0ae7899/LICENSE) file for details.\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A Python package to find the shortest path in a graph using Ant Colony Optimization (ACO)",
    "version": "1.1.0",
    "project_urls": {
        "Homepage": "https://github.com/hasnainroopawalla/ant-colony-optimization"
    },
    "split_keywords": [
        "python",
        "machinelearning",
        "ai",
        "aco"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dc667f44b188ee3e4a6079aaebe3fd2c04aa0b554587734dd4d8719c97a7d3ac",
                "md5": "563823156648e85e9af6dee292c3a597",
                "sha256": "082f41b00383527dce89b5f07772c76af7c5ad099be0012505c281361e1362b8"
            },
            "downloads": -1,
            "filename": "aco_routing-1.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "563823156648e85e9af6dee292c3a597",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 8561,
            "upload_time": "2023-12-17T21:31:38",
            "upload_time_iso_8601": "2023-12-17T21:31:38.035452Z",
            "url": "https://files.pythonhosted.org/packages/dc/66/7f44b188ee3e4a6079aaebe3fd2c04aa0b554587734dd4d8719c97a7d3ac/aco_routing-1.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e7b6ecb1e8e293ab41ef5def1f8bb6efd02fc7b27d8b06b8fc3c32563ddf6463",
                "md5": "84240beb906eb6abb023223be3ae3d3b",
                "sha256": "145769e327a2f1739cdaf18febf3dd0628c33dd94e137665674ace2298f1916d"
            },
            "downloads": -1,
            "filename": "aco_routing-1.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "84240beb906eb6abb023223be3ae3d3b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 7676,
            "upload_time": "2023-12-17T21:31:39",
            "upload_time_iso_8601": "2023-12-17T21:31:39.594973Z",
            "url": "https://files.pythonhosted.org/packages/e7/b6/ecb1e8e293ab41ef5def1f8bb6efd02fc7b27d8b06b8fc3c32563ddf6463/aco_routing-1.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-17 21:31:39",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hasnainroopawalla",
    "github_project": "ant-colony-optimization",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "aco-routing"
}
        
Elapsed time: 0.16421s