{"id":50741417,"url":"https://github.com/squeakycheese75/evo-kit","last_synced_at":"2026-06-10T17:03:52.170Z","repository":{"id":362453286,"uuid":"1257123530","full_name":"squeakycheese75/evo-kit","owner":"squeakycheese75","description":"A lightweight, type-safe genetic algorithm toolkit for Go.","archived":false,"fork":false,"pushed_at":"2026-06-04T10:01:47.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-04T10:05:07.966Z","etag":null,"topics":["evolutionary-algorithm","generics","genetic-algorithm","go","golang","heuristics","optimization","search"],"latest_commit_sha":null,"homepage":"","language":"Go","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/squeakycheese75.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-02T11:40:34.000Z","updated_at":"2026-06-04T10:01:38.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/squeakycheese75/evo-kit","commit_stats":null,"previous_names":["squeakycheese75/evo-kit"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/squeakycheese75/evo-kit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/squeakycheese75%2Fevo-kit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/squeakycheese75%2Fevo-kit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/squeakycheese75%2Fevo-kit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/squeakycheese75%2Fevo-kit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/squeakycheese75","download_url":"https://codeload.github.com/squeakycheese75/evo-kit/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/squeakycheese75%2Fevo-kit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34161284,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-10T02:00:07.152Z","response_time":89,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["evolutionary-algorithm","generics","genetic-algorithm","go","golang","heuristics","optimization","search"],"created_at":"2026-06-10T17:03:51.140Z","updated_at":"2026-06-10T17:03:52.155Z","avatar_url":"https://github.com/squeakycheese75.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# evo-kit\n\nA lightweight, type-safe genetic algorithm toolkit for Go.\n\nEvolve solutions to optimization problems using Go generics.\n\n## Why?\n\nMany optimization problems can be expressed as:\n\n- Generate a candidate solution\n- Score how good it is\n- Mutate and combine candidates\n- Repeat until a good solution is found\n\nevo-kit handles the evolutionary loop so you can focus on the problem itself.\n\n## Features\n\n- Generic candidate types using Go generics\n- Tournament and roulette-wheel selection\n- Maximization and minimization support\n- Elitism\n- Parallel fitness evaluation with configurable workers\n- Island model evolution\n- Configurable migration between islands\n- Optional parallel island execution\n- Target score stopping\n- Stagnation-based stopping\n- Generation statistics and history tracking\n- Extensible architecture for custom evolutionary operators\n\n## Installation\n\n```bash\ngo get github.com/squeakycheese75/evo-kit\n```\n\n## Quick Example\n\n```go\nresult, err := ga.Run(ga.Config[string]{\n    PopulationSize: 100,\n    Generations:    500,\n    MutationRate:   0.1,\n    CrossoverRate:  0.7,\n    EliteCount:     2,\n\n    Generate: func(rng *rand.Rand) string {\n        return randomString(rng, len(target))\n    },\n\n    Fitness: func(candidate string) float64 {\n        return score(candidate, target)\n    },\n\n    Mutate: mutate,\n    Crossover: crossover,\n})\n\nif err != nil {\n    log.Fatal(err)\n}\n\nfmt.Printf(\"best=%q score=%.0f\\n\",\n    result.Best,\n    result.BestScore,\n)\n```\n\nExample output:\n\n```text\nbest=\"hello world\" score=11\n```\n\n## Island Evolution\n\n```go\ncfg := ga.Config[Solution]{\n    PopulationSize: 100,\n    Generations:    500,\n\n    Islands: \u0026ga.IslandConfig{\n        Count:             4,\n        MigrationInterval: 25,\n        MigrationCount:    2,\n        Parallel:          true,\n    },\n\n    Generate:  generate,\n    Fitness:   fitness,\n    Mutate:    mutate,\n    Crossover: crossover,\n}\n\nresult, err := ga.Run(cfg)\n```\n\n## Included Examples\n\n| Example | Description |\n|----------|-------------|\n| string_match | Evolve a string until it matches a target |\n| string_match_islands | Evolve a string using island-model evolution |\n| knapsack | Maximize value within a weight constraint |\n| query_plan | Optimize execution order and parallelism |\n\nRun an example:\n\n```bash\ngo run ./examples/query_plan\n```\n\nExample output:\n\n```text\ngen=0 cost=9522.53\ngen=31 cost=7645.53\n\nbest cost: 7645.53\nimprovement: 19.71%\nstop reason: stagnated\n```\n\nRun the island example:\n\n```bash\ngo run ./examples/string_match_islands\n```\n\n## Configuration\n\n```go\ncfg := ga.Config[Candidate]{\n    PopulationSize: 200,\n    Generations:    500,\n\n    MutationRate:   0.1,\n    CrossoverRate:  0.7,\n\n    EliteCount:     2,\n\n    Direction:      ga.Minimize,\n\n    MaxStagnation:  50,\n\n    Workers:        runtime.NumCPU(),\n}\n```\n\n## Parallel Fitness Evaluation\n\nFitness evaluation can be parallelised with `Workers`.\n\n```go\ncfg := ga.Config[Candidate]{\n    PopulationSize: 500,\n    Generations:    200,\n    Workers:        runtime.NumCPU(),\n\n    Generate:  generate,\n    Fitness:   expensiveFitness,\n    Mutate:    mutate,\n    Crossover: crossover,\n}\n```\n\nA value of `0` or `1` scores candidates sequentially.\n\nWhen `Workers \u003e 1`, the fitness function must be safe to call concurrently.\n\nTypical scaling for expensive fitness functions:\n\n| Workers | Time |\n|----------|------|\n| 1 | 1.18s |\n| 2 | 590ms |\n| 4 | 296ms |\n| 8 | 154ms |\n\n## When should I use a genetic algorithm?\n\nGenetic algorithms work well when:\n\n- Exhaustive search is too expensive\n- The search space is large\n- An approximate solution is acceptable\n- The fitness function is easy to evaluate\n\nExamples include scheduling, routing, portfolio optimization, query planning, game AI, and parameter tuning.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsqueakycheese75%2Fevo-kit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsqueakycheese75%2Fevo-kit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsqueakycheese75%2Fevo-kit/lists"}