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
77 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 ...
user avatar
  • 267
5 votes
3 answers
779 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 ...
user avatar
  • 231
2 votes
1 answer
81 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 ...
user avatar
6 votes
1 answer
96 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,...
user avatar
2 votes
0 answers
55 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 ...
user avatar
3 votes
0 answers
51 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 ...
user avatar
  • 414
7 votes
1 answer
375 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 ...
user avatar
  • 414
4 votes
2 answers
112 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, ...
user avatar
  • 414
2 votes
0 answers
88 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 ...
user avatar
  • 414
4 votes
1 answer
81 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 ...
user avatar
  • 59
1 vote
1 answer
214 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 ...
user avatar
  • 414
5 votes
1 answer
333 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 ...
user avatar
5 votes
1 answer
83 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 ...
user avatar
0 votes
0 answers
74 views

Controlling IPOPT options with pyomo doesn't work

I am using IPOPT solver for solving KKTs conditions (a bunch of equality constraints and complementarity conditions). For assigning the solver for complementarity problem, I use the command line below:...
user avatar
3 votes
1 answer
189 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 ...
user avatar
  • 33
-3 votes
2 answers
473 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 <...
user avatar
6 votes
1 answer
306 views

Python "Coffee Shop Scheduling Problem" - Scheduling Lunches/Breaks

I'm working on an employee scheduling program in python. Having never done this before, I've been researching different libraries that can be used to accomplish the task. Unfortunately, none of the ...
user avatar
  • 63
3 votes
0 answers
62 views

Automatic quadratization of constraints in pyomo for gurobi

Gurobi 9 can solve QCQPs, and QCQPs capture all of polynomial optimization by the obvious trick that e.g. a cubic term $x_1 x_2 x_3$ can be turned into a quadratic term $y x_3$ and a constraint $y = ...
user avatar
2 votes
1 answer
272 views

How to professionally write a constraint, where some variables take certain values of index and some variables should not take some values of index

I am using Pyomo's concrete model to model a MILP mathematical model, coming from multiproduct pipeline scheduling. Some of our continuous variables are: ...
user avatar
  • 103
2 votes
2 answers
198 views

Pyomo mipgap status monitoring

Is there a way to monitor the value of the mipgap while running an optimization model Pyomo? I would like to know how far I am from the optimality gap. Here is my ...
user avatar
2 votes
2 answers
299 views

How to install Ipopt on Google Colab for Pyomo?

I need to use Pyomo with Ipopt solver on Google-Colab. In order to install it I did as follows: Now I need to use it , I get the following error ? ApplicationError: No executable found for solver '...
user avatar
2 votes
1 answer
80 views

Can we take the constraints from one model and plug them into the other model in pyomo?

I am implementing data-driven robust optimization methodology introduced in this article in python. Somewhere of the method, I need to use pyomo for each constraint whose parameters are uncertain to ...
user avatar
  • 103
1 vote
1 answer
1k views

No executable found for solver 'ipopt

I know that there are some questions concerning this type of error, for example, this link. I first installed the latest version of ipopt through command line into my Pyomo environment and got the &...
user avatar
  • 103
7 votes
1 answer
271 views

Why is Gurobi output in Pyomo returning floating-point values rather than optimal integer solution?

I am hoping someone will be able to point me in the direction of why I am experiencing floating-point outputs rather than simply model.X = [15,15] and model.Z = [15,5] as solutions to this model? Note ...
user avatar
  • 191
3 votes
1 answer
270 views

pyomo/ipopt: nonlinear network optimization not converging

The question (very short version) Why can I not decrease the lower boundary for the decision variable model.v_dot (see implementation) below 30 ? As soon as I do so,...
user avatar
4 votes
1 answer
79 views

In pyomo, any reason for using "model.<nameofvariable>" throughout the code instead of doing "<nameofvariable> = model.<nameofvariable>" and using it?

The question is a bit self explanatory I believe, but just to give a simple example (this is not the entire model of course): ...
user avatar
  • 159
13 votes
2 answers
3k views

Is Apple's M1 suitable for Operations Research?

I am curious about the performance of Apple's M1 chip solving optimizations models, MIP, LP, and in solutions approach as benders or columns generations. I read that is a spectacular cpu to perform ...
user avatar
  • 313
4 votes
1 answer
248 views

Constraintlist with two Options Pyomo

I recently started with Pyomo and I have the following Problem: I want to construct a ConstraintList with an if statement. I already learned, that it's not possible. But the problem still exists... My ...
user avatar
3 votes
1 answer
339 views

How to round values in Pyomo

I have a variable in Pyomo called model.variable_objectiveCosts and I would like to print this value to a file. Basically it works. But when I would like to divide ...
user avatar
  • 1,546
9 votes
4 answers
2k views

What is the best open source solver for large scale LP optimization in pyomo?

I have used Gurobi and cplex for solving large scale LP problems with Pyomo. However, I do need to use open source solver. Any advise? glpk and cbc seems to be very slow in solving the problem (with ...
user avatar
0 votes
0 answers
43 views

How to count the number of Stale variables in Pyomo?

How to check if a variable is Stale or not? How to count them? For example let's have a variable like instance.x[i] (i in instance.i set). Let's assume some of ...
user avatar
1 vote
2 answers
127 views

Why my mutable parameter does not update in Pyomo?

I am trying to update my mutable parameter Nc in my Abstract model the initial value is 4 I constructed the instance then change instance.Nc to 5 and solve it but it is still 4 (initial value) , can ...
user avatar
1 vote
1 answer
154 views

How do I write the following constraint?

I have defined the index for time to be T = [1,2,3,4,5,6]. I want that that the demand that to be addressed twice in a given a time period, when the difference between the time the demand is addressed ...
user avatar
1 vote
0 answers
103 views

CPLEX callback in pyomo

I am trying to figure out what is the correct use of cplex callbacks in pyomo. In particular I am looking for the translation of the following example from gurobi to cplex: ...
user avatar
  • 59
1 vote
0 answers
56 views

Run Pyomo model with externally assigned variables

I have several (large) Pyomo models with about 20 variables and parameters (as time series). Out of these variables and parameters I have 3 decision variables. Now my question is whether I can use ...
user avatar
  • 1,546
1 vote
0 answers
116 views

How do I write the following constraints in Pyomo?

I'm currently trying to replicate a vehicle routing problem paper, and I'm facing trouble writing the said constraints in the paper in Pyomo. I've been able to generate the data as required by the ...
user avatar
1 vote
3 answers
594 views

Gurobi does not work any more in Pyomo after getting a new license

I have been using Pyomo with a free Academic license for Gurobi and so far it worked quite well. Now my license expired and I received a new license that is stored in the folder "C:/Gurobi/gurobi....
user avatar
  • 1,546
2 votes
1 answer
329 views

Obtaining solver timings from Pyomo

I would like to seek some advice on the following: I am currently using Pyomo to generate my MILP model in Pyomo and solve it using Gurobi, respectively. As the solution process is iterative, I would ...
user avatar
  • 663
1 vote
0 answers
96 views

Solver issue? Xpress (slp) - Nonlinear - Python - Pyomo

I tried solving my model with xpress: pip install xpress And then in the model: ...
user avatar
  • 111
1 vote
1 answer
260 views

How to display results of 2-dimensional Pyomo variables in a pandas dataframe

I would like to create a pandas dataframe from the results (and the parameters) of an optimization problem and create a csv file out of it. In my previous example (1-dimensional case) I have just one ...
user avatar
  • 1,546
2 votes
1 answer
367 views

Find multiple solutions using pyomo and gurobi

I am solving a MILP using Gurobi and Pyomo. I would like to obtain as many optimal solutions as possible. Here is what I have so far: ...
user avatar
  • 29
0 votes
1 answer
155 views

How to create constraint-equations in Pyomo with empty set inputs

I would like to crate an constraint-equation that depends on 4 sets. For that I use the following code: ...
user avatar
  • 1,546
1 vote
0 answers
94 views

How to deal with hourly and annually constraints in Pyomo?

I am wondering whether it is possible to create constraints over years and hours at the same time in Pyomo. For example, my current time variable is: ...
user avatar
  • 507
1 vote
1 answer
255 views

How to assign values from a list of dictionaries to a 2-dimensional parameter in Pyomo

I know how to assign values from a single dictionary to a 1-dimensional parameter in Pyomo. For that I use the following code ...
user avatar
  • 1,546
2 votes
1 answer
189 views

Returning the best possible value found when the search direction is becoming too small (IPOPT via Pyomo)

I'm using Pyomo to solve an optimization problem and I'm using as a solver IPOPT. Now I'm getting an error from IPOPT. EXIT: Search Direction is becoming Too Small. according to the docs, this means:...
user avatar
4 votes
2 answers
229 views

Setting up Branching Priority for GUROBI in Pyomo

I am currently experimenting with GUROBI and would appreciate some kind advice on the following: In Pyomo: Setting variable branching priorities, there was a response to doing so for CPLEX, hence I ...
user avatar
  • 663
2 votes
0 answers
115 views

Pyomo Trouble - Number of Constraints in Output is 0 When It Should Be > 5000

I have an MILP program written in Pyomo and I am using CBC as a solver. Below is a description of my problem: The model works fine when it is run on my local computer The output is the following in ...
user avatar
1 vote
0 answers
344 views

Value Error in Pyomo: Constraint rule returned None

I get an error in Pyomo that I do not understand. I habe 288 timeslots t and a binary variable y (which I call here ...
user avatar
  • 1,546
3 votes
1 answer
188 views

Obtaining linear relaxation objective value from MILP model coded in Pyomo

I would like to seek some advice on modeling the following: I am currently using Pyomo to generate my MILP model in Pyomo. It seems that it is not possible to cast the integer and binary variables to ...
user avatar
  • 663
1 vote
1 answer
821 views

How to display results of Pyomo variables in a pandas dataframe

I would like to display all the results of Pyomo variables in a pandas dataframe. I had a look at this question Pyomo: Looping Over A Variable Method and tried to adjust it to my case without success. ...
user avatar
  • 1,546