{ "info": { "author": "Justin Lovinger", "author_email": "", "bugtrack_url": null, "classifiers": [], "description": "Optimal (beta)\n==============\n\nA python metaheuristic optimization library. Built for easy extension\nand usage.\n\nWarning: Optimal is in beta. API may change. I will do my best to note\nany breaking changes in this readme, but no guarantee is given.\n\nSupported metaheuristics:\n\n- Genetic algorithms (GA)\n- Gravitational search algorithm (GSA)\n- Cross entropy (CE)\n\nInstallation\n============\n\n::\n\n pip install optimal\n\nUsage\n=====\n\n::\n\n import math\n\n from optimal import GenAlg\n from optimal import Problem\n from optimal import helpers\n\n # The genetic algorithm uses binary solutions.\n # A decode function is useful for converting the binary solution to real numbers\n def decode_ackley(binary):\n # Helpful functions from helpers are used to convert binary to float\n # x1 and x2 range from -5.0 to 5.0\n x1 = helpers.binary_to_float(binary[0:16], -5.0, 5.0)\n x2 = helpers.binary_to_float(binary[16:32], -5.0, 5.0)\n return x1, x2\n\n # ackley is our fitness function\n # This is how a user defines the goal of their problem\n def ackley_fitness(solution):\n x1, x2 = solution\n\n # Ackley's function\n # A common mathematical optimization problem\n output = -20 * math.exp(-0.2 * math.sqrt(0.5 * (x1**2 + x2**2))) - math.exp(\n 0.5 * (math.cos(2 * math.pi * x1) + math.cos(2 * math.pi * x2))) + 20 + math.e\n\n # You can prematurely stop the metaheuristic by returning True\n # as the second return value\n # Here, we consider the problem solved if the output is <= 0.01\n finished = output <= 0.01\n\n # Because this function is trying to minimize the output,\n # a smaller output has a greater fitness\n fitness = 1 / output\n\n # First return argument must be a real number\n # The higher the number, the better the solution\n # Second return argument is a boolean, and optional\n return fitness, finished\n\n # Define a problem instance to optimize\n # We can optionally include a decode function\n # The optimizer will pass the decoded solution into your fitness function\n # Additional fitness function and decode function parameters can also be added\n ackley = Problem(ackley_fitness, decode_function=decode_ackley)\n\n # Create a genetic algorithm with a chromosome size of 32,\n # and use it to solve our problem\n my_genalg = GenAlg(32)\n best_solution = my_genalg.optimize(ackley)\n\n print best_solution\n\nImportant notes:\n\n- Fitness function must take solution as its first argument\n- Fitness function must return a real number as its first return value\n\nFor further usage details, see comprehensive doc strings.\n\nMajor Changes\n=============\n\n08/27/2017\n----------\n\nMoved a number of options from Optimizer to Optimizer.optimize\n\n07/26/2017\n----------\n\nRenamed common.random\\_solution\\_binary to\ncommon.random\\_binary\\_solution, and common.random\\_solution\\_real to\ncommon.random\\_real\\_solution\n\n11/10/2016\n----------\n\nproblem now an argument of Optimizer.optimize, instead of\nOptimizer.\\_\\_init\\_\\_.\n\n11/10/2016\n----------\n\nmax\\_iterations now an argument of Optimizer.optimize, instead of\nOptimizer.\\_\\_init\\_\\_.\n\n11/8/2016\n---------\n\nOptimizer now takes a problem instance, instead of a fitness function\nand kwargs.\n\n11/5/2016\n---------\n\nLibrary reorganized with greater reliance on \\_\\_init\\_\\_.py.\n\nOptimizers can now be imported with:\n\n::\n\n from optimal import GenAlg, GSA, CrossEntropy\n\nEtc.", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/JustinLovinger/Optimal", "keywords": "optimization,metaheuristic,genetic algorithm,GA,gravitational search algorithm,GSA,cross entropy", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "optimal", "package_url": "https://pypi.org/project/optimal/", "platform": "", "project_url": "https://pypi.org/project/optimal/", "project_urls": { "Homepage": "https://github.com/JustinLovinger/Optimal" }, "release_url": "https://pypi.org/project/optimal/0.2.0/", "requires_dist": null, "requires_python": "", "summary": "A python metaheuristic optimization library. Currently supports Genetic Algorithms, Gravitational Search, and Cross Entropy.", "version": "0.2.0" }, "last_serial": 3148647, "releases": { "0.1.0": [], "0.2.0": [ { "comment_text": "", "digests": { "md5": "8591f221fc2963716b25041846075928", "sha256": "a99324b2b8a34cd912dda9729c2cd4d2830cd0b62bade475ce40d84ed3764ba7" }, "downloads": -1, "filename": "optimal-0.2.0.zip", "has_sig": false, "md5_digest": "8591f221fc2963716b25041846075928", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 49095, "upload_time": "2017-09-04T21:28:43", "url": "https://files.pythonhosted.org/packages/4a/88/7dc0dc4673d2b2496ad24e76ed68f6d713a496da22f67ed0e1b483164631/optimal-0.2.0.zip" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "8591f221fc2963716b25041846075928", "sha256": "a99324b2b8a34cd912dda9729c2cd4d2830cd0b62bade475ce40d84ed3764ba7" }, "downloads": -1, "filename": "optimal-0.2.0.zip", "has_sig": false, "md5_digest": "8591f221fc2963716b25041846075928", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 49095, "upload_time": "2017-09-04T21:28:43", "url": "https://files.pythonhosted.org/packages/4a/88/7dc0dc4673d2b2496ad24e76ed68f6d713a496da22f67ed0e1b483164631/optimal-0.2.0.zip" } ] }