{"id":37148476,"url":"https://github.com/biotinker/nlopt","last_synced_at":"2026-01-14T17:32:12.766Z","repository":{"id":57568394,"uuid":"342731907","full_name":"biotinker/nlopt","owner":"biotinker","description":"A NLopt implementation for Go","archived":false,"fork":true,"pushed_at":"2021-03-01T19:21:43.000Z","size":33,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-06-20T17:53:54.110Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"go-nlopt/nlopt","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/biotinker.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":"2021-02-27T00:05:59.000Z","updated_at":"2021-03-01T19:21:45.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/biotinker/nlopt","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/biotinker/nlopt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/biotinker%2Fnlopt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/biotinker%2Fnlopt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/biotinker%2Fnlopt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/biotinker%2Fnlopt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/biotinker","download_url":"https://codeload.github.com/biotinker/nlopt/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/biotinker%2Fnlopt/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28428306,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T16:38:47.836Z","status":"ssl_error","status_checked_at":"2026-01-14T16:34:59.695Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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":[],"created_at":"2026-01-14T17:32:12.054Z","updated_at":"2026-01-14T17:32:12.757Z","avatar_url":"https://github.com/biotinker.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"A NLopt implementation for Go\n======\n\nA package to provide functionality of object-oriented C-API of [NLopt](http://ab-initio.mit.edu/wiki/index.php/Main_Page) \nfor the Go programming language (http://golang.org). This provides a wrapper \nusing cgo to a c-based implementation.\n\n\n## Status\n\n[![Build Status](https://travis-ci.org/go-nlopt/nlopt.svg?branch=master)](https://travis-ci.org/go-nlopt/nlopt) [![Coverage Status](https://coveralls.io/repos/github/go-nlopt/nlopt/badge.svg?branch=master)](https://coveralls.io/github/go-nlopt/nlopt?branch=master) [![GoDoc](https://godoc.org/github.com/go-nlopt/nlopt?status.svg)](https://godoc.org/github.com/go-nlopt/nlopt)\n\n\n## Installation\n\n- On RedHat/CentOS/Fedora\n\n~~~shell script\nyum/dnf -y install nlopt-devel\n~~~\n\n- On Ubuntu (14.04+)\n\n~~~shell script\napt-get install -y libnlopt-dev\n~~~\n\n- or, install NLopt library on any Unix-like system (GNU/Linux is fine) with a \n  C compiler, using the standard procedure:\n\n~~~shell script\ncurl -O https://codeload.github.com/stevengj/nlopt/tar.gz/v2.7.0 \u0026\u0026 tar xzvf v2.7.0 \u0026\u0026 cd nlopt-2.7.0\ncmake . \u0026\u0026 make \u0026\u0026 sudo make install\n~~~\n\n- On Windows download binary packages at [NLopt on Windows](http://ab-initio.mit.edu/wiki/index.php/NLopt_on_Windows)\n\nIf you use pre-packaged binaries, you might want to either make symlink or a copy of `libnlopt-0.dll` library\nfile as `libnlopt.dll`, e.g.:\n\n~~~shell script\nmklink libnlopt.dll libnlopt-0.dll\n~~~\n\nIf the C++ library is in a non-standard directory, or you are using Windows, \nmake sure to export `LIBRARY_PATH` environment variable, e.g.:\n\n~~~shell script\nexport LIBRARY_PATH=/path/to/NLopt\n~~~\n\nor, on Windows:\n\n~~~shell script\nset LIBRARY_PATH=C:\\path\\to\\NLopt\n~~~\n\n\nThen install `nlopt` package. \n\n~~~shell script\ngo get -u github.com/go-nlopt/nlopt\n~~~\n\n\n## Examples\n\nImplementation of nonlinearly constrained problem from [NLopt Tutorial](http://ab-initio.mit.edu/wiki/index.php/NLopt_Tutorial)\n\n~~~go\npackage main\n\nimport (\n        \"fmt\"\n        \"github.com/go-nlopt/nlopt\"\n        \"math\"\n)\n\nfunc main() {\n        opt, err := nlopt.NewNLopt(nlopt.LD_MMA, 2)\n        if err != nil {\n                panic(err)\n        }\n        defer opt.Destroy()\n\n        opt.SetLowerBounds([]float64{math.Inf(-1), 0.})\n\n        var evals int\n        myfunc := func(x, gradient []float64) float64 {\n                evals++\n                if len(gradient) \u003e 0 {\n                        gradient[0] = 0.0\n                        gradient[1] = 0.5 / math.Sqrt(x[1])\n                }\n                return math.Sqrt(x[1])\n        }\n        \n        myconstraint := func(x, gradient []float64, a, b float64) float64 {\n                if len(gradient) \u003e 0 {\n                        gradient[0] = 3*a* math.Pow(a*x[0]+b, 2.)\n                        gradient[1] = -1.0\n                }\n                return math.Pow(a*x[0]+b, 3) - x[1]\n        }\n\n        opt.SetMinObjective(myfunc)\n        opt.AddInequalityConstraint(func(x, gradient []float64) float64 { return myconstraint(x, gradient, 2., 0.)}, 1e-8)\n        opt.AddInequalityConstraint(func(x, gradient []float64) float64 { return myconstraint(x, gradient, -1., 1.)}, 1e-8)\n        opt.SetXtolRel(1e-4)\n\n        x := []float64{1.234, 5.678}\n        xopt, minf, err := opt.Optimize(x)\n        if err != nil {\n                panic(err)\n        }\n        fmt.Printf(\"found minimum after %d evaluations at f(%g,%g) = %0.10g\\n\", evals, xopt[0], xopt[1], minf)\n}\n~~~\n\nImplementation of [Nonlinear Least Squares Without Jacobian](https://uk.mathworks.com/help/optim/ug/nonlinear-least-squares-with-full-jacobian.html)\n\n~~~go\npackage main\n\nimport (\n        \"fmt\"\n        \"github.com/go-nlopt/nlopt\"\n        \"math\"\n)\n\nfunc main() {\n        opt, err := nlopt.NewNLopt(nlopt.LN_BOBYQA, 2)\n        if err != nil {\n                panic(err)\n        }\n        defer opt.Destroy()\n\n        k := []float64{1., 2., 3., 4., 5., 6., 7., 8., 9., 10.}\n        \n        var evals int\n        myfun := func(x, gradient []float64) float64 {\n                evals++\n                f := make([]float64, len(k))\n                for i := 0; i \u003c len(k); i++ {\n                        f[i] = 2 + 2*k[i] - math.Exp(k[i]*x[0]) - math.Exp(k[i]*x[1])\n                }\n                var chi2 float64\n                for i := 0; i \u003c len(f); i++ {\n                        chi2 += (f[i] * f[i])\n                }\n                return chi2\n        }\n                  \n        opt.SetMinObjective(myfun)\n        opt.SetXtolRel(1e-8)\n        opt.SetFtolRel(1e-8)\n\n        x := []float64{0.3, 0.4}\n        xopt, resnorm, err := opt.Optimize(x)\n        if err != nil {\n                panic(err)\n        }\n        fmt.Printf(\"BOBYQA: found minimum after %d evaluations at f(%g,%g) = %0.10g\\n\", evals, xopt[0], xopt[1], resnorm)\n}\n~~~\n\n## License\n\nMIT - see LICENSE for more details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbiotinker%2Fnlopt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbiotinker%2Fnlopt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbiotinker%2Fnlopt/lists"}