{ "info": { "author": "Robert Grant", "author_email": "rhgrant10@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "=====\nPants\n=====\n\nA Python3 implementation of the Ant Colony Optimization Meta-Heuristic\n\n--------\nOverview\n--------\n\n**Pants** provides you with the ability to quickly determine how to\nvisit a collection of interconnected nodes such that the work done is\nminimized. Nodes can be any arbitrary collection of data while the edges\nrepresent the amount of \"work\" required to travel between two nodes.\nThus, **Pants** is a tool for solving traveling salesman problems.\n\nThe world is built from a list of nodes and a function responsible for\nreturning the length of the edge between any two given nodes. The length\nfunction need not return actual length. Instead, \"length\" refers to that \nthe amount of \"work\" involved in moving from the first node to the second\nnode - whatever that \"work\" may be. For a silly, random example, it could\neven be the number of dishes one must wash before moving to the next \nstation at a least dish-washing dish washer competition.\n\nSolutions are found through an iterative process. In each iteration,\nseveral ants are allowed to find a solution that \"visits\" every node of\nthe world. The amount of pheromone on each edge is updated according to\nthe length of the solutions in which it was used. The ant that traveled the\nleast distance is considered to be the local best solution. If the local\nsolution has a shorter distance than the best from any previous\niteration, it then becomes the global best solution. The elite ant(s)\nthen deposit their pheromone along the path of the global best solution\nto strengthen it further, and the process repeats.\n\nYou can read more about `Ant Colony Optimization on\nWikipedia `_.\n\n------------\nInstallation\n------------\n\nInstallation via ``pip``\n\n.. code-block:: console\n\n $ pip3 install ACO-Pants\n\n-----\nUsage\n-----\n\nUsing **Pants** is simple. The example here uses Euclidean distance\nbetween 2D nodes with ``(x, y)`` coordinates, but there are no real\nrequirements for node data of any sort.\n\n1) Import **Pants** (along with any other packages you'll need).\n\n .. code-block:: python\n\n import pants\n import math\n import random\n\n2) Create your data points; these become the nodes. Here we create some\n random 2D points. The only requirement for a node is that it is\n distinguishable from all of the other nodes.\n\n .. code-block:: python\n\n nodes = []\n for _ in range(20):\n x = random.uniform(-10, 10)\n y = random.uniform(-10, 10)\n nodes.append((x, y))\n\n\n3) Define your length function. This function must accept two nodes and\n return the amount of \"work\" between them. In this case, Euclidean \n distance works well.\n\n .. code-block:: python\n\n def euclidean(a, b):\n return math.sqrt(pow(a[1] - b[1], 2) + pow(a[0] - b[0], 2))\n\n4) Create the ``World`` from the nodes and the length function. \n\n .. code-block:: python\n\n world = pants.World(nodes, euclidean)\n\n5) Create the ``Solver``.\n\n .. code-block:: python\n\n solver = pants.Solver()\n\n6) Solve the ``World`` with the ``Solver``. Two methods are provided for\n finding solutions: ``solve()`` and ``solutions()``. The former\n returns the best solution found, whereas the latter returns each\n solution found if it is the best thus far.\n\n .. code-block:: python\n\n solution = solver.solve(world)\n # or\n solutions = solver.solutions(world)\n\n7) Inspect the solution(s).\n\n .. code-block:: python\n\n print(solution.distance)\n print(solution.tour) # Nodes visited in order\n print(solution.path) # Edges taken in order\n # or\n best = float(\"inf\")\n for solution in solutions:\n assert solution.distance < best\n best = solution.distance\n\nRun the Demo\n------------\n\nIncluded is a 33 \"city\" demo script that can be run from the command line.\n\n.. code-block:: console\n \n user@host:~$ pants-demo -h\n usage: pants-demo [-h] [-V] [-a A] [-b B] [-l L] [-p P] [-e E] [-q Q] [-t T]\n [-c N] [-d D]\n\n Script th;at demos the ACO-Pants package.\n\n optional arguments:\n -h, --help show this help message and exit\n -V, --version show program's version number and exit\n -a A, --alpha A relative importance placed on pheromones; default=1\n -b B, --beta B relative importance placed on distances; default=3\n -l L, --limit L number of iterations to perform; default=100\n -p P, --rho P ratio of evaporated pheromone (0 <= P <= 1); default=0.8\n -e E, --elite E ratio of elite ant's pheromone; default=0.5\n -q Q, --Q Q total pheromone capacity of each ant (Q > 0); default=1\n -t T, --t0 T initial amount of pheromone on every edge (T > 0);\n default=0.01\n -c N, --count N number of ants used in each iteration (N > 0); default=10\n -d D, --dataset D specify a particular set of demo data; default=33\n\n For best results:\n * 0.5 <= A <= 1\n * 1.0 <= B <= 5\n * A < B\n * L >= 2000\n * N > 1\n\n For more information, please visit https://github.com/rhgrant10/Pants.\n user@host:~$ pants-demo\n Solver settings:\n limit=100\n rho=0.8, Q=1\n alpha=1, beta=3\n elite=0.5\n\n Time Elapsed Distance \n --------------------------------------------------\n 0:00:00.017490 0.7981182992833705 \n 0:00:00.034784 0.738147755518648 \n 0:00:00.069041 0.694362159048816 \n 0:00:00.276027 0.6818083968312925 \n 0:00:00.379039 0.6669398280432167 \n 0:00:00.465924 0.6463548571712562 \n 0:00:00.585685 0.6416519698864324 \n 0:00:01.563389 0.6349308484274142 \n --------------------------------------------------\n Best solution:\n 0 = (34.02115, -84.267249)\n 9 = (34.048194, -84.262126)\n 6 = (34.044915, -84.255772)\n 22 = (34.061518, -84.243566)\n 23 = (34.062461, -84.240155)\n 18 = (34.060461, -84.237402)\n 17 = (34.060164, -84.242514)\n 12 = (34.04951, -84.226327)\n 11 = (34.048679, -84.224917)\n 8 = (34.046006, -84.225258)\n 7 = (34.045483, -84.221723)\n 13 = (34.051529, -84.218865)\n 14 = (34.055487, -84.217882)\n 16 = (34.059412, -84.216757)\n 25 = (34.066471, -84.217717)\n 24 = (34.064489, -84.22506)\n 20 = (34.063814, -84.225499)\n 10 = (34.048312, -84.208885)\n 15 = (34.056326, -84.20058)\n 5 = (34.024302, -84.16382)\n 32 = (34.118162, -84.163304)\n 31 = (34.116852, -84.163971)\n 30 = (34.109645, -84.177031)\n 29 = (34.10584, -84.21667)\n 28 = (34.071628, -84.265784)\n 27 = (34.068647, -84.283569)\n 26 = (34.068455, -84.283782)\n 19 = (34.061281, -84.334798)\n 21 = (34.061468, -84.33483)\n 2 = (34.022585, -84.36215)\n 3 = (34.022718, -84.361903)\n 4 = (34.023101, -84.36298)\n 1 = (34.021342, -84.363437)\n Solution length: 0.6349308484274142\n Found at 0:00:01.563389 out of 0:00:01.698616 seconds.\n user@host:~$\n\nKnown Bugs\n----------\n\nNone of which I am currently aware. Please let me know if you find \notherwise.\n\nTroubleshooting\n---------------\n\nCredits\n-------\n\n- Robert Grant rhgrant10@gmail.com\n\nLicense\n-------\n\nGPL", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://pypi.python.org/pypi/ACO-Pants", "keywords": null, "license": "LICENSE.txt", "maintainer": null, "maintainer_email": null, "name": "ACO-Pants", "package_url": "https://pypi.org/project/ACO-Pants/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/ACO-Pants/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://pypi.python.org/pypi/ACO-Pants" }, "release_url": "https://pypi.org/project/ACO-Pants/0.5.2/", "requires_dist": null, "requires_python": null, "summary": "A Python3 implementation of the ACO Meta-Heuristic", "version": "0.5.2" }, "last_serial": 1218328, "releases": { "0.3.1": [], "0.3.2": [ { "comment_text": "", "digests": { "md5": "576424b990cd50e797eafe53f934b8bb", "sha256": "72e8c5e43848691a389b10c774495311b50067fa00ddd58a43c38a274bc0e872" }, "downloads": -1, "filename": "ACO-Pants-0.3.2.tar.gz", "has_sig": false, "md5_digest": "576424b990cd50e797eafe53f934b8bb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11489, "upload_time": "2014-06-12T15:56:16", "url": "https://files.pythonhosted.org/packages/5e/d3/c316929d6955466d9a47ed5e5fc9583ca461551330daef5c8065b0d01f9f/ACO-Pants-0.3.2.tar.gz" } ], "0.3.3": [ { "comment_text": "", "digests": { "md5": "07e354246ba28b75a6e9c8896f95ba5e", "sha256": "16daca378dc7a2973dc71c45589dc52d83136e1c5cfe54725adca5bdb2c02193" }, "downloads": -1, "filename": "ACO-Pants-0.3.3.tar.gz", "has_sig": false, "md5_digest": "07e354246ba28b75a6e9c8896f95ba5e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11861, "upload_time": "2014-06-12T16:11:01", "url": "https://files.pythonhosted.org/packages/27/35/95efa5c820cfd08b94fd9d2d0afdf3bc52e70562474763e97af98fa68d14/ACO-Pants-0.3.3.tar.gz" } ], "0.3.4": [ { "comment_text": "", "digests": { "md5": "d18a36cc0583e8e7e7c96b05da535aa6", "sha256": "a748b4e7c3793950ee1fe60b21cc00273837719a8ef2775dfee4b8646480d4ec" }, "downloads": -1, "filename": "ACO-Pants-0.3.4.tar.gz", "has_sig": false, "md5_digest": "d18a36cc0583e8e7e7c96b05da535aa6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14161, "upload_time": "2014-06-13T01:49:54", "url": "https://files.pythonhosted.org/packages/d4/05/75206e58a9d8f9fa46a1a5760ad3b55fb5669ca6501c33de33b41fdb4906/ACO-Pants-0.3.4.tar.gz" } ], "0.3.5": [ { "comment_text": "", "digests": { "md5": "19719ddb1c1186bb8c17c6bb32f20024", "sha256": "900dd2b59370f3bd4f8f75709cb05c6582410cce5b94104ce31870f3857d3dc2" }, "downloads": -1, "filename": "ACO-Pants-0.3.5.tar.gz", "has_sig": false, "md5_digest": "19719ddb1c1186bb8c17c6bb32f20024", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13978, "upload_time": "2014-06-13T02:40:17", "url": "https://files.pythonhosted.org/packages/87/82/4e7ccfa7c2b0d65e73b87b3c957d1b3b75e135ada017b9d04abf2df983e2/ACO-Pants-0.3.5.tar.gz" } ], "0.3.6": [ { "comment_text": "", "digests": { "md5": "38affe5c4fe8455dd1b0b4c6a038a976", "sha256": "024917123db3178c4384a15e46db96b209733bc915db8c581102a4f1f22a0f54" }, "downloads": -1, "filename": "ACO-Pants-0.3.6.tar.gz", "has_sig": false, "md5_digest": "38affe5c4fe8455dd1b0b4c6a038a976", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12241, "upload_time": "2014-06-13T14:00:26", "url": "https://files.pythonhosted.org/packages/9e/85/850eb53a77ac15c56be5df310fb0de16b6ad7d7daa90c7003cc919e834d2/ACO-Pants-0.3.6.tar.gz" } ], "0.3.7": [ { "comment_text": "", "digests": { "md5": "f70ef112726155947191e2249ee6871b", "sha256": "903f133e0cc9c3d0dd050b318c86ab6e2f1160e5aea3fcdf206447fb2b4854cf" }, "downloads": -1, "filename": "ACO-Pants-0.3.7.tar.gz", "has_sig": false, "md5_digest": "f70ef112726155947191e2249ee6871b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12234, "upload_time": "2014-06-13T14:23:20", "url": "https://files.pythonhosted.org/packages/c7/fe/9a0654f3cece963e2dc9ede2afba2047a1bc667963bcabc14bf8f9ca2554/ACO-Pants-0.3.7.tar.gz" } ], "0.3.8": [ { "comment_text": "", "digests": { "md5": "c81a594e53ae348032549aafc93a2623", "sha256": "c3f0867f704566c843e3adbe23db7a4d543756ab411e069ff6d365395332da01" }, "downloads": -1, "filename": "ACO-Pants-0.3.8.tar.gz", "has_sig": false, "md5_digest": "c81a594e53ae348032549aafc93a2623", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12238, "upload_time": "2014-06-13T14:32:22", "url": "https://files.pythonhosted.org/packages/81/00/5d9a44d9f1e1d90fe5c05a767d70c4feee8b1f9fc035b982d5fb3c6037e0/ACO-Pants-0.3.8.tar.gz" } ], "0.4.0": [ { "comment_text": "", "digests": { "md5": "ccee5087e7dc5bf5f86e176d3a492ef9", "sha256": "9fc9b6e97373b7564638bd003c3bd0ea3c410e72e6f7840842030178a502612e" }, "downloads": -1, "filename": "ACO-Pants-0.4.0.tar.gz", "has_sig": false, "md5_digest": "ccee5087e7dc5bf5f86e176d3a492ef9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12526, "upload_time": "2014-06-19T16:15:21", "url": "https://files.pythonhosted.org/packages/06/0b/d9a5ffa4525d95d8e6dc44fd53110c43459841dd019b0bd87d2fdcac676f/ACO-Pants-0.4.0.tar.gz" } ], "0.4.1": [ { "comment_text": "", "digests": { "md5": "4f8507a0fb6be01c6227b27a287c7a28", "sha256": "26211d9c6fe8b942c25c67aec7e35bd6641c47b248c0a2024bb392058a73fbd0" }, "downloads": -1, "filename": "ACO-Pants-0.4.1.tar.gz", "has_sig": false, "md5_digest": "4f8507a0fb6be01c6227b27a287c7a28", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12273, "upload_time": "2014-06-24T20:40:00", "url": "https://files.pythonhosted.org/packages/b6/96/4281e150f4335042a0a5f0f8ff7c45537243c1fdca4ac18a86f4b3e92de3/ACO-Pants-0.4.1.tar.gz" } ], "0.5.0": [ { "comment_text": "", "digests": { "md5": "a6df6db1f530d11bda72dea333a83740", "sha256": "727aa66ffe40a5a7ce06614cf8397d1fe98f50a8e998cdd25ace89f69f0ba05d" }, "downloads": -1, "filename": "ACO-Pants-0.5.0.tar.gz", "has_sig": false, "md5_digest": "a6df6db1f530d11bda72dea333a83740", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13906, "upload_time": "2014-06-25T17:03:35", "url": "https://files.pythonhosted.org/packages/f0/e0/55a3df9382c3858dc73e2870688a5a26aaeda9042d8ebc9b71317f50c002/ACO-Pants-0.5.0.tar.gz" } ], "0.5.1": [ { "comment_text": "", "digests": { "md5": "a97f40cedccb0cc23ad6fe05a2d3cf86", "sha256": "35ee88a1c5e478bb6f8a359edcbe10161a971ac1720529456702934801507e9a" }, "downloads": -1, "filename": "ACO-Pants-0.5.1.tar.gz", "has_sig": false, "md5_digest": "a97f40cedccb0cc23ad6fe05a2d3cf86", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15610, "upload_time": "2014-06-26T17:09:51", "url": "https://files.pythonhosted.org/packages/52/76/070c15542caaf8311266326e81ccb0fd5fcbef9995e461899883db020086/ACO-Pants-0.5.1.tar.gz" } ], "0.5.2": [ { "comment_text": "", "digests": { "md5": "55d40f2cd0594f82021fac25b0b936e1", "sha256": "7f12498681de7954faf58f419aee9555c8d77ec777935fa206d674b7aa20a19d" }, "downloads": -1, "filename": "ACO-Pants-0.5.2.tar.gz", "has_sig": false, "md5_digest": "55d40f2cd0594f82021fac25b0b936e1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15617, "upload_time": "2014-09-09T14:57:24", "url": "https://files.pythonhosted.org/packages/91/67/e62d59d6b47ed6809d1212ec42bee8137e755f538784105bd5d8d2346ab6/ACO-Pants-0.5.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "55d40f2cd0594f82021fac25b0b936e1", "sha256": "7f12498681de7954faf58f419aee9555c8d77ec777935fa206d674b7aa20a19d" }, "downloads": -1, "filename": "ACO-Pants-0.5.2.tar.gz", "has_sig": false, "md5_digest": "55d40f2cd0594f82021fac25b0b936e1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15617, "upload_time": "2014-09-09T14:57:24", "url": "https://files.pythonhosted.org/packages/91/67/e62d59d6b47ed6809d1212ec42bee8137e755f538784105bd5d8d2346ab6/ACO-Pants-0.5.2.tar.gz" } ] }