Questions tagged [pyomo]

For questions related to the Python optimization modeling package Pyomo. Pyomo is a Python-based open-source software package that supports a diverse set of optimization capabilities for formulating, solving, and analyzing optimization models. Pyomo allows users to formulate optimization problems in Python in a manner that is similar to the notation commonly used in mathematical optimization.

Filter by
Sorted by
Tagged with
1 vote
1 answer
37 views

Of what size should I expect to be able to solve an integer linear program with Pyomo?

So I am solving a purely integer linear optimization problem with Pyomo on a single computer (core i-5, 12 GB RAM). The problem has around 10000 variables and 300 constraints. For doing this, I am ...
  • 121
3 votes
0 answers
44 views

How to maximise a function with non-differentiable constraints while integrating over a time series data series with linear programming?

In this problem, I need to pick the optimal charging and discharging times and durations of an electric car-sharing battery to maximize income - not just for a single (dis)charging cycle, but a whole ...
1 vote
1 answer
54 views

variable use of nested blocks in pyomo

I'm using pyomo to model a system consisting of subsystems which themselves consist of subsystems. Therefore, I use nested Blocks. Every block is described in a separate file. I want to be able to ...
  • 11
3 votes
0 answers
193 views

Google-OR tools vs Pyomo and other commercial Solvers for solving a simple maximum flow problem

I have implemented a Pyomo model for solving maximum flow problem as a subroutine of an algorithm. However, the approach does not scale very well because Pyomo does not provide a very good way to re-...
  • 186
3 votes
5 answers
301 views

Convert MCP model from GAMS to Pyomo

I have a Mixed Complementarity Problem (MCP) that represents a market under perfect competition. The model is written in GAMS and works as expected. But when translating it to Python, using Pyomo, the ...
1 vote
1 answer
71 views

Create constraint when variable is within a given range MILP

What is the best way to specify whether a given variable is within a given range in Pyomo? Here I have a binary decision variable assign[t, e] which I want to ...
  • 186
2 votes
1 answer
331 views

Optimization problem with if condition as constraint

I am trying to solve an optimization problem where the constraint contains absolute values and I am not sure how I can express this in a 'Pyomo-friendly' way. Consider the following optimization ...
  • 175
1 vote
1 answer
31 views

Difference between cplex_direct and cplex in Pyomo SolverFactory

I noticed some people specify the solver as "cplex_direct" whereas others as "cplex" when passing the option to SolverFactory in Pyomo. Is there ...
  • 186
2 votes
2 answers
143 views

Improve Network Flow computation with additional Pyomo constraints based on previous computation

I am performing several max-flow computations on extremely similar networks and I seek to improve their execution time based on information from previous computations (As there is a lot of repetitive ...
  • 186
1 vote
1 answer
48 views

Are there any performance overheads if we specify Pyomo Constraints in different way?

I am interested to know whether there are any performance overheads for specifying Pyomo Constraints in different ways. For example, which of the two ways is better? I am trying to speed up one of my ...
  • 186
0 votes
1 answer
77 views

Pyomo.solvers on anaconda mac Ventura 13.0.1 (22A400)

I am facing difficulties to install pyomo.solvers for anaconda I do need glpk cbc ipopt for my anaconda I tried the following ...
2 votes
1 answer
102 views

Pyomo supported solvers on NEOS

Pyomo has two solver managers to execute external solvers: neos (remote execution) serial (local execution). ...
2 votes
1 answer
39 views

Using CPLEX academic version with Pyomo on MacOS

I have recently tried to use the CPLEX solver to solve one of my Pyomo models. I first installed the community version that is available:https://pypi.org/project/cplex/ using ...
  • 186
1 vote
0 answers
92 views

Resetting Pyomo model after computation

I am aware that the types provided by pyomo are immutable and often cause issues when we feed the same data twice in consecutive computations (e.g. when trying to solve an instance a couple of times) ...
  • 186
2 votes
1 answer
89 views

Re-optimizing pyomo model based on previous computation

I am currently new to pyomo and modelling techniques but I came across information mentioning that the CPLEX and Gurobi APIs offer a functionality where you can re-use already computed values and feed ...
  • 186
2 votes
1 answer
131 views

Adding variable to constraint in pyomo

I am trying to implement a delayed column generation approach in pyomo. However, I cannot find a way to add a variable to a constraint. I can add variables to the objective function, simply by adding ...
  • 5,865
1 vote
1 answer
234 views

Pyomo (GLPK): How to set up options with TIME LIMIT or Relative Gap Limit?

I am using Pyomo. I got successes in setting up options for Cbc and scip solvers as shown below. But I am unable to figure out how to set up TIME LIMIT and MIP Relative Gap limit for GLPK solver after ...
0 votes
0 answers
60 views

Looking for correction in pyomo constraint

I am working on two graphs having nodes and edges. Graph1: VNF Graph with node demand and bandwidth demand. Graph2: Server Graph with node capacity and bandwidth capacity. The nodes and links of ...
2 votes
1 answer
116 views

Fixing a complex linear constraint in pyomo

My directed graph f with any node u has a set of outgoing and incoming links as uv ∈ O(u) and vu ∈ I(u) respectively. I am trying to write this constraint here ϕ refers to a binary decision variable ...
3 votes
0 answers
85 views

Creating Disjunctions for MIP Model. Code taking too long to execute

I am currently following this guide in the hopes of building a linear programming model in python and solving using gurobi. https://towardsdatascience.com/schedule-optimisation-using-linear-...
5 votes
0 answers
99 views

How to use interpolation for problem parameters in Pyomo

I'm working on my first Pyomo DAE project to teach myself how to use it for trajectory optimization. I have generated an atmosphere lookup table with density and speed of sound as a function of ...
1 vote
0 answers
39 views

Finding the solutions using pyomo and gurobi

I have a code that uses pyomo and gurobi but when i try to run it, it doesn't give me the optimal solutions, just says that they exist. What can i do?
1 vote
1 answer
73 views

Traversing a list data dynamically in Pyomo Abstract Model

In my PYOMO abstract model, I am reading my data file and storing some specific attributes in a list say demand=[]. I am reading the data file as follows: ...
4 votes
1 answer
123 views

Creating constraints dynamically in pyomo abstract model

I have a networkX graph with few nodes and these nodes have attributes such as "demand". ...
2 votes
1 answer
185 views

Pyomo Abstract model "Empty constraint block written in LP format - solver may error"

My pyomo abstract model has 2 sets with 3 parameters for each set. I am minimizing the objective function with 4 constraints as follows: ...
2 votes
0 answers
268 views

Add lower and upper bounds on decision variables in Pyomo

I have the following optimization model in pyomo: ...
  • 21
-3 votes
1 answer
158 views

Pyomo - ConstriantList

Invalid constraint expression. The constraint expression resolved to a trivial Boolean (True) instead of a Pyomo object. Please modify your rule to return Constraint.Feasible instead of True.
1 vote
2 answers
173 views

MILP modeling Code with pyomo or gurobi or cplex or GAMS. Any link?

I am looking for MILP modeling code with stochastic/deterministic demand for Inventory ordering policy (e.g. (q,r) or (s,S) policy) with pyomo or gurobi or cplex or GAMS. Any link?
  • 29
3 votes
3 answers
226 views

Can I formulate a green vehicle routing problem with pyomo model then solve it with metaheuristics algorithms e.g. GA,HS rather than pyomo solver?

I want to use pyomo to formulate MILP problems in python such as Green Vehicle Routing Problem and others but use metaheuristics algorithms (GA, Harmony search, etc.) to solve those problems instead ...
1 vote
0 answers
29 views

Pyomo error about evaluating value of 'ScalarParam' parameter

I'm trying to optimize a huge model, but here is a part of it capable of creating an understanding of my question: ...
2 votes
2 answers
131 views

Is it possible to import the pyomo model solution in another .py file in the same directory

I have a model say cost.py as follows: ...
3 votes
0 answers
88 views

Testing the pyomo optimization model

I have a resource scheduling optimization model in Pyomo with 3 constraints and an objective. The model runs well for the minimization and maximization objectives. ...
3 votes
0 answers
111 views

Can Pyomo be linked with Google's GLOP or CP-SAT solvers?

Pyomo can be linked with several solvers Open source and commercial ones. I was wondering if Pyomo can be linked with Google's GLOP or CP-SAT solvers?
4 votes
0 answers
71 views

How to invoke a solution pool and access all the solutions in cplex using PYOMO ? this is the structure of my pyomo code

...
3 votes
2 answers
227 views

Write constraints with relationship sets in Pyomo

I would like to write the following constraint in the most compact form possible using Pyomo. $$\sum_{o\in O}y_{n,o} = \sum_{o\in O} \sum_{n'\in LN}y_{n',o}\qquad \forall n$$ Where, the important part,...
1 vote
1 answer
191 views

Solving Graph Partitioning Problems with Gurobi and Pyomo

I am trying to solve a graph partitioning problem for a large number of structurally similar random graphs with an 0-1 LP. Most of these problems are solved within 0.x seconds. Some graphs take the ...
  • 287
5 votes
3 answers
806 views

how to "calm down" optimizer

I want to optimize a charging schedule for Battery Electric Vehicles (BEV) along a grid line, taking into account customer wishes (when to be done with charging with what State of Charge (SOC)) and ...
  • 273
2 votes
1 answer
219 views

Passing exact number of allocations as constraint to pyomo in a sourcing problem

I am solving a sourcing allocation optimization problem. Here I have let's say two brands. Each brand has a raw material demand across the 3 plants (Demand in kg) Brand 1 Brand2 Plant 1 3000 2000 ...
6 votes
1 answer
294 views

Using CBC CLI Arguments in Pyomo

I am currently using the cbc solver with Pyomo opt = SolverFactory('cbc') opt.solve(model) How can more options for Cbc be used,...
2 votes
0 answers
93 views

Pyomo optimisation not working (gas plant dispatch)

background I am trying to write an pyomo script to optimally dispatch a gas plant based on perfect foresight of electricity prices. I believe I am 90% of the way there, just a few issues. Problem The ...
3 votes
0 answers
92 views

Pyomo: Compute IIS, remove corresponding constraint and resolve

I am using pyomo together with a bunch of solvers (gurobi, cbc, etc.). I am able to compute the IIS (with gurobi, not cbc), and write it in a *.ilp file. What I ...
  • 414
7 votes
1 answer
642 views

Problem is infeasible with Gurobi, feasible with cbc (but can't access objective value)

I am solving a MILP with cbc and gurobi (via pyomo). Gurobi states that the model is infeasible. As to cbc the solver status states that a feasible and optimal solution is found, but then it fails to ...
  • 414
4 votes
2 answers
306 views

Compute Irreducible Infeasible Set (IIS) in Pyomo

I am using Pyomo together with Gurobi (and other solvers such as cbc). I am trying to compute an Irreducible Infeasible Set (ISS). In Pyomo documentation, ...
  • 414
2 votes
0 answers
195 views

Pyomo + Cplex - OSError: [Errno 22] Invalid argument

I am trying to get Cplex working with pyomo. I have followed Cplex installation instructions has explained here: Downloading and setting up CPLEX for Pyomo However when calling Cplex via pyomo I get ...
  • 414
4 votes
1 answer
119 views

Edit .NL files to reformulate problem instances

I would like to run a solvers comparison on several instances of MINLPLib. I can get the .NL files for each instance. Now, I would like to reformulate several instances and I need to edit the .NL ...
  • 59
1 vote
1 answer
862 views

Pyomo: Check if solution exists and if not solve other problem

I am using pyomo with gurobi (and other solvers) to solve some optimization programs. Sometimes these programs don't have a solution and throw an error such as ...
  • 414
5 votes
1 answer
550 views

CPLEX gives different solutions of MILP every run

I am solving a mixed-integer (binary) linear problem using CPLEX as a solver (branch-and-bound method). But I encountered the following issue. Each run I get a different solution at a different node ...
5 votes
1 answer
103 views

How to transfer an optimization problem written with GUROBI (in python) in a grammar that can be readily solved with another solver?

Trying to use an opensource optimization tool in python (having used only gurobi for years) I see that the whole code (representing the optimization problem in pythonic language) must be written ...
3 votes
1 answer
240 views

If variable falls below a certain value, include difference to set value in objective

I think its easiest to describe my goal first and continue with my implementation and the resulting problems! My goal: Using Pyomo as interface and Gurobi as solver, if a variable $x_{i,t}$ falls ...
  • 33
-3 votes
2 answers
1k views

No value for uninitialized NumericValue object

I'm working on an optimization model in python with the pyomo library. However I'm getting an error message in python that I cannot seem to understand. The code and error message is below. My code is <...