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
1answer
26 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 ...
2
votes
2answers
58 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 '...
2
votes
1answer
40 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 ...
2
votes
1answer
114 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 &...
7
votes
1answer
203 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 ...
3
votes
1answer
101 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,...
4
votes
1answer
72 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): ...
12
votes
2answers
2k 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 ...
4
votes
1answer
106 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 ...
3
votes
1answer
144 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 ...
8
votes
4answers
559 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 ...
1
vote
0answers
24 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 ...
1
vote
2answers
49 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 ...
1
vote
1answer
149 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 ...
2
votes
0answers
51 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: ...
1
vote
0answers
28 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 ...
1
vote
0answers
61 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 ...
1
vote
3answers
286 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....
2
votes
1answer
127 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 ...
1
vote
0answers
60 views

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

I tried solving my model with xpress: pip install xpress And then in the model: ...
1
vote
1answer
123 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 ...
2
votes
1answer
151 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: ...
0
votes
1answer
61 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: ...
1
vote
0answers
55 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: ...
1
vote
1answer
62 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 ...
2
votes
1answer
74 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:...
4
votes
2answers
184 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 ...
2
votes
0answers
66 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 ...
1
vote
0answers
124 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 ...
3
votes
1answer
89 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 ...
1
vote
1answer
276 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. ...
0
votes
1answer
182 views

Mutable parameter in Pyomo causes a problem

I am defining a Pyomo model that should have some mutable Big-M parameters whose values should be dynamically assigned (once). However, I am having a problem with a difference equation as described in ...
3
votes
1answer
412 views

How to find out which constraint causes problems in Pyomo

I have a Pyomo model with many constraints and variables. When solving it with Gurobi, I get the message "Model is infeasible or unbounded". Now I would like to find out which constraints ...
0
votes
0answers
366 views

Use if-statements when defining a constraint in Pyomo

I would like to define the value of a variable model.variable_costsPerTimeSlot [t] in pyomo and I would like to use if-statements. Depending on the value of the if-...
1
vote
1answer
36 views

How to assure a range for a specific variable in Pyomo

I would like to specify a certain range for a variable for a certain timeslot in Pyomo. I have a temperature variable $T(t)$ that is defined by using the difference equation $$T(t) = T(t-1) + \cdots,\...
2
votes
1answer
49 views

Piecewise Constraint in Abstract Model

I would like to write a piecewise constraint for an Abstract Model in Pyomo. $$\operatorname{pu}_i(t_i^{'v})=\begin{align}\begin{cases}\rho_1(e_i'-t_i^{'v})+\rho_2(e_i-e_i'),\quad& t_i^{'v}\le e_i'...
0
votes
0answers
27 views

Correct way to define constraints in Pyomo

Can I know if the constraint below can be defined as follows in Pyomo for convex optimization. W and G are arrays of dimension M x N. ...
1
vote
1answer
201 views

Can I define constraints in Pyomo as a list?

I would like to define the following constraint in Pyomo $$W^\top{\bf 1}\le\hat w=\begin{bmatrix}\hat{w}_1&\hat{w}_2&\ldots&\hat{w}_N\end{bmatrix}^\top$$ where $W$ is a $2\times4$ matrix. ...
2
votes
1answer
64 views

Model definition in pyomo to solve online optimization problem

I am trying to model the attached online optmization problem in pyomo. Eventually, I am going to use the octeract solver to find the matrix soluions of W and G. I would like to ask advice about ...
2
votes
0answers
67 views

How to assign a single value to Pyomo parameter without a dictionary

I would like to assign a single value to a paramter that depends on a created set in Pyomo. I have the following code: ...
2
votes
1answer
392 views

Pyomo can't find Gurobi solver

I have a pyomo model that I can solve using the GLPK solver by just using the code: ...
2
votes
0answers
82 views

PYOMO - Optimization for the daily production of a products demand minimizing the production cost

I am trying to build an optimization model using PYOMO for the daily production of a product demand, minimizing the production cost. I have demand, production capacity (by machine by day), production ...
3
votes
1answer
138 views

Referencing of sets in Pyomo objectives

I have a question about referecing set in Pyomo objectives. Basically I have 2 options and I do not understand why one of it works whereas the other yields an error. Here you see them: ...
1
vote
1answer
306 views

How to display results from a solver during solving in Pyomo

I would like to see the current results (e.g. MIP gaps) of a solver in pyomo (as in GAMS) while solving the problem. I read that I should use the option "stream-solver" (see for instance ...
3
votes
1answer
70 views

How to implement a difference equation in Pyomo

I would like to define a difference equation in pyomo for a temperature variable. The equation (simplified) looks like: $Temperature(t) = Temperature (t-1) + x(t)$ , for t>0 $Temperature (0) = 20 $ ...
1
vote
1answer
220 views

How to dynamically set variable names in Pyomo?

I am looking to set variables in my Pyomo model by using a loop, so that they can be created automatically. However, each variable also contains bounds. I was hoping that it can loop through a ...
1
vote
1answer
900 views

Pyomo can't find solver

I am new to Pyomo and I have the following optimization problem (original transport problem by Dantzig): ...
2
votes
1answer
160 views

How to define constraints in Pyomo using sets and variables

I am trying to model the transportation problem of Dantzig in Pyomo (see the GAMS code here https://www.gams.com/latest/gamslib_ml/libhtml/gamslib_trnsport.html or the description here https://www....
3
votes
1answer
124 views

Why functions with arguments can be called without arguments in Pyomo

I have a question regarding pyomo. I have seen quite often, that for the definition of parameters, objectives and constraints, explicit functions are defined. These functions expect some arguments and ...
2
votes
1answer
217 views

Error when defining variables in Pyomo

I just started to learn about Pyomo. In several tutorials it is stated that the command for creating a variable is just model.Variable = VAR(...). However, I get ...