{"id":48496402,"url":"https://github.com/cog-imperial/romodel","last_synced_at":"2026-04-07T12:30:39.596Z","repository":{"id":44916426,"uuid":"293533155","full_name":"cog-imperial/romodel","owner":"cog-imperial","description":"Modeling robust optimization problems in Pyomo","archived":false,"fork":false,"pushed_at":"2022-11-11T10:48:14.000Z","size":165,"stargazers_count":88,"open_issues_count":3,"forks_count":19,"subscribers_count":8,"default_branch":"master","last_synced_at":"2026-01-27T07:51:32.204Z","etag":null,"topics":["pyomo","robust-optimization"],"latest_commit_sha":null,"homepage":"","language":"Python","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/cog-imperial.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-09-07T13:17:14.000Z","updated_at":"2026-01-03T11:47:53.000Z","dependencies_parsed_at":"2023-01-21T15:02:18.493Z","dependency_job_id":null,"html_url":"https://github.com/cog-imperial/romodel","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/cog-imperial/romodel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cog-imperial%2Fromodel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cog-imperial%2Fromodel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cog-imperial%2Fromodel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cog-imperial%2Fromodel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cog-imperial","download_url":"https://codeload.github.com/cog-imperial/romodel/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cog-imperial%2Fromodel/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31513375,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-07T03:10:19.677Z","status":"ssl_error","status_checked_at":"2026-04-07T03:10:13.982Z","response_time":105,"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":["pyomo","robust-optimization"],"created_at":"2026-04-07T12:30:38.713Z","updated_at":"2026-04-07T12:30:39.590Z","avatar_url":"https://github.com/cog-imperial.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ROmodel\n\nROmodel is a Python package which extends the modeling capabilities of\n[Pyomo](https://github.com/Pyomo/pyomo) to robust optimization problems. It\nalso implements a number of algorithms for solving these problems.\n\n## Install\n\nTo install ROmodel use:\n\n```bash        \npip install git+https://github.com/cog-imperial/romodel.git\n```\n\n## Getting started \n\nThis introduction assumes basic familiarity with modeling optimization problems\nin Pyomo. ROmodel introduces three main components for modeling robust optimization\nproblems:\n\n1. `UncSet` for modeling uncertainty sets\n2. `UncParam` for modeling uncertain parameters \n3. `AdjustableVar` for modeling adjustable variables in adjustable robust\n   optimization problems\n\nTo start using ROmodel, import Pyomo and ROmodel:\n\n```python\nimport pyomo.environ as pe\nimport romodel as ro\n```\n\nCreate a Pyomo model (ROmodel is currently only tested with Pyomo's `ConcreteModel`) and\nsome variables:\n\n```python\nm = pe.ConcreteModel()\n# Create an indexed variable\nm.x = pe.Var([0, 1])\n```\n\nNext, create an uncertainty set. Uncertainty sets can be created in one of two\nways: \n\n1. Using generic Pyomo constraints.\n2. Choosing from a library of commonly used geometries.\n\n### Generic uncertainty sets\n\nTo create a generic uncertainty set use the `UncSet` class. This class inherits\nfrom Pyomo's `Block` class and can be used similarly. To define the uncertainty\nset simply add constraints to the `UncSet` object:\n\n```python\n# Create a generic uncertainty set\nm.uncset = ro.UncSet()\n# Create an indexed uncertain parameter\nm.w = ro.UncParam([0, 1], uncset=m.uncset, nominal=[0.5, 0.8])\n# Add constraints to the uncertainty set\nm.uncset.cons1 = pe.Constraint(m.w[0] + m.w[1] \u003c= 1.5)\nm.uncset.cons2 = pe.Constraint(m.w[0] - m.w[1] \u003c= 1.5)\n```\n\n### Library uncertainty sets\n\nROmodel currently implements library versions of polyhedral uncertainty sets\n(`P*w \u003c= d`), ellipsoidal sets (`(w - mu)^T Cov^-1 (w - mu) \u003c= r^2`), and\n(warped) Gaussian process-based uncertainty sets (see our [paper](https://arxiv.org/abs/2006.08222) for more details).\n\nPolyhedral sets can be constructed using their matrix representation with the\n`PolyhedralSet` class:\n\n```python\nfrom romodel.uncset import PolyhedralSet\n# Define polyhedral set\nm.uncset = PolyhedralSet(mat=[[ 1,  1],\n                              [ 1, -1],\n                              [-1,  1],\n                              [-1, -1]],\n                         rhs=[1, 1, 1, 1])\n```\n\nSimilarly, ellipsoidal sets can be constructed from a covariance matrix and a\nmean vector using the `EllipsoidalSet` class:\n\n```python\nfrom romodel.uncset import EllipsoidalSet\n# Define ellipsoidal set\nm.uncset = EllipsoidalSet(cov=[[1, 0, 0],\n                               [0, 1, 0],\n                               [0, 0, 1]],\n                          mean=[0.5, 0.3, 0.1])\n```\n\n\n### Creating uncertain parameters and constraints\n\nUncertain parameters can be created using the `UncParam` class. They are\nsimilar to Pyomo's `Param` modeling object and take a `nominal` argument, which\nspecifies the nominal values, and an `uncset` object, which specifies which\nuncertainty set to use.  Uncertain constraints (or objectives) are created\nimplicitly by using uncertain\nparameters in constraint expressions. As an example, consider the following\ndeterministic constraint:\n\n```python\n# deterministic\nm.x = pe.Var(range(3))\nc = [0.1, 0.2, 0.3]\nm.cons = pe.Constraint(expr=sum(c[i]*m.x[i] for i in m.x) \u003c= 0)\n```\n\nIf the coefficients `c` are uncertain, we can model the robust constraint as:\n\n```python\n# robust\nm.x = pe.Var(range(3))\nm.c = ro.UncParam(range(3), nominal=[0.1, 0.2, 0.3], uncset=m.uncset)\nm.cons = pe.Constraint(expr=sum(m.c[i]*m.x[i] for i in m.x) \u003c= 0)\n```\n\n### Adjustable robust optimization\nROmodel also has capabilities for modeling adjustable variables for adjustable\nrobust optimization. Defining an adjustable variable is analogous to defining a\nregular variable in Pyomo, with an additional `uncparam` argument\nspecifying a list of uncertain parameters which the adjustable variable depends\non:\n\n```python\n# Define uncertain parameters\nm.w = ro.UncParam(range(3), nominal=[1, 2, 3])\n# Define adjustable variable which depends on uncertain parameter\nm.y = ro.AdjustableVar(range(3), uncparams=[m.w], bounds=(0, 1))\n```\n\nThe uncertain parameters can also be set individually for each element of the\nadjustable variables index using the `set_uncparams` function:\n\n```python\n# Set uncertain parameters for individual indicies\nm.y[0].set_uncparams([m.w[0]])\nm.y[1].set_uncparams([m.w[0], m.w[1]])\n```\n\nThe only method currently implemented for solving adjustable robust\noptimization problems in ROmodel is linear decision rules. If a model contains\nadjustable variables in a constraint or objective, ROmodel automatically\nreplaces it by a linear decision rule based on the specified uncertain\nparameters.\n\n\n### Solvers\nRobust optimization problems modeled in ROmodel can be solved using one of\nthree solvers:\n    \n1. Reformulation solver: this solver applies duality based reformulations to\n   the robust problem to generate it's deterministic counterpart. ROmodel\n   currently includes reformulations for ellipsoidal, polyhedral, and Gaussian\n   process-based uncertainty sets.\n2. Cutting plane solver: this solver starts by solving the nominal problem and\n   then iteratively adds uncertainty scenarios which violate the robust\n   constraints until all constraints are robustly feasible. The cutting plane\n   solver can be applied to any uncertainty set geometry which can be solved\n   with one of the solvers available through Pyomo.\n3. Nominal solver: this solver simply replaces each uncertain parameter by its\n   nominal value and solves the nominal problem. This solver is included for\n   convenience.\n\nROmodel solvers can be instantiated using Pyomo's `SolverFactory`:\n```python\n# Solve robust problem using reformulation\nsolver = pe.SolverFactory('romodel.reformulation')\nsolver.solve(m)\n# Solve robust problem using cutting planes\nsolver = pe.SolverFactory('romodel.cuts')\nsolver.solve(m)\n# Solve nominal problem\nsolver = pe.SolverFactory('romodel.nominal')\nsolver.solve(m)\n```\n\n## Example problems\nROmodel includes a number of example problems:\n\n1. [Knapsack problem](docs/knapsack.md)\n2. [Portfolio optimization problem](docs/portfolio.md)\n3. [Pooling problem](docs/pooling.md) (Nonlinear robust optimization)\n4. [Facility location problem](docs/facility.md) (Adjustable robust optimization)\n5. [Production planning problem](docs/planning.md) (Warped GP based uncertainty sets)\n\nFurther freely available examples of problems implemented in ROmodel include:\n\n6. [State-Task-Network with degradation](https://github.com/johwiebe/stn)\n7. [Drill scheduling problem](https://github.com/cog-imperial/drill-scheduling)\n\n\n\n## References \u0026 Funding\nThis work was funded by an EPSRC/Schlumberger CASE studentship to J.W.\n(EP/R511961/1).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcog-imperial%2Fromodel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcog-imperial%2Fromodel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcog-imperial%2Fromodel/lists"}