{ "info": { "author": "TheSolvingMachine", "author_email": "support@thesolvingmachine.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3", "Topic :: Scientific/Engineering :: Artificial Intelligence" ], "description": "[![Build Status](https://travis-ci.org/TheSolvingMachine/kangrouter-py.svg?branch=master)](https://travis-ci.org/TheSolvingMachine/kangrouter-py)\n\n# kangrouter-py\nPython client for [KangRouter](https://thesolvingmachine.com/kangrouter/) - pickup/delivery transportation services optimization. \n \n## Installation\n\n```bash\npip install kangrouter-py\n```\n\n## Usage\n\n### Preliminaries\nFor interacting with the API, both an *apiKey* and a *licenseId* are required. Please\nobtain them from your [account](https://thesolvingmachine.com/account) page.\n\n### An example problem\n\nInput problems are described as a python dict. As a (simplistic) example, consider the problem of:\n* Taking [Alberto Caeiro](https://en.wikipedia.org/wiki/Fernando_Pessoa#Alberto_Caeiro) home after a medical appointment at the [Garcia de Orta Hospital](http://www.hgo.pt/). He is ready to leave the hospital after 13:00, and must be home no later than 14:15. Alberto is on a wheelchair, so we allocate 5 minutes for pickup and dropoff.\n* Picking [Ricardo Reis](https://en.wikipedia.org/wiki/Fernando_Pessoa#Ricardo_Reis) at the [Brasileira](https://en.wikipedia.org/wiki/Caf%C3%A9_A_Brasileira) caf\u00e9, and take him to a beach restaurant. He wants to be there no later than 12:15. Ricardo takes a regular seat.\n\nAssume that the vehicle available for transportation is parked in [Sintra](https://en.wikipedia.org/wiki/Sintra), has 3 seats and room for 2 wheelchairs. Additionally, the driver must have a 60 minute lunch break between 12:00 and 14:00. \n\nThis problem translates to the following object:\n\n```python\nproblem = {\n \"nbResources\": 2,\n \"jobs\": [\n {\n \"jobId\": \"Pickup Alberto at the hospital\",\n \"origLat\": \"38.674921\",\n \"origLon\": \"-9.175401\",\n \"destLat\": \"38.716860\",\n \"destLon\": \"-9.162417\",\n \"minStartTime\": \"13:00\",\n \"maxEndTime\": \"14:15\",\n \"pickupDuration\": 5,\n \"deliveryDuration\": 5,\n \"consumptions\": [0,1]\n },\n {\n \"jobId\": \"Take Ricardo to the beach\",\n \"origLat\": \"38.710835\",\n \"origLon\": \"-9.142143\",\n \"destLat\": \"38.634080\",\n \"destLon\": \"-9.230549\",\n \"maxEndTime\": \"12:15\",\n \"pickupDuration\": 1,\n \"deliveryDuration\": 1,\n \"consumptions\": [1,0]\n }\n ],\n \"vehicles\": [\n {\n \"vehicleId\": \"12-AS-46\",\n \"depotLat\": \"38.806842\",\n \"depotLon\": \"-9.382556\",\n \"minStartTime\": \"07:00\",\n \"maxEndTime\": \"22:00\",\n \"maxWorkDuration\": 540,\n \"capacities\": [2,3],\n \"breaks\": [\n {\n \"breakId\": \"Lunch\",\n \"minStartTime\": \"12:00\",\n \"maxEndTime\": \"14:00\",\n \"duration\": 60\n }\n ],\n \"overspeed\": 1.25\n }\n ]\n}\n```\nInteresting problems have multiple jobs and multiple vehicles, but the example above should be enough to get you going.\n\n### Submit a problem\n\nThe code below creates a new solver for the provided example:\n\n```python\nfrom kangrouter import KangRouterClient\napi = KangRouterClient(apiKey,licenseId)\nsolverId = api.create(problem)\n```\n\n### Check solving status\n\nAfter a solver is created it can be in one of 4 states:\n* pending - The solver is queued for execution but not started yet.\n* solving - The solver is executing.\n* completed - The solver has finished.\n* invalid - The problem is invalid, or an unexpected error has occurred.\n\nThe function below is used to query the solver current state and obtain information regarding the solving progress:\n\n```python\nstatus = api.getStatus(solverId)\nprint(status)\n```\n\nThis is a very simple problem, so the solver executes very quickly:\n\n\n```python\n{\n \"execStatus\": \"completed\",\n \"nbJobsDiscarded\": 0,\n \"solverEndTime\": \"Wed Nov 18 11:59:48 2015 GMT\",\n \"solverStartTime\": \"Wed Nov 18 11:59:40 2015 GMT\",\n \"totalDistance\": 98,\n}\n```\n\nGiven that larger problems may take a few minutes, calling this function while the solver is executing will also return ETA (expected delivery time) for completion.\n\n### Get the solution\n\nWhen the solver is done, the solution may be retrieved as follows:\n\n```python\nsolution = api.getSolution(solverId)\nprint(solution)\n```\n\nThe solution shows at what times, or time intervals, drivers must leave their depots, start their work breaks, or perform pickup/delivery actions:\n\n```python\n{\n \"jobsScheduled\": [\n {\n \"jobId\": \"Pickup Alberto at the hospital\",\n \"maxEndTime\": \"14:15\",\n \"maxStartTime\": \"13:55\",\n \"minEndTime\": \"13:20\",\n \"minStartTime\": \"13:00\",\n \"vehicleId\": \"12-AS-46\"\n },\n {\n \"jobId\": \"Take Ricardo to the beach\",\n \"maxEndTime\": \"12:15\",\n \"maxStartTime\": \"11:59\",\n \"minEndTime\": \"11:14\",\n \"minStartTime\": \"10:58\",\n \"vehicleId\": \"12-AS-46\"\n }\n ],\n \"type\": \"total\",\n \"vehiclesScheduled\": [\n {\n \"breaks\": [\n {\n \"breakId\": \"Lunch\",\n \"maxEndTime\": \"13:55\",\n \"maxStartTime\": \"12:55\",\n \"minEndTime\": \"13:00\",\n \"minStartTime\": \"12:00\"\n }\n ],\n \"maxEndTime\": \"14:35\",\n \"maxStartTime\": \"11:38\",\n \"minEndTime\": \"13:40\",\n \"minStartTime\": \"10:37\",\n \"vehicleId\": \"12-AS-46\"\n }\n ]\n}\n```\n### Other methods\nThe remaining methods allow to stop a running solver, which might be useful if you're in a hurry:\n\n```python\napi.stop(solverId)\n```\n\nand remove a solver (and associated data) from the server:\n\n```python\napi.delete(solverId)\n```\n\n## Links\n* [KangRouter API Reference](https://thesolvingmachine.com/kangrouter/doc/en/)\n* [KangRouter API Playground](https://thesolvingmachine.com/swagger/kangrouter/srv/)", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/TheSolvingMachine/kangrouter-py/tarball/1.0.4", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/TheSolvingMachine/kangrouter-py", "keywords": "Vehicle Routing With Time Windows", "license": "Apache", "maintainer": "", "maintainer_email": "", "name": "kangrouter-py", "package_url": "https://pypi.org/project/kangrouter-py/", "platform": "", "project_url": "https://pypi.org/project/kangrouter-py/", "project_urls": { "Download": "https://github.com/TheSolvingMachine/kangrouter-py/tarball/1.0.4", "Homepage": "https://github.com/TheSolvingMachine/kangrouter-py" }, "release_url": "https://pypi.org/project/kangrouter-py/1.0.4/", "requires_dist": null, "requires_python": "", "summary": "Python client for the KangRouter transportation service optimizer.", "version": "1.0.4" }, "last_serial": 3223715, "releases": { "1.0.2": [ { "comment_text": "", "digests": { "md5": "4cb25438cd3a1b5bfdeab76f87f979c8", "sha256": "bec4886420c1abac0611594d8949b07b51f261adea2583682930a1b6b3c21910" }, "downloads": -1, "filename": "kangrouter-py-1.0.2.tar.gz", "has_sig": false, "md5_digest": "4cb25438cd3a1b5bfdeab76f87f979c8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3443, "upload_time": "2015-11-14T19:13:59", "url": "https://files.pythonhosted.org/packages/90/76/564764a72c7abdd802d101ec71f862b38288b999471a4457cb6b2601ac39/kangrouter-py-1.0.2.tar.gz" } ], "1.0.3": [ { "comment_text": "", "digests": { "md5": "629aecf99526f8ff6177e76be5aae600", "sha256": "9b0d73f101aabd916bd5912c68040fdceb8e9d8e18d69be14d53fb7a80912236" }, "downloads": -1, "filename": "kangrouter-py-1.0.3.tar.gz", "has_sig": false, "md5_digest": "629aecf99526f8ff6177e76be5aae600", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5737, "upload_time": "2015-11-29T03:36:45", "url": "https://files.pythonhosted.org/packages/31/97/4431a39acad01dd44876a0557f97513c36d260c048e40fa6c1a88066af63/kangrouter-py-1.0.3.tar.gz" } ], "1.0.4": [ { "comment_text": "", "digests": { "md5": "60261d0e78952b5df0979d390d52f6bb", "sha256": "206cefc36fae16023c4b0af7cb8841755d51df9c1029bfe83c025ba9874cf182" }, "downloads": -1, "filename": "kangrouter-py-1.0.4.tar.gz", "has_sig": false, "md5_digest": "60261d0e78952b5df0979d390d52f6bb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5904, "upload_time": "2017-10-04T00:55:49", "url": "https://files.pythonhosted.org/packages/bb/f3/37b7505e06caf09d8c7860e2da2df7087a617cdabd78be7b0255f55ac9ed/kangrouter-py-1.0.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "60261d0e78952b5df0979d390d52f6bb", "sha256": "206cefc36fae16023c4b0af7cb8841755d51df9c1029bfe83c025ba9874cf182" }, "downloads": -1, "filename": "kangrouter-py-1.0.4.tar.gz", "has_sig": false, "md5_digest": "60261d0e78952b5df0979d390d52f6bb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5904, "upload_time": "2017-10-04T00:55:49", "url": "https://files.pythonhosted.org/packages/bb/f3/37b7505e06caf09d8c7860e2da2df7087a617cdabd78be7b0255f55ac9ed/kangrouter-py-1.0.4.tar.gz" } ] }