https://github.com/erp12/ga-clj
No-assumptions genetic algorithms in Clojure
https://github.com/erp12/ga-clj
Last synced: 3 months ago
JSON representation
No-assumptions genetic algorithms in Clojure
- Host: GitHub
- URL: https://github.com/erp12/ga-clj
- Owner: erp12
- License: mit
- Created: 2021-11-24T16:39:48.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2023-02-02T18:56:39.000Z (almost 3 years ago)
- Last Synced: 2025-04-11T14:25:19.946Z (9 months ago)
- Language: Clojure
- Size: 46.9 KB
- Stars: 5
- Watchers: 4
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# GA-CLJ
A genetic algorithm framework in Clojure that makes minimal assumptions.
## Rationale
@todo write me!
Outline
- prior art
- Clojush, Propeller, link to lspector Conj talk. Maybe link to famous PushGP uses (quantum, finite algebra)
- Coupled to PushGP.
- Other JVM tools: ECJ, jenetics, etc.
- Other tools make assumptions about genome/phenome structures.
- Not easily extended via interop.
- Decoupling from assumptions
- Genomes can be any data.
- Individuals are open maps that hold genomes, errors, and anything else the user wants to add to them.
- "breeding" new genomes is done via a user supplied function.
- Solving common issues
- Ensure same, well tested, implementations of common algorithms. (aka toolbox)
- Difficult to debug evolution because it is random.
- GA-CLJ enhances exceptions with additional data (for example, the genome that caused the problem.)
## Installation
We recommend declaring your ga-clj dependency using git coordinates. Add the following to your `deps.edn`.
```clojure
;; Add to
{io.github.erp12/ga-clj {:git/tag "v0.0.2" :git/sha "e3c764dg"}}
```
In the future, we may also publish releases to Clojars.
## Guide
Currently, ga-clj only supports generational genetic algorithms.
### Terminology
- `genome-factory`: A nullary function for creating random genomes.
- `genome->individual`: A function from genome to an "individual" map containing additional data used to drive breeding.
Often this map contains the errors/fitness associated with the genome but could also contain any other values.
- `breed`: A function that takes the current population of individuals and maybe other data about the state of evolution
and returns a new child genome. Often this function will perform parent selection and variation operators.
The `erp12.ga-clj.toolbox` namespace provides implementations of commonly used algorithms that will likely be useful
to call in breed functions.
Additional terminology and configuration parameters can be found in the docstring of `evolve` functions found
in namespaces that provide a specific kind of genetic algorithm. For example:
- `erp12.ga-clj.generational/evolve`
## Examples
See the `examples/` directory. You can run the examples on the command line. For example:
```text
clj -M:examples -m erp12.ga-clj.examples.alphabet
```
Change the namespace in the command to run a different example.
## Contributing
See the `CONTRIBUTING.md` for more information, including how to run tests.
## To-Do before "official" release
- Fill out the toolbox with other common error functions, selection methods, and variation operators.
- Add more examples that test the design/abstraction in a wider range of scenarios.
- TSP?
- Knapsack problem?
- Rationale and Guide