{"id":37113170,"url":"https://github.com/andrew-torda/simplex","last_synced_at":"2026-01-14T13:21:44.301Z","repository":{"id":57508954,"uuid":"234528069","full_name":"andrew-torda/simplex","owner":"andrew-torda","description":"Nelder Meade simplex optimization method","archived":false,"fork":false,"pushed_at":"2020-10-05T07:58:10.000Z","size":62,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-06-20T11:55:19.221Z","etag":null,"topics":["simplex"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andrew-torda.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":"2020-01-17T10:41:20.000Z","updated_at":"2024-06-20T11:55:19.222Z","dependencies_parsed_at":"2022-09-26T17:51:43.651Z","dependency_job_id":null,"html_url":"https://github.com/andrew-torda/simplex","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/andrew-torda/simplex","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrew-torda%2Fsimplex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrew-torda%2Fsimplex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrew-torda%2Fsimplex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrew-torda%2Fsimplex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andrew-torda","download_url":"https://codeload.github.com/andrew-torda/simplex/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrew-torda%2Fsimplex/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28421087,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T10:47:48.104Z","status":"ssl_error","status_checked_at":"2026-01-14T10:46:19.031Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["simplex"],"created_at":"2026-01-14T13:21:43.501Z","updated_at":"2026-01-14T13:21:44.273Z","avatar_url":"https://github.com/andrew-torda.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# simplex\nNelder Mead simplex optimization method in go.\n\nThe basic interface is simple. You ask for a new object and then say Run. There is an absurd number of options. You can specify upper and lower bounds for parameters individually, convergence requirements for each parameter and there are two different methods for setting up the initial vertices. The most complicated option invokes a second cost function on the data each time a new best point is found. If one is doing an optimisation for some kind of fitting, you can have a standard cost function that acts on most of the data, but a second function that acts on part of the data for testing (to see recall versus generalisation or overfitting).\n\n## Introduction\n\nThere are lots of tests which give a flavour of what one should do. The example_xx_test.go files are real examples. The simplest start is to define your cost function. It takes a slice of float32's as its only argument and returns a float32 and error. A quadratic function might look like this\n\n    function cost ( x []float32) (result, error) {\n        a := x[0] - 5\n        b := x[1] - 2\n        return a * a + b * b, nil\n    }\n\nThis would have minima at `x[0] = 5` and `x[1] = 2`. It does not allow for errors, so it returns nil as the second result. \nIf you need additional arguments, you will need some kind of wrapper. Maybe you have some fixed arguments which are not to be optimized. A closure might be the best approach. There are lots of closures in the tests.\n\nYou then need to make a simplex control argument\n\n    s := NewSplxCtrl(cost, iniPrm, maxsteps)\n\nwhere `cost` is the cost function and iniPrm is a slice with initial parameters. Maybe it was set by a line like `iniPrm := []float32{10, 9}` which would set 10 and 9 as the initial values. `maxsteps` is the maximum number of steps. You then run the simplex with a line like\n\n    result, err := s.Run(2)\n\nwhich would run the simplex two times with `maxsteps` steps each time. To get to the optimized parameters, you would `fmt.Println (result.BestPrm)`. To check if convergence was reached, you might say\n\n    if result.StopReason != simplex.Converged {\n        fmt.Println(\"Did not converge\")\n    }\n\nReally, one should just `go doc -all` to see many more options.\n\n## Differences compared to literature\n\n### errors\n\nEvery time we call the cost function, we check for errors. This is a bit unusual since most peoples functions do not break. We have however had cost functions which involve opening and playing with lots of files and doing things that occasionally explode. In case of an error, it will bubble back up to the caller. Most simple numerical functions do not need this, so they can return `x, nil` instead of just `x`.\n\n### Initialisation\nThe default is to initialise as per the literature. You have a starting point and each subsequent point has a typical length added in exactly one dimension. Alternatively, you can have the simplex surround the initial point. If you have two parameters, this would be a triangle with the start point at its centre.\nFrom `go doc -all`, look for the paragraph on initialisation.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrew-torda%2Fsimplex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandrew-torda%2Fsimplex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrew-torda%2Fsimplex/lists"}