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
1answer
59 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): ...
9
votes
1answer
1k 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
99 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
106 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
430 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
23 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
42 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
147 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
48 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
59 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
243 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
108 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
51 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
104 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
121 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
56 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
47 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
52 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
69 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
167 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
64 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
85 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
76 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
203 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
140 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
340 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
264 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
33 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
40 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
25 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
114 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
58 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
60 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
316 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
81 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
128 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
226 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
68 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
169 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
712 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
121 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
113 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
196 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 ...
2
votes
0answers
73 views

Find multiple solutions in Pyomo with Gurobi

I am fairly new to Pyomo and Gurobi. I'd like to find 20 sets of different solutions that meet the following constraints. ...
3
votes
1answer
131 views

Ipopt (probably) fails to solve a nonlinear problem, what is next?

I am trying to solve a nonlinear problem with only a set of continuous variables (where the nonlinearity stems from negative inconsistent - across differently indexed variables - large powers), e.g., ...
1
vote
2answers
329 views

How to generate multiple solutions to linear program in Python?

I recently posted a question here where I had written some Pyomo code to solve a simple linear program, however I feel the Operations Research platform is perhaps a better fit for this question. My ...
3
votes
1answer
86 views

How to collect solutions within CPLEX and retrieve them from PYOMO?

I would like to seek some advice on modeling the following: I am currently to invoke solvers, CPLEX, in particular. As I am solving my problem sequentially, i.e., the top-level subproblem results are ...
2
votes
2answers
252 views

Pyomo + Ipopt. Speed Issue

I am using Pyomo + Ipopt as solver to solve a NLP problem. The problem is not extremely complex in terms of dimensionality and ...
0
votes
1answer
135 views

Pyomo variable creation dilemma

I am working on a pyomo model, and need to create a few different sets of variables that are dependent on a solution from a master model. I need the variables to be indexed variables however the ...