{ "info": { "author": "Geoffrey Bomarito", "author_email": "geoffrey.f.bomarito@nasa.gov", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "License :: OSI Approved :: Apache Software License", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "![Bingo Logo](media/logo.png)\n\nmaster: [![Build Status](https://travis-ci.com/nasa/bingo.svg?branch=master)](https://travis-ci.com/nasa/bingo) [![Coverage Status](https://coveralls.io/repos/github/nasa/bingo/badge.svg?branch=master)](https://coveralls.io/github/nasa/bingo?branch=master)\n\ndevelop: [![Build Status](https://travis-ci.com/nasa/bingo.svg?branch=develop)](https://travis-ci.com/nasa/bingo) [![Coverage Status](https://coveralls.io/repos/github/nasa/bingo/badge.svg?branch=develop)](https://coveralls.io/github/nasa/bingo?branch=develop) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/9fe09cffafe64032962a82f7f1588e9f)](https://www.codacy.com/app/bingo_developers/bingo?utm_source=github.com&utm_medium=referral&utm_content=nasa/bingo&utm_campaign=Badge_Grade)\n\n## General\nBingo is an open source package for performing symbolic regression, Though it \ncan be used as a general purpose evolutionary optimization package. \n\n### Key Features\n * Integrated local optimization strategies\n * Parallel island evolution strategy implemented with mpi4py\n * Coevolution of fitness predictors\n \n### Note\nAt this point, the API is still in a state of flux. The current release has a \nmuch more stable API but still lacks some of the features of older releases.\n\n## Getting Started\n\n### Dependencies\nBingo is intended for use with Python 3.x. Bingo requires installation of a \nfew dependencies which are relatively common for data science work in python:\n - numpy\n - scipy\n - matplotlib\n - mpi4py (if parallel implementations are to be run)\n - pytest, pytest-mock (if the testing suite is to be run)\n \nA `requirements.txt` file is included for easy installation of dependencies with \n`pip` or `conda`.\n\nInstallation with pip:\n```shell\npip install -r requirements.txt\n```\n\nInstallation with conda:\n```shell\nconda install --yes --file requirements.txt\n```\n\n### BingoCpp\nA section of bingo is written in c++ for increased performance. In order to \ntake advantage of this capability, the code must be compiled. See the \ndocumentation in the bingocpp submodule for more information.\n\nNote that bingo can be run without the bingocpp portion, it will just have lower \nperformance.\n\nIf bingocpp has been properly installed, the following command should run \nwithout error.\n```shell\npython -c \"import bingocpp\"\n```\n\nA common error in the installation of bingocpp is that it must be built with \nthe same version of python that will run your bingo scripts. The easiest way \nto ensure consistent python versioning is to build and run in a Python 3 \nvirtual environment.\n\n### Documentation\nSphynx is used for automatically generating API documentation for bingo. The \nmost recent build of the documentation can be found in the repository at: \n`doc/_build/html/index.html`\n\n\n## Running Tests\nAn extensive unit test suite is included with bingo to help ensure proper \ninstallation. The tests can be run using pytest on the tests directory, e.g., \nby running:\n```shell\npytest tests \n```\nfrom the root directory of the repository.\n\n## Usage Examples\nIn addition to the example shown here, the best place to get started in bingo \nis by going through the [examples directory](examples/). It contains several scripts and \njupyter notebooks.\n\n### A simple evolutionary analysis with bingo: the one max problem\nThis example walks through the general steps needed to set up and run a bingo \nanalysis. The example problem described here is the one max problem. In the \none max problem individuals in a population are defined by a chromosome with a \nlist of 0 or 1 values, e.g., `[0, 1, 1, 0, 1]`. The goal of the optimization \nis to evolve toward an optimum list containing all 1's. A complete version of \nthis example is script is found [here](examples/OneMaxExample.py).\n\n#### Defining a chromosome generator\nBingo's built-in `MultipleValueChromosome` is used here. Individuals of this \ncontain their genetic information in a list attribute named `values`. A \nchromosome generator is used to generate members of the population. The \n`MultipleValueChromosomeGenerator` generates these individuals by populating \nthe indivudual's `values` from a given input function.\n```python\nimport numpy as np\nfrom bingo.Base.MultipleValues import MultipleValueChromosomeGenerator\nnp.random.seed(0) # seeded for reproducible results\n\ndef generate_0_or_1():\n return np.random.choice([0, 1])\n\ngenerator = MultipleValueChromosomeGenerator(generate_0_or_1,\n values_per_chromosome=16) \n```\n\n#### Defining the evolutionary algorithm\nEvolutionary algorithms have 3 phases in bingo: variation, evaluation and \nselection. The variation phase is responsible for generating offspring of the \npopulation, usually through some combination of mutation and crossover. In \nthis example `VarOr` is used which creates offspring through either mutation or \ncrossover (never both).\n```python\nfrom bingo.Base.MultipleValues import SinglePointCrossover, SinglePointMutation\nfrom bingo.Base.VarOr import VarOr\n\ncrossover = SinglePointCrossover()\nmutation = SinglePointMutation(generate_0_or_1)\nvariation_phase = VarOr(crossover, mutation,\n crossover_probability=0.4,\n mutation_probability=0.4)\n```\nThe evaluation phase is responsible for evaluating the fitness of new members \nof a population. It relies on the definition of a `FitnessFunction` class. \nThe goal of bingo analyses is to *minimize* fitness, so fitness functions \nshould be constructed accordingly. In the one max problem fitness is defined \nas the number of 0's in the individuals `values`.\n```python\nfrom bingo.Base.FitnessFunction import FitnessFunction\nfrom bingo.Base.Evaluation import Evaluation\n\nclass OneMaxFitnessFunction(FitnessFunction):\n \"\"\"Callable class to calculate fitness\"\"\"\n def __call__(self, individual):\n return individual.values.count(0)\n\nfitness = OneMaxFitnessFunction()\nevaluation_phase = Evaluation(fitness)\n```\nThe selection phase is responsible for choosing which members of the population \nproceed to the next generation. An implementation of the common tournament \nselection algorithm is used here.\n```python\nfrom bingo.Base.TournamentSelection import Tournament\n\nselection_phase = Tournament(tournament_size=2)\n```\nBased on these phases, an `EvolutionaryAlgorithm` can be made.\n```python\nfrom bingo.Base.EvolutionaryAlgorithm import EvolutionaryAlgorithm\n\nev_alg = EvolutionaryAlgorithm(variation_phase, evaluation_phase, \n selection_phase)\n```\n\n#### Creating an island and running the analysis\nAn `Island` is the fundamental unit in bingo evolutionary analyses. It is \nresponsible for generating and evolving a population (using a generator and \nevolutionary algorithm).\n```python\nfrom bingo.Base.Island import Island\n\nisland = Island(ev_alg, generator, population_size=10)\nbest_individual = island.best_individual()\nprint(\"Best individual at start: \", best_individual)\nprint(\"Best individual's fitness: \", best_individual.fitness)\n```\n```\n Best individual at start: [1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1]\n Best individual's fitness: 5\n```\nThe island can be evolved directly using it's `execute_generational_step` \nmember function. In this case the population is evolved for 50 generations\n```python\nfor _ in range(50):\n island.execute_generational_step()\n\nbest_individual = island.best_individual()\nprint(\"Best individual at end: \", best_individual)\nprint(\"Best individual's fitness: \", best_individual.fitness)\n```\n```\n Best individual at end: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n Best individual's fitness: 0\n```\n\n## Contributing\n1. Fork it ()\n2. Create your feature branch (`git checkout -b feature/fooBar`)\n3. Commit your changes (`git commit -am 'Add some fooBar'`)\n4. Push to the branch (`git push origin feature/fooBar`)\n5. Create a new Pull Request\n\n\n## Versioning\nWe use [SemVer](http://semver.org/) for versioning. For the versions available, \nsee the [tags on this repository](https://github.com/nasa/bingo/tags). \n\n## Authors\n * Geoffrey Bomarito\n * Kathryn Esham\n * Ethan Adams\n * Tyler Townsend\n * Diana Vera\n \n## License \n#### Notices\nCopyright 2018 United States Government as represented by the Administrator of \nthe National Aeronautics and Space Administration. No copyright is claimed in \nthe United States under Title 17, U.S. Code. All Other Rights Reserved.\n\nThe Bingo Mini-app framework is licensed under the Apache License, Version 2.0 \n(the \"License\"); you may not use this application except in compliance with the \nLicense. You may obtain a copy of the License at \n[http://www.apache.org/licenses/LICENSE-2.0].\n\nUnless required by applicable law or agreed to in writing, software distributed \nunder the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \nCONDITIONS OF ANY KIND, either express or implied. See the License for the \nspecific language governing permissions and limitations under the License.", "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/nasa/bingo", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "bingo-nasa", "package_url": "https://pypi.org/project/bingo-nasa/", "platform": "", "project_url": "https://pypi.org/project/bingo-nasa/", "project_urls": { "Homepage": "https://github.com/nasa/bingo" }, "release_url": "https://pypi.org/project/bingo-nasa/0.2.2/", "requires_dist": null, "requires_python": "~=3.4", "summary": "A package for genetic optimization and symbolic regression", "version": "0.2.2" }, "last_serial": 5273159, "releases": { "0.2.2": [ { "comment_text": "", "digests": { "md5": "5041d8d1530c0a3f9ab5106c8179405f", "sha256": "d773ebda8da6f5ab1902685389cec85d4854d28815470a229817b0719fa0ec79" }, "downloads": -1, "filename": "bingo-nasa-0.2.2.tar.gz", "has_sig": false, "md5_digest": "5041d8d1530c0a3f9ab5106c8179405f", "packagetype": "sdist", "python_version": "source", "requires_python": "~=3.4", "size": 1656465, "upload_time": "2019-05-15T15:54:12", "url": "https://files.pythonhosted.org/packages/f7/a5/62a58ddcb5fbe3ea30041a37bdb948a50d591f5e5236f7c9aabc23c2a943/bingo-nasa-0.2.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "5041d8d1530c0a3f9ab5106c8179405f", "sha256": "d773ebda8da6f5ab1902685389cec85d4854d28815470a229817b0719fa0ec79" }, "downloads": -1, "filename": "bingo-nasa-0.2.2.tar.gz", "has_sig": false, "md5_digest": "5041d8d1530c0a3f9ab5106c8179405f", "packagetype": "sdist", "python_version": "source", "requires_python": "~=3.4", "size": 1656465, "upload_time": "2019-05-15T15:54:12", "url": "https://files.pythonhosted.org/packages/f7/a5/62a58ddcb5fbe3ea30041a37bdb948a50d591f5e5236f7c9aabc23c2a943/bingo-nasa-0.2.2.tar.gz" } ] }