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
2 votes
0 answers
62 views

Pyomo Terminal Condition: other

I have written a huge optimization code in pyomo. The code serves for any planning horizon. The variables are indexed in time (t). When I set t to have 365 days, the termination condition is feasible/...
Alex's user avatar
  • 21
3 votes
1 answer
70 views

Solver options in Pyomo as long as using the NEOS solvers

I am working on a scheduling problem that is already coded in Pyomo. To solve the problem, I have used the NEOS solver, CPLEX. Now, to test and run some of the instances, I need to call some CPLEX ...
A.Omidi's user avatar
  • 7,559
2 votes
1 answer
94 views

Using networkx predecessors in Pyomo initialize method

I am working on the directed graph by using the Networkx package and what I need is to use its predecessors' method on an optimization model. Let's say, there exists a directed graph with just $12$ ...
A.Omidi's user avatar
  • 7,559
1 vote
0 answers
51 views

How to speed up state of charge constraint in Pyomo model

Context: I am working on a small electricity market model in Pyomo. It optimizes the capacity of different technologies and generation in at least 43800 hours. One of the technologies is a battery. ...
funkypenguin's user avatar
1 vote
0 answers
55 views

Migrates between solvers

I would like to know if there is a way to migrate the model from A to another solver. For example, lets say i have done built my model in gurobipy and would like to migrates into pyomo. Is there a way?...
overboxed's user avatar
  • 573
2 votes
2 answers
151 views

I want to solve an optimization problem with nonlinear piecewise objective function (I tried Pyomo with "ipopt" solver but I had an error)

I want to solve an optimization problem where the objective function is the summation of nonlinear, piecewise functions in the decision variables q_i's such that when a decision variable q_i < 1, ...
3bod's user avatar
  • 21
-1 votes
2 answers
96 views

An error in Pyomo with a parameter represented as a matrix

I am really new at pyomo and I have been trying to model a simple problem (I reduced the problem to the maximum so that I can see the error). Now the error is at the beginning when I declare the ...
Meriem 's user avatar
3 votes
1 answer
99 views

Modelling a decision variable as an index of a (fixed) set

I'm trying to model the following MINLP problem in Pyomo. We are trying to minimize a nonlinear objective function $f$ in $x_i \in \lbrace{0, 1, 2\rbrace}$ for $i= 1, 2, \dots, N$ and subject to a ...
Steven01123581321's user avatar
2 votes
1 answer
130 views

Implementing a MINLP problem in Pyomo: giving an infeasible solution

I'm trying to implement a MINLP problem which is described in a previous post here: How do we formulate a problem where the decision variable has an index that is also a decision variable? The only ...
Steven01123581321's user avatar
1 vote
2 answers
198 views

Pyomo: Value assignment for binary variables through constraints

I am currently working on a cost minimisation model for multi-product, multi-period supplier selection with Pyomo. It is a linear model described below. **Problem statement** I have no idea how to ...
NullNeuner's user avatar
1 vote
1 answer
150 views

Optimal to-do list scheduling in Python using Pyomo

I am trying to optimally schedule a series of tasks with fixed durations between 9am and 5pm in the day (I guess kind of like a constrained knapsack problem, or job scheduling problem). I have broken ...
Jwem93's user avatar
  • 333
3 votes
1 answer
407 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 ...
John D's user avatar
  • 199
3 votes
1 answer
93 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 ...
Andreas Schuldei's user avatar
1 vote
1 answer
140 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 ...
Ursxx's user avatar
  • 11
4 votes
0 answers
427 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-...
Pia MiA's user avatar
  • 392
3 votes
5 answers
423 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 ...
Solver Max's user avatar
1 vote
1 answer
114 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 ...
Pia MiA's user avatar
  • 392
2 votes
1 answer
436 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 ...
BenBernke's user avatar
  • 175
2 votes
1 answer
90 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 ...
Pia MiA's user avatar
  • 392
2 votes
2 answers
188 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 ...
Pia MiA's user avatar
  • 392
1 vote
1 answer
57 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 ...
Pia MiA's user avatar
  • 392
0 votes
1 answer
105 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 ...
Optimization team's user avatar
2 votes
1 answer
202 views

Pyomo supported solvers on NEOS

Pyomo has two solver managers to execute external solvers: neos (remote execution) serial (local execution). ...
Lars Hadidi's user avatar
2 votes
1 answer
51 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 ...
Pia MiA's user avatar
  • 392
1 vote
0 answers
142 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) ...
Pia MiA's user avatar
  • 392
2 votes
1 answer
169 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 ...
Pia MiA's user avatar
  • 392
2 votes
1 answer
268 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 ...
Sune's user avatar
  • 6,072
1 vote
1 answer
485 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 ...
GuanghuiLiu's user avatar
0 votes
0 answers
63 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 ...
Waqas Swati's user avatar
2 votes
1 answer
122 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 ...
Waqas Swati's user avatar
3 votes
0 answers
89 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-...
SevenArmy's user avatar
5 votes
0 answers
143 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 ...
machalot's user avatar
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?
Joana Domingos's user avatar
1 vote
1 answer
85 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: ...
Waqas Swati's user avatar
4 votes
1 answer
175 views

Creating constraints dynamically in pyomo abstract model

I have a networkX graph with few nodes and these nodes have attributes such as "demand". ...
Waqas Swati's user avatar
2 votes
1 answer
262 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: ...
Waqas Swati's user avatar
2 votes
0 answers
494 views

Add lower and upper bounds on decision variables in Pyomo

I have the following optimization model in pyomo: ...
Telso's user avatar
  • 21
-4 votes
1 answer
260 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.
Dnyaneshwar Kaulwar's user avatar
1 vote
2 answers
234 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?
Peter's user avatar
  • 29
3 votes
3 answers
306 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 ...
Ahmed Abdulmunem's user avatar
1 vote
0 answers
48 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: ...
Alexandre César Barbosa's user avatar
2 votes
2 answers
158 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: ...
Waqas Swati's user avatar
3 votes
0 answers
109 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. ...
Waqas Swati's user avatar
3 votes
0 answers
140 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?
Optimization team's user avatar
4 votes
0 answers
96 views

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

...
Prachi Patki's user avatar
3 votes
2 answers
327 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,...
Daniel V.'s user avatar
1 vote
1 answer
214 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 ...
baxbear's user avatar
  • 287
5 votes
3 answers
819 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 ...
Andre's user avatar
  • 293
2 votes
1 answer
240 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 ...
Lakhotia Dipesh's user avatar
6 votes
1 answer
389 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,...
Athena Wisdom's user avatar