Name | msopt JSON |
Version |
0.0.8
JSON |
| download |
home_page | None |
Summary | A mip model framework like gurobi, make write lp and mip easy, and support gurobi, cbc, highs solver. |
upload_time | 2024-07-28 02:07:01 |
maintainer | None |
docs_url | None |
author | allen |
requires_python | >=3.11 |
license | None |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Using gurobi syntax for MIP modeling
The syntax of gurobi is very traversal for mip modeling, but the syntax of some open-source solvers and their corresponding API interfaces often uses the conventional naming convention of Python, which is inconvenient for programming with complex constraints.
Therefore, I developed a Python library called gurobi2, which encapsulates commonly used objects such as variable sets, create constraints, constraint sets, and large M methods, and provides a programming experience consistent with gurobipy. I hope to improve the efficiency and experience of programming through this.
For specific API usage, please refer to the official documentation of Gurobi: https://www.gurobi.com/documentation/current/refman/index.html
Here is an example:
```python
from msopt.api import Model, Param, INF, quicksum
m = Model("example", "CBC")
x = m.addVars([1,2,3], vtype="C", name="x")
y = m.addVars([1,2,3], vtype="B", name="y")
z = m.addVars([1,2,3], vtype="I", name="z")
m.addConstr(x.sum() == 1, name="c1")
m.addConstr(y.sum() >= 1, name="c2")
m.addConstr(z[1] == 1, name="c3")
objective = quicksum(x[i] for i in [1,2,3])
m.setObjective(objective, "maximize")
m.setParam(Param.TimeLimit, 10)
m.setParam(Param.MIPGap, 0.01)
m.optimize()
print("status: ", m.status)
print("Objective value: ", m.objVal)
print("x: ", x[1].x, x[2].x, x[3].x)
print("y: ", y[1].x, y[2].x, y[3].x)
print("z: ", z[1].x, z[2].x, z[3].x)
```
Raw data
{
"_id": null,
"home_page": null,
"name": "msopt",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.11",
"maintainer_email": null,
"keywords": null,
"author": "allen",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/81/76/d98349cdc6f79e6a12ca84079964605fb56af87b362e302e219e6cf16c3e/msopt-0.0.8.tar.gz",
"platform": null,
"description": "# Using gurobi syntax for MIP modeling\n\nThe syntax of gurobi is very traversal for mip modeling, but the syntax of some open-source solvers and their corresponding API interfaces often uses the conventional naming convention of Python, which is inconvenient for programming with complex constraints.\n\nTherefore, I developed a Python library called gurobi2, which encapsulates commonly used objects such as variable sets, create constraints, constraint sets, and large M methods, and provides a programming experience consistent with gurobipy. I hope to improve the efficiency and experience of programming through this.\n\nFor specific API usage, please refer to the official documentation of Gurobi: https://www.gurobi.com/documentation/current/refman/index.html\n\nHere is an example:\n\n```python\n\nfrom msopt.api import Model, Param, INF, quicksum\n\n\nm = Model(\"example\", \"CBC\")\n\nx = m.addVars([1,2,3], vtype=\"C\", name=\"x\")\ny = m.addVars([1,2,3], vtype=\"B\", name=\"y\")\nz = m.addVars([1,2,3], vtype=\"I\", name=\"z\")\n\nm.addConstr(x.sum() == 1, name=\"c1\")\nm.addConstr(y.sum() >= 1, name=\"c2\")\nm.addConstr(z[1] == 1, name=\"c3\")\n\nobjective = quicksum(x[i] for i in [1,2,3])\nm.setObjective(objective, \"maximize\")\n\nm.setParam(Param.TimeLimit, 10)\nm.setParam(Param.MIPGap, 0.01)\nm.optimize()\n\nprint(\"status: \", m.status)\nprint(\"Objective value: \", m.objVal)\nprint(\"x: \", x[1].x, x[2].x, x[3].x)\nprint(\"y: \", y[1].x, y[2].x, y[3].x)\nprint(\"z: \", z[1].x, z[2].x, z[3].x)\n\n```",
"bugtrack_url": null,
"license": null,
"summary": "A mip model framework like gurobi, make write lp and mip easy, and support gurobi, cbc, highs solver.",
"version": "0.0.8",
"project_urls": {
"Homepage": "https://github.com/pypa/sampleproject",
"Issues": "https://github.com/pypa/sampleproject/issues"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b3946e878c4fe386d06d6069806d6602740dd264424e06c99f28aa5b6d07e35d",
"md5": "552199ad3e623d43de4d5c01fd3a8ba4",
"sha256": "35632ee08c0ca1dd189ff5ee1471d5275e1df2b58d6d96d03bd1670953d7dd9e"
},
"downloads": -1,
"filename": "msopt-0.0.8-py3-none-any.whl",
"has_sig": false,
"md5_digest": "552199ad3e623d43de4d5c01fd3a8ba4",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.11",
"size": 1031769,
"upload_time": "2024-07-28T02:06:59",
"upload_time_iso_8601": "2024-07-28T02:06:59.155994Z",
"url": "https://files.pythonhosted.org/packages/b3/94/6e878c4fe386d06d6069806d6602740dd264424e06c99f28aa5b6d07e35d/msopt-0.0.8-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8176d98349cdc6f79e6a12ca84079964605fb56af87b362e302e219e6cf16c3e",
"md5": "6acbfa51684c6f701aa040bb2b064fcb",
"sha256": "ba4c4e8ca632bffe5e51d5914036344d51924f52e26a5cf7d2d34b7972e2aba8"
},
"downloads": -1,
"filename": "msopt-0.0.8.tar.gz",
"has_sig": false,
"md5_digest": "6acbfa51684c6f701aa040bb2b064fcb",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.11",
"size": 1027289,
"upload_time": "2024-07-28T02:07:01",
"upload_time_iso_8601": "2024-07-28T02:07:01.895003Z",
"url": "https://files.pythonhosted.org/packages/81/76/d98349cdc6f79e6a12ca84079964605fb56af87b362e302e219e6cf16c3e/msopt-0.0.8.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-28 02:07:01",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "pypa",
"github_project": "sampleproject",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "msopt"
}