Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/okabe-junya/gago
is a simple genetic algorithm library written in go
https://github.com/okabe-junya/gago
genetic-algorithm golang
Last synced: about 1 month ago
JSON representation
is a simple genetic algorithm library written in go
- Host: GitHub
- URL: https://github.com/okabe-junya/gago
- Owner: Okabe-Junya
- License: mit
- Created: 2024-07-20T18:01:46.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-07-21T14:25:34.000Z (7 months ago)
- Last Synced: 2024-11-09T11:08:44.922Z (3 months ago)
- Topics: genetic-algorithm, golang
- Language: Go
- Homepage:
- Size: 26.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# GAGO: Simple Genetic Algorithm Library written in Go
[![Test](https://github.com/Okabe-Junya/gago/actions/workflows/test.yml/badge.svg)](https://github.com/Okabe-Junya/gago/actions/workflows/test.yml) [![CodeQL](https://github.com/Okabe-Junya/gago/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/Okabe-Junya/gago/actions/workflows/github-code-scanning/codeql) [![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) [![Go Report Card](https://goreportcard.com/badge/github.com/Okabe-Junya/gago)](https://goreportcard.com/report/github.com/Okabe-Junya/gago) [![Go Reference](https://pkg.go.dev/badge/github.com/Okabe-Junya/gago.svg)](https://pkg.go.dev/github.com/Okabe-Junya/gago)
## Overview
**GAGO** is a go library for implementing genetic algorithms. The library is designed to be flexible and extensible, allowing users to define their own selection, crossover, and mutation functions.
## Installation
```bash
go get -u github.com/Okabe-Junya/gago
```## Usage
See the [examples](./examples/) directory for more details. The following is a simple example of how to use the library.
> [!NOTE]
> You need to define some functions to use this example.```go
func main() {
gaInstance := &ga.GA{
Selection: func(population []*ga.Individual) []*ga.Individual { return ga.TournamentSelection(population, 3) },
Crossover: ga.SinglePointCrossover,
Mutation: ga.BitFlipMutation,
CrossoverRate: crossoverRate,
MutationRate: mutationRate,
Generations: generations,
EnableLogger: true,
}gaInstance.Initialize(populationSize, initializeGenotype, evaluatePhenotype)
gaInstance.Evolve(evaluatePhenotype)bestIndividual := findBestIndividual(gaInstance.Population)
bestX := decodeGenotype(bestIndividual.Genotype)fmt.Printf("Best x: %f, Fitness: %f\n", bestX, bestIndividual.Phenotype.Fitness)
}
```## License
This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.