{"id":28072480,"url":"https://github.com/chriso345/gspl","last_synced_at":"2025-08-21T01:04:20.429Z","repository":{"id":256504441,"uuid":"838597427","full_name":"ChrisO345/gspl","owner":"ChrisO345","description":"Gospel - A Go Simplex Programming Library","archived":false,"fork":false,"pushed_at":"2025-04-30T03:25:13.000Z","size":33,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-12T21:09:48.814Z","etag":null,"topics":["linear-algebra","linear-programming","simplex"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/chriso345/gspl","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/ChrisO345.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}},"created_at":"2024-08-06T01:28:54.000Z","updated_at":"2025-04-30T12:09:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"4e21747e-1f5e-4479-a2f3-f5d07a64ca7f","html_url":"https://github.com/ChrisO345/gspl","commit_stats":null,"previous_names":["chriso345/gulp"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChrisO345%2Fgspl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChrisO345%2Fgspl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChrisO345%2Fgspl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChrisO345%2Fgspl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ChrisO345","download_url":"https://codeload.github.com/ChrisO345/gspl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253823453,"owners_count":21969848,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["linear-algebra","linear-programming","simplex"],"created_at":"2025-05-12T21:09:52.156Z","updated_at":"2025-08-21T01:04:20.415Z","avatar_url":"https://github.com/ChrisO345.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gspl\n\n**gspl** (short for **Go Simplex Programming Library**, pronounced *gospel*) is a lightweight solver for linear programming problems, built in Go using the revised simplex method. It emphasizes clarity, performance, and seamless integration into Go applications.\n\n---\n\n## Features\n\n* Solves optimal, unbounded, infeasible, and degenerate linear problems.\n* Implements an efficient revised simplex algorithm.\n* Clean and idiomatic API for modeling and solving LPs.\n* Focused on numerical stability and usability.\n\n`gspl` is ideal for embedding linear optimization into Go-based software.\n\n---\n\n## Installation\n\nEnsure you have Go installed, then run:\n\n```bash\ngo get github.com/chriso345/gspl\n```\n\n---\n\n## Usage\n\nHere's how to define and solve a basic linear programming problem with **gspl**:\n\n```go\npackage main\n\nimport (\n\t\"github.com/chriso345/gspl/lp\"\n\t\"github.com/chriso345/gspl/solver\"\n)\n\nfunc main() {\n\t// Create decision variables\n\tvariables := []lp.LpVariable{\n\t\tlp.NewVariable(\"x1\"),\n\t\tlp.NewVariable(\"x2\"),\n\t\tlp.NewVariable(\"x3\"),\n\t}\n\n\tx1 := \u0026variables[0]\n\tx2 := \u0026variables[1]\n\tx3 := \u0026variables[2]\n\n\t// Objective function: Minimize -6 * x1 + 7 * x2 + 4 * x3\n\tobjective := lp.NewExpression([]lp.LpTerm{\n\t\tlp.NewTerm(-6, *x1),\n\t\tlp.NewTerm(7, *x2),\n\t\tlp.NewTerm(4, *x3),\n\t})\n\n\t// Set up the LP problem\n\texample := lp.NewLinearProgram(\"README Example\", variables)\n\texample.AddObjective(lp.LpMinimise, objective)\n\n\t// Add constraints\n\texample.AddConstraint(lp.NewExpression([]lp.LpTerm{\n\t\tlp.NewTerm(2, *x1),\n\t\tlp.NewTerm(5, *x2),\n\t\tlp.NewTerm(-1, *x3),\n\t}), lp.LpConstraintLE, 18)\n\n\texample.AddConstraint(lp.NewExpression([]lp.LpTerm{\n\t\tlp.NewTerm(1, *x1),\n\t\tlp.NewTerm(-1, *x2),\n\t\tlp.NewTerm(-2, *x3),\n\t}), lp.LpConstraintLE, -14)\n\n\texample.AddConstraint(lp.NewExpression([]lp.LpTerm{\n\t\tlp.NewTerm(3, *x1),\n\t\tlp.NewTerm(2, *x2),\n\t\tlp.NewTerm(2, *x3),\n\t}), lp.LpConstraintEQ, 26)\n\n\t// Solve it\n\tsolver.Solve(\u0026example).PrintSolution()\n}\n```\n\n### What’s Happening?\n\nWe’re setting up a linear program to:\n\n1. **Minimize**:\n   $-6x_1 + 7x_2 + 4x_3$\n2. **Subject to constraints**:\n\n   * $2x_1 + 5x_2 - x_3 \\leq 18$\n   * $x_1 - x_2 - 2x_3 \\leq -14$\n   * $3x_1 + 2x_2 + 2x_3 = 26$\n\nThe solution will print the optimal values of the variables and the minimized objective value.\n\nSee the [examples](examples) directory for other scenarios.\n\n---\n\n## API Overview\n\n### Variables\n\nCreate decision variables as a slice:\n\n```go\nvariables := []lp.LpVariable{\n    lp.NewVariable(\"x1\"),\n    lp.NewVariable(\"x2\"),\n}\n```\n\nYou can access and pass them as pointers:\n\n```go\nx1 := \u0026variables[0]\n```\n\n### Objective Function\n\nBuild the objective using terms:\n\n```go\nobjective := lp.NewExpression([]lp.LpTerm{\n    lp.NewTerm(5, *x1),\n    lp.NewTerm(3, *x2),\n})\n```\n\nAdd it to the LP:\n\n```go\nlp := lp.NewLinearProgram(\"My LP\", variables)\nlp.AddObjective(lp.LpMaximise, objective)\n```\n\n### Constraints\n\nEach constraint uses an expression, a comparison type, and a right-hand side:\n\n```go\nlp.AddConstraint(lp.NewExpression([]lp.LpTerm{\n    lp.NewTerm(2, *x1),\n    lp.NewTerm(3, *x2),\n}), lp.LpConstraintLE, 10)\n```\n\nConstraint types:\n\n* `gspl.LpConstraintLE` - less than or equal\n* `gspl.LpConstraintGE` - greater than or equal\n* `gspl.LpConstraintEQ` - equality\n\n### Solving\n\n```go\nsolution := solver.Solve(\u0026lp)\nsolution.PrintSolution()\n```\n\nThis solves the model and prints variable values and the objective result.\n\n---\n\n## License\n\nLicensed under the MIT License. See the [LICENSE](LICENSE) file for more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchriso345%2Fgspl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchriso345%2Fgspl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchriso345%2Fgspl/lists"}