Questions tagged [pyomo]

1

votes
1

answer
340

Views

Pyomo Set multi-level indexing

In a production and transportation problem I am trying to model using Pyomo, I want to 1) assign each product a separate time duration with a specific starting point, and 2) activate an operating rule for each product within its own time duration. I define a 2-dim array model.Tpp of type Set in an...
SantaClaus
1

votes
2

answer
234

Views

Retrieving Pyomo solution without using for loop

I am struggling to find an efficient way of retrieving the solution to an optimization problem. The solution consists of around 200K variables that I would like in a pandas DataFrame. After searching online the only approaches I found for accessing the variables was through a for loop which looks so...
Jasper
1

votes
0

answer
89

Views

Pyomo load command error: 'NoneType' object is not subscriptable

I am trying to load an array from an excel file. It can be successfully loaded into pyomo when the array size is of 10000 by 140. But I got an error when I was trying to load a 13000 by 140 array. In fact, any array which is larger than that will cause the same error. The error messages are as follo...
Kunru Yang
1

votes
1

answer
78

Views

Using Pyomo with PyInstaller

Is it possible to create a standalone executable file with PyInstaller which solves an optimization problem with Pyomo? For example, I can solve the optimization problem min_x {2*x_1 + 3*x_2 : x_i >= 0, 3*x_1 + 4*x_2 >= 1} by creating a file 'concreteProblem.py' with the following contents from __fu...
Garrett
1

votes
0

answer
102

Views

Installing sIpopt on anaconda environment

I am currently working on a project using an environment within anaconda (my OS is Windows). My current environment already has IPOPT installed via the anaconda cloud. Now, I am trying to install sIPOPT (a toolbox for IPOPT, not to be mistaken with IPOPT itself), available on: https://www.coin-or.or...
Ken
1

votes
1

answer
344

Views

Pyomo optimal solution found but number of solutions 0 (hydropower simulation)

I am looking to simulate the hydropower generation in Norway, taking into account all the cascade dependencies (for an hourly resolution). To beginn with I have set up an optimisation problem in Pyomo for a set of three plants and three reservoirs for one day. For the moment I want to maximise profi...
kratzlos
1

votes
0

answer
125

Views

Pyomo Blocks: indexed vs not-indexed blocks on time-dependent problems

The Pyomo book proposes this structure of blocks for a time-dependent problem. There is a Pyomo Block 'Electrical Grid Model' which is repeated for every time step, means indexed by the time series. model.T = range(120) def electrical_grid_block(grid, t): model.Grid = Block(model.T,rule=electrical...
programmar
1

votes
0

answer
214

Views

Get marginal values (dual) for constraints in Pyomo MIP

I want to access dual variables for a MIP problem developed in python with Pyomo. To my understanding the dual is not created for MIP problems, but in my opinion there should be a work around for this. This should be possible to use as a minimal working example, I'm using Gurobi myself. I can see t...
maypay
1

votes
2

answer
219

Views

How to save (pickle) a model instance in pyomo

I want to create a model instance and then save it so I can load and solve at a later time (the initialization takes quite long compared to the solving). When I tried this it gave me the following error. with open('model.pickle', 'w') as f: pickle.dump(instance, f) AttributeError: Can't pickle local...
Jasper
1

votes
0

answer
58

Views

Pyomo load function

I have got a file named test.xls which looks like this: All Index MaxProd Nuclear 300,0 DomesticCoal_Anthracite 588,0 BrownLignite 203,1 ImportedCoal_SubBituminous 150,4 ImportedCoal_Bituminous 194,4 CCGT_1 500,0...
Christian P
1

votes
1

answer
47

Views

Precedence Constraint Pyomo

I have some problems with my prcedence constraint code. Here an example: I would like to implement the following predecessor constraint: where: i = tasks; t = period; j = model of product x = binary variable which returns 1 if task i is done in period t for model j and 0 otherwise. In order to sat...
Carlos Dlc
1

votes
0

answer
72

Views

Pyomo parameter estimation with time-varying input signals

I want to try Pyomo for parameter estimation problems and this is what I have so far. First the parameters and variables are created. The unknows to the parameter estimation problem are p1 to p6. The time-varying inputs are TVL, mdot and TU. model = pyo.ConcreteModel() model.t = dae.ContinuousSet(in...
Yannick
1

votes
0

answer
32

Views

Computing numeric derivatives with pyomo

I need to repeatedly compute derivatives at a given point of nonlinear pyomo constraints. According to this post, there are basically two options: one symbolic approach (which uses sympy) and one numeric approach via the NL file generated by Pyomo. I have tried the symbolic approach which looks lik...
Christoph Neumann
1

votes
1

answer
63

Views

Baron Error with Pyomo: NonLinearity Error in POW expression

I am trying to solve a nonlinear optimization problem in Pyomo with Baron. The solving works fine when using solvers like ipopt, bonmin, couenne etc. When using Baron I get the following error: =========================================================================== BARON version 18.5.9. Built:...
NinuJa
1

votes
0

answer
20

Views

Is there a way to organise my Pyomo code into submodels that are loaded together into the solver?

I have some experience with AMPL before modelling some complex systems. I was able to divide up my model into smaller submodels and load the together in a 'model.run' file. My question is if anyone knows if it is possible to have the same structure with pyomo? The purpose is to have a clean and easy...
Alexander Villers
1

votes
1

answer
128

Views

cbc solver: print solution to file

i solve my optimiziation problems whit pyomo and the cbc-solver. Now i try to print the terminal output/solution to a file: import pandas as pd from pyomo.opt import SolverFactory from model import * import numpy import matplotlib.pyplot as plt opt = SolverFactory('cbc') opt.options['solution'] = 'o...
Capa
1

votes
1

answer
354

Views

Conda list shows python package but error 'module not found' occurs

I am forced to work on windows and I need to install pyomo. Seems like anaconda is the way to do that. I installed the package via conda install and conda list also shows me that it's installed. But when I run jupyter notebook via the anaconda screen the pyomo package is not in the environment and t...
programmar
1

votes
0

answer
79

Views

Does pyomo provide access to cplex callbacks?

I'm relatively new in Pyomo and I have some problems getting access to the cplex callback for generating user cuts. I'm using Pyomo 5.5.0 and cplex 12.8.0.0, I've already defined an Abstract model and loaded the data, now I would like to specify the cplex UserCutCallback in order to add user-written...
Riccardo
1

votes
1

answer
67

Views

Is pyomo equality expression commutative?

Here's a constraint defined by a function: def my_constraint(model, j): a = sum(model.variable_1[i, j] for i in model.i) + sum(model.variable_2[o, j] for o in model.o if o != j) b = model.variable_3[j] # Apparently, the order matters !? return a == b # return b == a model.my_constraint = pe.Constrai...
Jérôme
1

votes
0

answer
78

Views

How to implement Least-absolute Regresion as a lineal optimization problem

I'm a beginner on this, so I'm traying to implement Least Absolute Regresion as a Linear Optimization Problem from this formulation: UPDATE CODE This is my code so far, but I'm sure it no good because I'm getting the next error: ERROR: Rule failed when generating expression for constraint neg_Const...
Ludwig Rubio
1

votes
0

answer
34

Views

How to use pyomo to load *.sol file

I use pyomo to write the script, but use external solver to do the optimization. The external solver return a *.sol file. My question is that if pyomo or any package of python can decode the sol file, and pass the decision variable result into the original model. Therefore, we can do some post analy...
user10978338
1

votes
0

answer
30

Views

Integral function

I want to simulate the discharging of a battery. I want to store on m.energy_remain[t] the energy remaining in that time instant (t). Untill now i am only able to compute the energy remaining in the final time, because integral() function compute all time-horizon (m.t). How can i improve it to have...
g.mazzaglia
1

votes
0

answer
61

Views

Pyomo: Ipopt maximum numbers of iterations exceeded

i have some troubles with my objective in pyomo. I'm trying to minimize the difference between meassured value (parameter - which i import from a .txt) and the result for a variable from my optimization model. Now my objective is: def _obj_rule(mode): return pe.summation(model.T_vl_s_M,model.T_VL_s_...
annonym123456765432
1

votes
1

answer
47

Views

Reducing memory requirements of a pyomo model

I am building a big pyomo model with over 1 million constraints and 2 million variables. And I am looking for suggestions to reduce the memory requirements of the model that I am building. At the moment it requires over 20gb's of RAM. How would I reduce this? I've never tested defining variables wit...
oakca
1

votes
2

answer
71

Views

Can solver status always be inferred from the termination condition?

I would assume that if the termination condition is 'optimal', then the solver status must be 'ok'. The documentation located at https://pyomo.readthedocs.io/en/latest/working_models.html#accessing-solver-status seems to confirm this by stating that 'the value 'optimal' indicates that the solver suc...
rapap
1

votes
1

answer
21

Views

Does IPOPT not support Pyomo's quicksum function? ValueError for unsupported expression type

I am trying to solve a nonlinear feasibility problem on Pyomo using ipopt solver. The problem has 2 RangeSet declarations of a combined size 28, 4 Param declarations of a combined size 68, and 5 Var declarations of a combined size 88. There's also 90 constraint declarations (2 redundant) of which so...
kemisage
1

votes
1

answer
822

Views

Pyomo output error

I am using pyomo package for implementing an optimization problem. I was trying one of the example problems provided in pyomo online documentation. But, I am getting error when I was trying to solve it. The python code used: from __future__ import division from pyomo.environ import * model = Abstra...
Mike Kehoe
0

votes
0

answer
6

Views

PYOMO: Operation on sets of abstract model

I want to operate on abstract sets. But it dosen't work. from pyomo.environ import * m = AbstractModel() m.A = Set(initialize=[0,1,2]) m.B = Set(initialize=[0]) m.C = m.A-m.B instance = m.create_instance() for c in instance.C.value: print(c) TypeError: 'NoneType' object is not iterable
Capa
1

votes
1

answer
221

Views

PyOmo/Ipopt fails with “can't evaluate pow”

I am using PyOmo to generate a nonlinear model which will ultimately be solved with Ipopt. The model is as follows: from pyomo.environ import * from pyomo.dae import * m = ConcreteModel() m.t = ContinuousSet(bounds=(0,100)) m.T = Param(default=100,mutable=True) m.a = Param(default=0.1) m.kP = Par...
Richard
1

votes
1

answer
156

Views

Pyomo's parameter estimation in an ODE system with missing values in time series

I have an ODE system of 7 equations for explaining a particular set of microorganisms dynamics of the form: Where the are the different chemical and microorganisms species involved (even sub-indexes for chemical compounds), the are the yield coefficients and the are the pseudo-reactions: I am usi...
Mau
1

votes
1

answer
504

Views

adding constraint under pyomo environment

I am working under pyomo.environ package. I tried to adding a constraint something like this http://imgur.com/a/pWJ79. i and j are the index of nodes. The node_set contains N0 to N5, six nodes in total. Arc_set is a set that store the links between nodes, say, [N1, N2], and it doesn't not contain...
whh1294
1

votes
1

answer
1.2k

Views

In Pyomo, Is it possible to write an objective function or a constraint based on several Expressions?

I am quite new in Pyomo and I try to write the objective function and a constraint of my model by using several methods. Actually, I would like to construct the objective function/constraint based on several contributions of different object types implemented in different python scripts. For doing t...
Dimitri Tomanos
1

votes
1

answer
1.1k

Views

Pyomo summation of a product of a matrix by a vector

I edit my code including all the parameters and variables involved: (D is a numpy matrix imported from Python) import pyomo from pyomo.environ import * from array import * import numpy as np import scipy as sp from diff_matrix import D ##N=10???? print(D) m =ConcreteModel() ... m.n = Param(initial...
Michael
1

votes
1

answer
487

Views

in Pyomo, How to write a constraint that has different time periods based on another parameter?

I'm working on a purchasing optimization model, below are some related inputs: stets : model.b = Set(initialize=Brands, doc='Brands') model.s = Set(initialize=Suppliers, doc='Suppliers') model.t = Set(initialize=Time , doc='Time in days') parameters: model.lt = Param(model.s, initialize=LeadTime,...
aMRo alHarBi
1

votes
2

answer
1.3k

Views

Python doesn't find Pyomo

I'm stumped on why Python won't import pyomo. I can find the directory and see it is installed: 234:pyomo user$ pip show pyomo Name: Pyomo Version: 5.1.1 Summary: Pyomo: Python Optimization Modeling Objects Home-page: http://pyomo.org Author: William E. Hart Author-email: [email protected] License...
Tim
1

votes
0

answer
7

Views

PYOMO: How to create constraint relaxation? (Rewrite constraint from CPLEX in Pyomo)

I am trying to transfer a model written in GAMS using CPLEX solver to Pyomo. CPLEX has a feature allowing modelers to relax constraints & decision variables if a model is infeasible - FeasOpt (for Feasible Optimization). I am having trouble recreating this automated infeasibility relaxation feature...
Steve
1

votes
2

answer
562

Views

Data import in Pyomo from csv or xlsx

I have an abstract model in Pyomo which I need to run a couple of times with changing data which is why I'd like to have some easy data import from csv or xls. I tried the DataPortal as well as directly writing a data file but don't succeed and would appreciate your help!! DataPortal I am well aware...
Malo
1

votes
1

answer
121

Views

Solve DAE with Pyomo and class

I'm trying to solve a car problem. first, I have an original code of car problem: # Ampl Car Example # # Shows how to convert a minimize final time optimal control problem # to a format pyomo.dae can handle by removing the time scaling from # the ContinuousSet. # # min tf # dxdt = 0 # dvdt = a-R*v^2...
D.Sprite
1

votes
1

answer
270

Views

Pyomo and conditional objective function

Is it possible (and if so how) to use an objective function that has a conditional expression? Changing the example from the docs, I would like an expression like: def objective_function(model): return model.x[0] if model.x[1] < const else model.x[2] model.Obj = Objective(rule=objective_function, se...
orange
1

votes
1

answer
208

Views

In pyomo how can one extract the second derivative from the objective function

I'm working with pyomo and already have a model defined, with an objective function to go with it. After the model is solved, the objective function has certain parameters attached to it. So if i had a multi index variable [x1, x2, x3], my quadratic objective function would suppose look something li...
omu_negru

View additional questions