{ "info": { "author": "chankane", "author_email": "brawnychocolate@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3.7" ], "description": "# pyind\nA genetic algorithm library in Python3\n\n**pyind ONLY supports ndarray (numpy)**\n\n[\u65e5\u672c\u8a9e](https://github.com/chankane/pyind/blob/master/README.ja.md)\n\n## Installation\n``pip install pyind``\n\n## About evaluation function\nAn evaluation function has the following format\n```python\ndef evaluation_function(individual): # individual is an array of gene\n return fitness_of_this_individual\n\n```\n\n## About `conf`\n`conf` has the following format\n```python\nconf_format = {\n \"eval\": {\n \"func\": evaluation_function # Required fields and it has not default value.\n },\n \"sel\": {\n # See \"Table Sel\" below\n },\n \"xovr\": {\n # See \"Table Xovr\" below\n },\n \"mut\": {\n # See \"Table Mut\" below\n },\n}\n```\nValue that can be set to `conf[\"sel\"]` are as shown in the table\n\nIn parentheses is default value\n\nTable Sel\n\n\"sel\" (elitism) | \"num\" (10)\n-- | :--:\nelitism | 0–size of poplation\nroulette | 0–size of poplation\n\nValue that can be set to `conf[\"xovr\"]` are as shown in the table\n\nIn parentheses is default value\n\nTable Xovr\n\n\"xovr\" (p2) | \"pb\" (0.875)\n-- | :--:\np2 | 0–1\nuniform | 0–1\nox | 0–1\n\nValue that can be set to `conf[\"mut\"]` are as shown in the table\n\nIn parentheses is default value\n\nTable Mut\n\n\"mut\" (flip_bit) | \"pb\" (0.0075)| \"delta\" (1)\n-- | :--: | :--:\nflip_bit | 0–1\nboundary | 0–1 | 0–∞\nswap_idx | 0–1\n\n## Future Releases\n1. Fix bug\n1. Add functions of selection, crossover and mutation\n1. Run more faster\n## License\nMIT\n\n## Sample code\n### Onemax problem\n```python\n# Onemax Problem\nimport numpy as np\n\nfrom pyind import pyind as pi\nfrom pyind import defaults as df\n\n\nIND_LEN = 100\nPOP_LEN = 100\n\n\ndef evl(ind):\n return ind.sum()\n\n\nif __name__ == \"__main__\":\n pop = np.random.randint(2, size=(POP_LEN, IND_LEN))\n\n conf = df.CONF\n conf[\"eval\"][\"func\"] = evl\n\n best = pi.Pyind(pop, conf).run()\n\n print(\"best ind: \")\n print(best)\n\n```\n### Traveling salesman problem (TSP)\n```python\n# Traveling salesman problem\n\nimport numpy as np\nimport matplotlib.pyplot as plt\n\nfrom pyind import pyind as pi\nfrom pyind import crossover as xovr\nfrom pyind import mutation as mut\nfrom pyind import defaults as df\n\n\nCITIES_LEN = 30\nPOP_LEN = 300\nEND_GEN = 500\n\ncities = np.random.rand(CITIES_LEN * 2).reshape((-1, 2))\n\n\ndef evl(ind):\n total = 0\n for i in range(1, len(ind)):\n total += np.linalg.norm(cities[ind[i]] - cities[ind[i - 1]])\n return -total\n\n\ndef solve(pop):\n conf = df.CONF\n conf[\"eval\"][\"func\"] = evl\n conf[\"xovr\"][\"func\"] = xovr.ox\n conf[\"mut\"][\"func\"] = mut.swap_idx\n conf[\"mut\"][\"pb\"] = 0.10\n return pi.Pyind(pop, conf).run(END_GEN)\n\n\nif __name__ == \"__main__\":\n t = cities.T\n\n # Create pop\n pop = np.tile(np.arange(CITIES_LEN), (POP_LEN, 1))\n for e in pop:\n np.random.shuffle(e)\n\n # Plot gen 0\n idx = pop[0]\n plt.plot(t[0, idx], t[1, idx], label=\"gen 0\", marker=\"o\")\n\n best = solve(pop)\n print(\"best ind: \")\n print(best)\n\n # Plot gen END_GEN\n idx = best\n plt.plot(t[0, idx], t[1, idx], label=\"gen \" + str(END_GEN), marker=\"o\")\n\n plt.legend()\n plt.show()\n\n```\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/chankane/pyind", "keywords": "pyind genetic ga GA", "license": "", "maintainer": "", "maintainer_email": "", "name": "pyind", "package_url": "https://pypi.org/project/pyind/", "platform": "", "project_url": "https://pypi.org/project/pyind/", "project_urls": { "Homepage": "https://github.com/chankane/pyind" }, "release_url": "https://pypi.org/project/pyind/1.2/", "requires_dist": [ "numpy" ], "requires_python": "", "summary": "A genetic algorithm library in Python3", "version": "1.2" }, "last_serial": 4848266, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "133b3d4cbbd44011f72d6221ae929f23", "sha256": "4cf81cdc998079e5deb580855f12322e7bb0d186677703057ff2219f489c8eba" }, "downloads": -1, "filename": "pyind-1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "133b3d4cbbd44011f72d6221ae929f23", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8526, "upload_time": "2019-02-21T02:51:28", "url": "https://files.pythonhosted.org/packages/f4/67/ee84e16be6e16e2945d7362b26abc334f6ab26b5e1c6740aa6860fc1dd80/pyind-1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6c8d2195429b9c4c2274f39258c841a7", "sha256": "9e80efe9db2618b1336a36052fa3c5450003d8ee305b227fddfdcc58f04b01ff" }, "downloads": -1, "filename": "pyind-1.0.tar.gz", "has_sig": false, "md5_digest": "6c8d2195429b9c4c2274f39258c841a7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6441, "upload_time": "2019-02-21T02:51:29", "url": "https://files.pythonhosted.org/packages/8c/7a/8aa931cf8c57db6d64fc50380375671c4ed5322f9dbb8b2029447fb6fe6f/pyind-1.0.tar.gz" } ], "1.1": [ { "comment_text": "", "digests": { "md5": "46b46bfbc12d5761fd90d4b43b9a5516", "sha256": "ae1a4b79422c7d9d0b6b2f6aadea057796273e425c3704b8e9138dcf29d3b2fe" }, "downloads": -1, "filename": "pyind-1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "46b46bfbc12d5761fd90d4b43b9a5516", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8510, "upload_time": "2019-02-21T02:54:20", "url": "https://files.pythonhosted.org/packages/42/98/ca73f736a8a3bd09c36e856b0f1fd08c9df08dfeccf9196c5ff820c68fc9/pyind-1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b4daa249fe86c1b4ca034c5b18666ec5", "sha256": "ccdd11d8decccb9e8995036ac171ec08f9f8efbe1d9bc66477417f9cd064e739" }, "downloads": -1, "filename": "pyind-1.1.tar.gz", "has_sig": false, "md5_digest": "b4daa249fe86c1b4ca034c5b18666ec5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6413, "upload_time": "2019-02-21T02:54:22", "url": "https://files.pythonhosted.org/packages/cf/3f/2e3a99bc140cb3166d1ebaa2e0cbc89704e435a9f6272bd72f593ee0fc7b/pyind-1.1.tar.gz" } ], "1.2": [ { "comment_text": "", "digests": { "md5": "c4ed73f69080b54b827b6423428c73a1", "sha256": "7de640c54d11d260530eaed91c0a92ec1e274062a9215cc27f75b8ffe0366163" }, "downloads": -1, "filename": "pyind-1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "c4ed73f69080b54b827b6423428c73a1", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8513, "upload_time": "2019-02-21T02:56:30", "url": "https://files.pythonhosted.org/packages/74/0b/de171ffb85255282581a00c924bc97c12a3b4dfde585ce2aa2502ef74c2b/pyind-1.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "985a066d333f73ba8ebb8f7a3d07790e", "sha256": "91d98c184b646791cc4990613677952baf28734cfd1043ba988d259082dc1fd5" }, "downloads": -1, "filename": "pyind-1.2.tar.gz", "has_sig": false, "md5_digest": "985a066d333f73ba8ebb8f7a3d07790e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6413, "upload_time": "2019-02-21T02:56:33", "url": "https://files.pythonhosted.org/packages/b6/b0/24d48cd88cee27ebe29c180775a3b1d25316ed4c9540ac296d1a8e1d9318/pyind-1.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c4ed73f69080b54b827b6423428c73a1", "sha256": "7de640c54d11d260530eaed91c0a92ec1e274062a9215cc27f75b8ffe0366163" }, "downloads": -1, "filename": "pyind-1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "c4ed73f69080b54b827b6423428c73a1", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8513, "upload_time": "2019-02-21T02:56:30", "url": "https://files.pythonhosted.org/packages/74/0b/de171ffb85255282581a00c924bc97c12a3b4dfde585ce2aa2502ef74c2b/pyind-1.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "985a066d333f73ba8ebb8f7a3d07790e", "sha256": "91d98c184b646791cc4990613677952baf28734cfd1043ba988d259082dc1fd5" }, "downloads": -1, "filename": "pyind-1.2.tar.gz", "has_sig": false, "md5_digest": "985a066d333f73ba8ebb8f7a3d07790e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6413, "upload_time": "2019-02-21T02:56:33", "url": "https://files.pythonhosted.org/packages/b6/b0/24d48cd88cee27ebe29c180775a3b1d25316ed4c9540ac296d1a8e1d9318/pyind-1.2.tar.gz" } ] }