{"id":43310751,"url":"https://github.com/devries/godevo","last_synced_at":"2026-02-01T21:10:55.404Z","repository":{"id":57510156,"uuid":"148906892","full_name":"devries/godevo","owner":"devries","description":"A differential evolution and Markov chain Monte Carlo differential evolution package in Go","archived":false,"fork":false,"pushed_at":"2018-10-22T21:11:26.000Z","size":22,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-10T13:54:56.699Z","etag":null,"topics":["differential-evolution","golang","markov-chain-monte-carlo","mcmc"],"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/devries.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":"2018-09-15T14:01:11.000Z","updated_at":"2024-12-20T07:50:11.000Z","dependencies_parsed_at":"2022-09-26T16:31:07.648Z","dependency_job_id":null,"html_url":"https://github.com/devries/godevo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/devries/godevo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devries%2Fgodevo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devries%2Fgodevo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devries%2Fgodevo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devries%2Fgodevo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devries","download_url":"https://codeload.github.com/devries/godevo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devries%2Fgodevo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28991185,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-01T20:57:35.821Z","status":"ssl_error","status_checked_at":"2026-02-01T20:57:29.580Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["differential-evolution","golang","markov-chain-monte-carlo","mcmc"],"created_at":"2026-02-01T21:10:54.768Z","updated_at":"2026-02-01T21:10:55.399Z","avatar_url":"https://github.com/devries.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Differential Evolution in Go\n\n[![GoDoc](https://godoc.org/github.com/devries/godevo?status.svg)](https://godoc.org/github.com/devries/godevo)\n\n## Introduction\n\nThe differential evolution algorithm is an optimization algorithm developed by\n[Storn \u0026 Price\n(1997)](https://link.springer.com/article/10.1023%2FA%3A1008202821328). Given\na function with a set of `N` parameters, the algorithm creates a set of `NP`\nrandom solutions within a defined parameter space, and then uses the variation\namong the parameters to mutate the existing population and find better\nsolutions. Although this optimization method can be slow, it can be useful to\navoid the falling into a local minimum, and it is a simple algorithm to\nimplement and understand.\n\nDifferential Evolution can also be adapted to Markov Chain Monte Carlo methods\neasily (see [ter Braak\n2006](https://link.springer.com/article/10.1007%2Fs11222-006-8769-1)). This\npackage implements differential evolution and Markov chain Monte Carlo\ndifferential evolution in the Go programming language.\n\n## Using the library\n\nImport the library with a standard import statement.\n\n```go\nimport \"github.com/devries/godevo\"\n```\n\nNext, you need a function which takes a set of parameters as a go slice of\n`float64` numbers, and returns a value to be optimized as a `float64`. For\nexample, the function below is a parabola in two dimensions which takes a\nslice of length 2 as input and returns the parabola value.\n\n```go\nfunc parabola(vec []float64) float64 {\n        res := 3.0 + (vec[0]-1.0)*(vec[0]-1.0) + (vec[1]-2.0)*(vec[1]-2.0)\n\n        return res\n}\n```\n\nThe minimization process involves specifying the range of parameters available\nby creating a set of minimum and maximum parameter values. In the code below I\nallow the first parameter to vary between 0.0 and 2.0, and the second\nparameter to vary between 0.0 and 5.0. I choose `NP` which is the size of the\npopulation of samples to be 15 in the case below. I indicate if I want the\noptimization function to be calculated in parallel (if the function takes a\nlong time to calculate this can be a good idea, but if it is relatively quick\nto calculate, then the overhead of goroutines can slow the process down).\nFinally, I provide the function to be optimized into the `Initialize`\nfunction. I get a pointer to a `Model` as well as an `error` which will be\n`nil` if the initialization worked.\n\n```go\nminparams := []float64{0.0, 0.0}\nmaxparams := []float64{2.0, 5.0}\n\nmodel, err := godevo.Initialize(minparams, maxparams, 15, false, parabola)\nif err != nil {\n        panic(err)\n}\n```\n\nIt is possible to fine tune parameters after initialization, for example the\ncrossover constant `CR` and the weighting factor `F` can be modified on the\nmodel structure. By default `CR=0.1` and `F=0.7`.\n\n```go\nmodel.CrossoverConstant = 0.4\nmodel.WeightingFactor = 0.8\n```\n\nThe method `Step` of the receiver `*Model` performs one iteration (one\ngeneration) of the algorithm. Therefore to run through 50 generations of\nevolution, you could do the following:\n\n```go\nfor i := 0; i \u003c 50; i++ {\n        model.Step()\n}\n```\n\nAt any point you can use the `Best` method of `*Model` to get the best\nsolution and the fitness of that solution.\n\n```go\nbestParameters, bestFitness := model.Best()\n```\n\n## Markov Chain Monte Carlo\n\nThe Markov chain Monte Carlo method is very similar, but is initialized with\nthe `InitializeMCMC` function, which takes the same parameter, but sets the\noptimization function to accept solutions based on the Metropolis algorithm,\nand only evolves child generations directly from the corresponding parent\nsolution, which is required to get good statistical measurements. Generations\nare evolved using the `Step` method, but generally you want to find the mean\nvalue of the parameters and their standard deviations in this case. For that\nyou can use the `MeanStd` method of the `*Model` receiver as shown below.\n\n```go\nmeanParameters, stdevParameters := model.MeanStd()\n```\n\nThe Markov chain Monte Carlo variant should provide a population whose\ndistribution is a good statistical representation of the accuracy of the\nmodel.\n\n## Documentation\n\nDetailed documentation is available [through\ngodoc](https://godoc.org/github.com/devries/godevo). Some examples are\nincluded in the `internal` subdirectory.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevries%2Fgodevo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevries%2Fgodevo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevries%2Fgodevo/lists"}