{"id":1370,"url":"https://github.com/petrmanek/Revolver","last_synced_at":"2025-08-02T04:31:15.487Z","repository":{"id":62452899,"uuid":"53369119","full_name":"petrmanek/Revolver","owner":"petrmanek","description":"A framework for building fast genetic algorithms in Swift.","archived":false,"fork":false,"pushed_at":"2017-07-30T19:06:27.000Z","size":77551,"stargazers_count":29,"open_issues_count":1,"forks_count":5,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-11-15T22:35:41.196Z","etag":null,"topics":["cocoapod","evolutionary-algorithms","genetic-algorithm","genetic-algorithm-framework","genetic-programming","machine-learning","optimization","optimization-methods","swift-framework","swift-library"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/petrmanek.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-08T00:22:57.000Z","updated_at":"2023-04-29T20:33:32.000Z","dependencies_parsed_at":"2022-11-29T13:20:57.153Z","dependency_job_id":null,"html_url":"https://github.com/petrmanek/Revolver","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/petrmanek%2FRevolver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/petrmanek%2FRevolver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/petrmanek%2FRevolver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/petrmanek%2FRevolver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/petrmanek","download_url":"https://codeload.github.com/petrmanek/Revolver/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228438911,"owners_count":17920014,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cocoapod","evolutionary-algorithms","genetic-algorithm","genetic-algorithm-framework","genetic-programming","machine-learning","optimization","optimization-methods","swift-framework","swift-library"],"created_at":"2024-01-05T20:15:44.895Z","updated_at":"2024-12-06T08:31:02.038Z","avatar_url":"https://github.com/petrmanek.png","language":"Swift","readme":"![image](Resources/header.png)\n\n[![Swift][swift-badge]][swift-url]\n[![Platform][platform-badge]][platform-url]\n[![CocoaPods][pod-badge]][pod-url]\n[![License][mit-badge]][mit-url]\n[![Travis][travis-badge]][travis-url]\n\nRevolver is a framework for building fast genetic algorithms in [Swift 3.0][swift-url].\n\n## Features\n\n- [x] Chromosomes: strings, trees\n- [x] Genetic operators: reproduction, mutation, crossover (1-point, 2-point, tree crossover)\n- [x] Selections: roulette, rank, tournament, random, best/worst\n- [x] Terminations: fixed number of generations, fitness threshold, date scheduling\n- [x] Evaluators: sequential, parallel, aggregate\n- [x] Random generators: Mersenne Twister, arc4random, drand48\n- [x] Everything listed above is ready-to-run, yet easily extensible. By subclassing base classes and conforming to protocols, you can customize almost anything.\n- [x] Well-documented API and many usage examples.\n- [x] Unit tests.\n\n\n## Compatibility\nRevolver was built with the open-source implementation of Swift in mind. For that reason, a great deal of effort was put into making it compile on Linux.\n\nRevolver is dependent on:\n\n - Swift 3.0 standard library\n - Foundation\n - libdispatch\n - SwiftyJSON\n\nRevolver can run on:\n\n - macOS\n - iOS\n - tvOS\n - watchOS\n - Linux (any distro capable of supporting the Swift runtime)\n\nRevolver can be compiled on:\n\n - macOS\n - Linux (any distro capable of supporting the Swift runtime)\n\nIf you for some reason need Swift 2 compatibility, check out the [swift-2.2][swift-2.2-branch] branch. Fair warning though, the branch has been frozen and remains unmaintained.\n\n\n## Installation\nThere are several ways to get Revolver integrated with your project. You can choose the one that suits you best.\n\n### Using CocoaPods\n[CocoaPods](http://cocoapods.org) is a dependency manager for Xcode projects. You can install it with the following command:\n\n```bash\n$ gem install cocoapods\n```\n\nTo integrate Revolver into your Xcode project using CocoaPods, specify it in your `Podfile` by adding the following line in your dependency list:\n\n```ruby\npod 'Revolver', '~\u003e 1.2'\n```\n\nThen, run the following command:\n\n```bash\n$ pod install\n```\n\n\n### Swift Package Manager\nThis method is recommended for *Pure Swift* projects on non-Apple platforms. Provided that you have already initialized your Package.swift file, you need to add Revolver as a dependency. That can be done by adding a line into the `dependencies` array as indicated below.\n\n```swift\nlet package = Package(\n    dependencies: [\n        // ... add this line:\n        .Package(url: \"https://github.com/petrmanek/Revolver.git\", majorVersion: 1),\n    ]\n)\n```\n\nDuring the first build of your package, SPM will download Revolver and resolve its dependencies.\n\n\n### Manually\nThis method is the most challenging of all. If you prefer manual installation for some reason, you will have to clone the project and its submodules.\n\n```bash\ngit clone --recursive https://github.com/petrmanek/Revolver.git\ncd Revolver\n```\n\nThen, include *Revolver.xcodeproj* in your project as an embedded framework.\n\n\n## Documentation\nRevolver is primarily documented with inline comments and Swift docstrings. If you prefer external documentation, check out the beautiful [HTML documentation][html-doc] generated by [jazzy][jazzy]. You may also be interested in reviewing a [my thesis][thesis], which is sort of a guide to using Revolver in practice.\n\n### Bundled Examples\nApart from conventional documentation, Revolver comes with various usage examples.\n\nListed in the increasing order of difficulty:\n\n 1. [MAX-ONE][example-maxone]: In which Revolver is introduced and configured to create the longest string of 1's.\n 2. [Parallel Evaluation][example-parallel]: In which Revolver is shown to utilize multiple CPU cores to speed up fitness evaluation.\n 3. [Knapsack Problem][example-knapsack]: In which Revolver is applied to solve an instance of a meaningful combinatorial problem.\n 4. [Self-driving Car][example-car]: In which a simple 2D simulation is set up to drive a robot car with the help of neural networks.\n 5. [QWOP][example-qwop]: In which Revolver produces human-competitive results, playing an online game.\n\n### Minimal Working Example\n\n```swift\nstruct MyChromosome: RangeInitializedArray {\n    typealias Element = Bool\n    static let initializationRange = 26...42\n\n    let array: [Element]    \n    init(array: [Element]) { self.array = array }    \n}\n\nclass MyEvaluator: SequentialEvaluator\u003cMyChromosome\u003e {\n    typealias Chromosome = MyChromosome\n\n    override func evaluateChromosome(individual: Chromosome) -\u003e Fitness {\n        // TODO: Fill in the fitness function here.\n        // You can return any Double between 0 and 1.\n        return 1.0\n    }    \n}\n\nlet elitism = Reproduction\u003cMyChromosome\u003e(BestSelection(), numberOfIndividuals: 5)\nlet reproduction = Reproduction\u003cMyChromosome\u003e(RouletteSelection())\nlet mutation = Mutation\u003cMyChromosome\u003e(RankSelection())\nlet crossover = OnePointCrossover\u003cMyChromosome\u003e(TournamentSelection(order: 10))\n\nlet alg = GeneticAlgorithm\u003cMyChromosome\u003e(\n    generator: ArcGenerator(),\n    populationSize: 200,\n    executeEveryGeneration: elitism,\n    executeInLoop: (Choice(reproduction, p: 0.50) ||| Choice(mutation, p: 0.25) ||| Choice(crossover, p: 0.25)),\n    evaluator: MyEvaluator(),\n    termination: (MaxNumberOfGenerations(60) || FitnessThreshold(0.5))\n)\n\nalg.run()\n```\n\n## Credits\nThis repository was created by [Petr Mánek][petrmanek-url] in 2016. Its contents are distributed under [MIT License][mit-url], unless specified otherwise.\n\n### BibTeX\nIf you use Revolver for your work, please reference it. For your convenience, here's the preferred BibTeX:\n\n```bibtex\n@mastersthesis{Manek2016,\n  document_type     = {Bachelor's Thesis},\n  timestamp         = {20160527},\n  author            = {Petr Mánek},\n  title             = {Genetic programming in Swift for human-competitive evolution},\n  school            = {Charles University in Prague},\n  year              = {2016},\n  type              = {Bachelor Thesis},\n  month             = {May},\n  pdf               = {http://www.ms.mff.cuni.cz/~manekp/publications/20160527-bachelor-thesis.pdf}\n}\n```\n\n## Contributions\nAll contributions to the framework are welcome.\n\nIf you'd like to contribute, let me first say thank you, you are made of awesome! Secondly, you may want to check out [the issue tracker][issue-tracker] for some bugs to fix and features to implement.\n\nAt the moment, there are no rules for contributing. However, before creating pull requests, please take some time to review [previous pull requests][pull-requests].\n\n\n[swift-badge]: https://img.shields.io/badge/Swift-3.0-orange.svg?style=flat\n[swift-url]: https://swift.org\n[platform-badge]: https://img.shields.io/badge/Platforms-OS%20X%20--%20Linux-lightgray.svg?style=flat\n[platform-url]: https://swift.org\n[mit-badge]: https://img.shields.io/badge/License-MIT-blue.svg?style=flat\n[mit-url]: https://tldrlegal.com/license/mit-license\n[travis-badge]: https://travis-ci.org/petrmanek/Revolver.svg?branch=master\n[travis-url]: https://travis-ci.org/petrmanek/Revolver\n[pod-badge]: https://img.shields.io/cocoapods/v/Revolver.svg\n[pod-url]: Revolver.podspec\n\n[petrmanek-url]: https://github.com/petrmanek\n[pull-requests]: https://github.com/petrmanek/Revolver/pulls\n[issue-tracker]: https://github.com/petrmanek/Revolver/issues\n[swift-2.2-branch]: https://github.com/petrmanek/Revolver/tree/swift-2.2\n\n[jazzy]: https://github.com/realm/jazzy\n[html-doc]: Revolver/Documentation\n[thesis]: https://github.com/petrmanek/mff-bachelor-thesis\n\n[example-maxone]: Examples/ExampleMaxOne\n[example-knapsack]: Examples/ExampleKnapsack\n[example-parallel]: Examples/ExampleParallel\n[example-car]: Examples/ExampleCar\n[example-qwop]: Examples/ExampleQwop\n","funding_links":[],"categories":["Machine Learning"],"sub_categories":["Other Hardware","Other free courses"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpetrmanek%2FRevolver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpetrmanek%2FRevolver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpetrmanek%2FRevolver/lists"}