{"id":18359521,"url":"https://github.com/irzinfante/fixed-mps","last_synced_at":"2025-04-10T03:23:46.529Z","repository":{"id":59606694,"uuid":"268352880","full_name":"irzinfante/fixed-mps","owner":"irzinfante","description":"Library to easily generate fixed MPS files for LP solvers","archived":false,"fork":false,"pushed_at":"2024-09-02T21:30:23.000Z","size":66,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-15T18:50:14.927Z","etag":null,"topics":["constraints","fixed-mps","linear-programming","linear-programming-modeler","lp","lp-problem","math","mps","operations-research","optimization"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/irzinfante.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":"2020-05-31T19:51:24.000Z","updated_at":"2024-09-02T21:28:16.000Z","dependencies_parsed_at":"2024-11-05T22:28:14.351Z","dependency_job_id":"2086de04-db39-46bd-8365-eace56d66a8c","html_url":"https://github.com/irzinfante/fixed-mps","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/irzinfante%2Ffixed-mps","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/irzinfante%2Ffixed-mps/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/irzinfante%2Ffixed-mps/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/irzinfante%2Ffixed-mps/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/irzinfante","download_url":"https://codeload.github.com/irzinfante/fixed-mps/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248149276,"owners_count":21055741,"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":["constraints","fixed-mps","linear-programming","linear-programming-modeler","lp","lp-problem","math","mps","operations-research","optimization"],"created_at":"2024-11-05T22:23:08.287Z","updated_at":"2025-04-10T03:23:46.502Z","avatar_url":"https://github.com/irzinfante.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Usage of the library\nLet's put it simple. Having the following linear programming (LP) problem,\n\n\u003cimg src=\"https://latex.codecogs.com/gif.latex?\\newline%20min%20\\;%20Z%20=%20-X_1%20-%20X_2\\newline%20\\;%20-2X_1%20+%202X_2%20\\ge%201\\newline%20-8X_1%20+%2010X_2\\le%2013\\newline%20X_1,%20X_2%20\\ge%200,\\;%20X_1,%20X_2%20\\in%20\\mathbb{Z}\"\u003e\n\nour goal is to generate, in the most simple and intuitive way, a fixed-format MPS file representing the problem.\n\nWe import the ``fixed-mps`` library from Maven with\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003edev.irzinfante\u003c/groupId\u003e\n    \u003cartifactId\u003efixed-mps\u003c/artifactId\u003e\n    \u003cversion\u003e2.0.2\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nNow, the instruction for building the LP problem is the following:\n\n```java\nimport dev.irzinfante.fixedmps.core.Problem;\nimport dev.irzinfante.fixedmps.core.Problem.ProblemBuilder;\nimport dev.irzinfante.fixedmps.core.Variable.VarBuilder;\nimport dev.irzinfante.fixedmps.core.Constraint.ConstraintBuilder;\n\nProblem lp = new ProblemBuilder(\n\n\tnew VarBuilder(-1).lowerBound(0).upperBound(Double.MAX_VALUE).integer().build(),\n\tnew VarBuilder(-1).lowerBound(0).upperBound(Double.MAX_VALUE).integer().build()\n\n)\n.addConstraint(new ConstraintBuilder(-2,  2).greaterThan(1))\n.addConstraint(new ConstraintBuilder(-8, 10).lessThan(13))\n.build();\n```\n\nAs we can see, the coefficient for each variable in the objective function is given at the time of declaring the variable. We tell also at this point if the variable is integer or binary (or we just build the variable to tell that it is a real).\n\nThen we add the constraints for the problem row by row, giving the coeffient for each variable in order, an telling the type of the constraint (\u003cimg src=\"https://latex.codecogs.com/gif.latex?\\le\"\u003e, \u003cimg src=\"https://latex.codecogs.com/gif.latex?\\ge\"\u003e or \u003cimg src=\"https://latex.codecogs.com/gif.latex?=\"\u003e) and the value of the free term.\n\nNow, to get the MPS file (as a String) from the problem we do this:\n```java\nimport dev.irzinfante.fixedmps.util.MPSUtil;\n\nMPSUtil.obtainMPSfile(lp)\n```\nThe result in this case would be:\n```fortran\nNAME          FIXEDMPS\nROWS\n N  OBJ\n G  C0000001\n L  C0000002\nCOLUMNS\n    INT1      'MARKER'                 'INTORG'\n    X0000001  C0000002  -8.00000e+00   C0000001  -2.00000e+00\n    X0000001  OBJ       -1.00000e+00\n    X0000002  C0000002  +1.00000e+01   C0000001  +2.00000e+00\n    X0000002  OBJ       -1.00000e+00\n    INT1END   'MARKER'                 'INTEND'\nRHS\n    RHS1      C0000001  +1.00000e+00\n    RHS1      C0000002  +1.30000e+01\nBOUNDS\n UP BND1      X0000001  +1.00000e+10\n UP BND1      X0000002  +1.00000e+10\nENDATA\n```\n\n## License\n\nCopyright (C) 2020-2024 Iker Ruiz de Infante Gonzalez iker@irzinfante.dev\n\nThis program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.\n\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more details.\n\nYou should have received a copy of the GNU Affero General Public License along with this program.  If not, see \u003chttps://www.gnu.org/licenses/\u003e.\n\n[LICENSE](LICENSE) contains a copy of the full AGPLv3 licensing conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Firzinfante%2Ffixed-mps","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Firzinfante%2Ffixed-mps","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Firzinfante%2Ffixed-mps/lists"}