Skip to main content

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
2 answers
42 views

How does pyomo handle constraints with equal index

suppose that I have two constraints in pyomo like this ...
Franco's user avatar
  • 13
2 votes
0 answers
50 views

Using BigM and auxiliary variable to linearise model leads to incorrect results

I am working on a Pyomo optimization model that aims to select the cheapest fuel for production at different facilities over several time periods. The model should select Mode1 for Tech1 when Fuel1 is ...
Jamie Bull's user avatar
0 votes
0 answers
52 views

How to initialize Pyomo Piecewise constraint aux variables

I am struggling with solving a MIP model formulated using Pyomo within a Python program. For some sets of problem parameters, CPLEX, HiGHS, and SCIP are sometimes failing to solve the problem and ...
pdb5627's user avatar
  • 186
8 votes
1 answer
128 views

Is there any way to use Lazy constraints in Pyomo?

I would like to know if there is any way to implement a Lazy constraint in the Pyomo package. (As far as I know, the only way to implement such a constraint is by ...
A.Omidi's user avatar
  • 8,960
0 votes
0 answers
27 views

R package cannot find PYOMO. How do I point to the correct location of where it's located?

As a quick note this is a re-post from the main StackOverflow. I am trying to use the PYOMO linear programming solver from within an R script. When I type ...
Abed's user avatar
  • 1
0 votes
1 answer
45 views

OPL Constraint to pyomo ConstraintList constraint for concrete model

Could someone help me convert these OPL constraints into equivalent Pyomo ConstraintList constraints for a concrete model: opl code: ...
Wasim Ali's user avatar
1 vote
1 answer
124 views

In Pyomo, how do I modify the Variable if the value is less than 0?

Pyomo does not allow to use if statements that involves variables. I want to create a new dictionary, model.Excess1, which uses the values from model.Excess to ...
xavgo's user avatar
  • 11
1 vote
0 answers
113 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
203 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
102 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
205 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
134 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
316 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
87 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
2 answers
260 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
  • 13
3 votes
1 answer
177 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
210 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
324 views

How to use the at() method in Pyomo

I am using Pyomo and I have the following lines ...
PeterBe's user avatar
  • 1,652
2 votes
0 answers
255 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
336 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,960
2 votes
1 answer
197 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,960
1 vote
0 answers
99 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
60 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
554 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
339 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
216 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
396 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
751 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
389 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
658 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
120 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
313 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
1k 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
  • 390
3 votes
5 answers
766 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
378 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
  • 390
2 votes
1 answer
651 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
  • 185
2 votes
1 answer
403 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
  • 390
2 votes
2 answers
328 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
  • 390
1 vote
1 answer
112 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
  • 390
0 votes
1 answer
157 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
460 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
219 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
  • 390
1 vote
0 answers
358 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
  • 390
2 votes
1 answer
560 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
  • 390
2 votes
1 answer
643 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,647
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
71 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
142 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
135 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
230 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