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

how to implement the correlation coefficient in cvxpy and how to rewrite cp.diff(cp.cumsum(x)/(cp.cumsum(x)[-1])

suppose that I have 2 sets of data, x and y,where x can be ...
Allen Zhang's user avatar
1 vote
0 answers
58 views

pyinstaller and Pyomo and also SCIP

I would like to package (using pyinstaller) my optimizer program that uses Pyomo and SCIP. I keep getting ...
mathlete42's user avatar
0 votes
1 answer
151 views

Pyomo disjunction

I have a Pyomo model where I want to formulate constraints: [Model.portrait.w, Model.portrait.l] OR [Model.landscape.w, Model.landscape.l] I can use BigM constraints to achieve this, but I want to try ...
Solver Max's user avatar
1 vote
1 answer
68 views

Pyomo sensitivity report access

I have been learning pyomo with glpk for a week now and I would like to know if pyomo team has developed a way to access "allowable increase" and "allowable decrease" values of the ...
Prasanna's user avatar
2 votes
1 answer
159 views

GLPK solver with Pyomo, not recognizing infeasibility

I have a simple infeasible problem as below. Maximize z = 4x1 + 3x2 2x1 - x2 >= 6 x1 + x2 <= 2 x1 and x2 >= 0 After solving I see that the termination status says 'ok' rather than saying ...
Prasanna's user avatar
0 votes
0 answers
83 views

Pyomo + Gurobi Scheduling Tasks within Working Hours

I initially posted this on stackoverflow and got redirected here. You can view the old post with formatted tables here: StackOverflow Post I have a python schedule optimization script using pyomo and ...
Phil Franjo's user avatar
2 votes
1 answer
246 views

Gurobipy MILP model comes infeasible yet can't compute IIS because "the model is feasible"

I build a MILP model by Pyomo and use Gurobi 9.0.3 as solver. When the model comes infeasible, I try to use pyomo.contrib.iis.iis.write_iis to compute infeasible ...
CangWangu's user avatar
0 votes
1 answer
62 views

Question about IIS output in Pyomo, Gurobipy

These days I try to build a Gurobipy optimization model by Pyomo and I met a problem about outputing IIS file. I use ...
CangWangu's user avatar
0 votes
1 answer
214 views

Gurobi founds optimal solution but it is not feasible

I'm currently solving a MIP model with pyomo using gurobi and I am facing strange results. I have one constraint that looks like this: ...
Franco's user avatar
  • 1
3 votes
1 answer
174 views

What are some of the key features that are currently absent in open-source AMLs like Pyomo, JuMP, Gurobipy

What are the some of prominent technical features (which may or may not be part of commercial Algebraic Modeling Languages (AMLs) such as GAMS or AMPL) which are currently lacking in open-source AMLs ...
chupa_kabra's user avatar
  • 1,485
-1 votes
1 answer
138 views

creating individual Variables in pyomo with different length

I am new to pyomo and I do have some smaller (or bigger) problems and hope someone can help me. How can you create this variable in pyomo? I wanted to create it with pyo.Varlist() in which I pass ...
Tamara Koch's user avatar
0 votes
1 answer
253 views

How to use the at() method in Pyomo

I am using Pyomo and I have the following lines ...
PeterBe's user avatar
  • 1,632
2 votes
0 answers
196 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
266 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
  • 8,642
2 votes
1 answer
162 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
  • 8,642
1 vote
0 answers
88 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
59 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
  • 593
2 votes
2 answers
418 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
279 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
175 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
291 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
577 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
331 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
537 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
111 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
253 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
901 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
677 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
304 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
588 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
294 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
292 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
98 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
144 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
404 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
2 answers
142 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
300 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
381 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
548 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,427
1 vote
1 answer
1k 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
68 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
135 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
119 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
199 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
41 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
94 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
286 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
338 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
935 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
430 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