Pyomo is a Python-based open-source software package that supports a diverse set of optimization capabilities for formulating, solving, and analyzing optimization models.
Questions tagged [pyomo]
1504 questions
-1
votes
1 answer
How to fix "Cannot add component 'cons_index' to block 'unknown': a component by that name is already defined" error in Pyomo?
I am using python in Google Colab to write a nonlinear optimization model and the goal is to run it in a meta-heuristic and get the results. The first time I ran the model it worked just fine. However, I changed some variables and added more…

Anas
- 29
- 3
-1
votes
1 answer
python using pyomo ValueError: More than one active objective defined for input model 'unknown'; Cannot write legal LP file
My objective is to create a hydropower generation model and identify the optimal water level dispatching process. However, I'm encountering errors when attempting to call the Gurobi solver using Pyomo. Although I have recently learned Pyomo, I have…

dut_old_fish
- 1
- 1
-1
votes
1 answer
Problem accessing indexed results two stage stochastic programming Pyomo
When running a stochastic programming problem in Pyomo, the resulting solution works only when running 10 precisely the same scenarios but the results remain zero when running different scenarios.
I aim to run 10 different scenarios with…

Thomas Weenk
- 1
- 2
-1
votes
1 answer
"Cannot treat the scalar component '' as an indexed component"
Here is a few rows of my code for an operations planning optimization.I have 2 dictionaries for the product monthly demand .I have created two parameters with these two dictionaries. As m i have defined the months. After that, i want to multiply…

christina
- 1
- 1
-1
votes
1 answer
Pyomo: Unable to handle quadratic expressions, Language Matching Constraint in Nurse Patient Assignment Model
I am writing a nurse patient matching algorithm, and I want to incorporate something into the objective function that encourages a language match between nurses and patients. The goal is to assign each patient to exactly one nurse while minimizing…
-1
votes
1 answer
Calculate ratio of two parameters using Pyomo, Python
I have 2 parameters such as Demand and Capacity:
I have modeled these as follows:
model.Dmem=Param(model.nf,within=NonNegativeIntegers, initialize=1)
model.Cmem=Param(model.ns, within=NonNegativeIntegers, initialize=5)
I want to calculate the ratio…

Waqas Swati
- 1
- 4
-1
votes
1 answer
runef command not found
Hi I installed pysp package using pip. and according to documents now I should be able to run runef command in terminal. but it gives error " command not found "
I also installed pyomo and it is working fine.
my os is ubuntu 20.04
-1
votes
1 answer
Confusion in Python Pyomo Components (Parameter and Variable)
I am learning Pyomo Abstract Modeling from a Book.
I have an example that has an objective functionEquation is here to minimize the cost of establishing a warehouse at optimal locations to build warehouses to meet delivery demands.
The authors…

Waqas Swati
- 1
- 4
-1
votes
1 answer
How to represent a variable in pyomo which takes a single value from three specified values
I want to declare a variable in PYOMO which must take any of the three values.
For example, the variable must take a value from these 0.037364, 0.03174, 0.03797.
Model.cost =Var(within=NonNegativeReals)??

Waqas Swati
- 1
- 4
-1
votes
1 answer
Pyomo problems with set up in while loop
Edit
I changed the constraints to this:
def constraint_rule1(m, i):
return sum(m.x[i] for i in m.data_set) == 0
def constraint_rule2(m, i):
return m.u1[i] - m.u2[i] == m.x[i] - m.data_param[i]
def objective_rule(m):
…

Cha26
- 33
- 9
-1
votes
1 answer
Failed to create solver with name 'gurobipy': Failed to set executable for solver asl. name=gurobipy either does not exist or it is not executable
I am reciving this error and I do not know what to do?
WARNING: Failed to create solver with name 'gurobipy': Failed to set
executable for solver asl. File with name=gurobipy either does not exist
or it is not executable. To skip this…
-1
votes
1 answer
ApplicationError: Solver (gurobi) did not exit normally
I'm using gurobi academic license and i've followed every steps to activate the license but i get the following error whenever i call the gurobi solver on model which i wrote in pyomo :
ERROR: Solver (gurobi) returned non-zero return code…

ali prm
- 1
- 1
-1
votes
2 answers
Extract pyomo results to a csv file
Can anyone help me extract the values from pyomo model into an excel file?
For example for this Objective function. I want the values for the models to be extracted into an excel file but dont know how...
def lastdeckung(model, t):
return…

saschav
- 37
- 6
-1
votes
1 answer
How can this be linear, according to Pyomo?
while linearizing some constraints containing divisions, I founda formulation which works and is interpreted as linear by Pyomo, and I absolutely have no idea why:
mod.coupling_temp2[m]*sum(mod.same_service[o1, o2, m] for o1, o2 in…

Unziello
- 103
- 8
-1
votes
1 answer
How to read a infeasible result in pyomo using cplex
I turned off the presolve because i need to get a result but when the result is infesiable and i try to read the result all the result that the program read are 0.
Someone knows how to read it??

Leonel Henríquez
- 9
- 4