pyomo

Access all variables occurring in a pyomo constraint

偶尔善良 提交于 2019-12-19 04:51:32
问题 I am working on an algorithm in python that needs to modify concrete (mixed-integer nonlinear) pyomo models. In particular, I need to know which variables are present in a general algebraic constraint . E.g. for a constraint model.con1 = Constraint(expr=exp(model.x_1) + 2*model.x_2 <= 2) I would like to make a a query (like model.con1.variables ) which returns (a list of) the variables ( [model.x_1,model.x_2] ). In this documentation I find that for linear constraints, the parameter variables

How do you install glpk-solver along with pyomo in Winpython

吃可爱长大的小学妹 提交于 2019-12-19 04:03:15
问题 I want to use "pyomo" for my studies. I installed pyomo via easy_install coopr install instructions, Pyomo needs a solver to work so I wanted to install the (GNU Linear Programming Kit) glpk_webpage, pyomo seems to be installed just right because I can import it in spyder (i am using WinPython-64bit-2.7.5.3) with import coopr.pyomo However, I cannot do anything without glpk I guess... I downloaded glpk-4.52 (latest version) from the ftp server but I do not know what to do with the batch files

Pyomo-IPOPT: solver falls into local minima, how to avoid that?

試著忘記壹切 提交于 2019-12-13 17:54:34
问题 I am trying to solve an optimisation problem consisting in finding the global maximum of a high dimensional (10+) monotonic function (as in monotonic in every direction). The constraints are such that they cut the search space with planes. I have coded the whole thing in pyomo and I am using the ipopt solver. In most cases, I am confident it converges successfully to the global optimal. But if I play a bit with the constraints I see that it sometimes converges to a local minima. It looks like

Get coefficients of a linear pyomo constraint

寵の児 提交于 2019-12-13 17:26:33
问题 I would like to obtain the coefficients of a linear constraint c of a pyomo model m . For instance, for m= ConcreteModel() m.x_1 = Var() m.x_2 = Var() m.x_3 = Var(within = Integers) m.x_4 = Var(within = Integers) m.c= Constraint(expr=2*m.x_1 + 5*m.x_2 + m.x_4 <= 2) I would like to get the array c_coef = [2,5,0,1] . The answer to this question explains how to obtain all variables occurring in a linear constraint and I can easily use this to create the zero-coefficients for variables which don

How to get variables of a constraint in Pyomo

旧街凉风 提交于 2019-12-13 08:35:44
问题 In Pyomo, how can I get a list of the variables appearing in a constraint? I combed through the code in Github, but could not a find any suitable method or attribute for that purpose. 回答1: I found the answer myself: model.con1.body._args gets you the desired list. 来源: https://stackoverflow.com/questions/48519905/how-to-get-variables-of-a-constraint-in-pyomo

Why do IPOPT and Scipy bring different results using the same inputs, constraints and objective function?

微笑、不失礼 提交于 2019-12-13 03:13:53
问题 I’m pretty new to optimization field, so forgive me if my question is too simple. I ran an optimization using Scipy (method SLSQP) and another one using Pyomo (IPOPT solver). Pyomo runs in less than one minute and Scipy takes 4 hours. Both have the same inputs, constraints and objective function. However, I got different results and my final results are 3% lower in Pyomo. There is no constraint violation, so I wonder if there is anything that happens under the hood to justify this difference?

Using PATH AMPL solver with Pyomo on Intel Mac OS X

柔情痞子 提交于 2019-12-12 21:15:30
问题 I'm trying to use the PATH solver (http://pages.cs.wisc.edu/~ferris/path.html) together with Pyomo on Mac OS X (10.11, Intel). I'm using the most recent Anaconda install with Python 3.5. Pyomo can make use of AMPL libraries. From http://prod.sandia.gov/techlib/access-control.cgi/2015/155584.pdf I'm trying to run the following example: `# file munson1.py from pyomo.environ import * from pyomo.mpec import * model = ConcreteModel() model.x1 = Var() model.x2 = Var() model.x3 = Var() model.f1 =

How to find which constraint is violated from pyomo's ipopt interface?

微笑、不失礼 提交于 2019-12-12 19:04:34
问题 I am running an optimization problem using pyomo's ipopt solver. My problem is sort of complicated, and it is declared infeasible by IPOPT. I will not post the entire problem unless needed. But, one thing to note is, I am providing a warm start for the problem, which I thought would help prevent infeasibility from rearing its ugly head. Here's the output from pyomo and ipopt when I set tee=True inside of the solver: Ipopt 3.12.4: ***************************************************************

cbc solver log memory is missing

不羁的心 提交于 2019-12-11 16:56:18
问题 I am solving a pyomo model with cbc solver. With the log file of the solver I can see how much time it needed to solve. But I was wondering if there is a way to check how much memory is needed to solve the model? Any command to see the memory usage? Following is the log file of the solver: Solver command line: ['/usr/bin/cbc', '-printingOptions', 'all', '-import', '/home/okan/Desktop/urbs-oemof/tmpkb6ceyi_.pyomo.lp', '-stat=1', '-solve', '-solu', '/home/okan/Desktop/urbs-oemof/tmpkb6ceyi_

Setting parameters in pyomo

廉价感情. 提交于 2019-12-11 15:41:55
问题 I am using CPLEX with pyomo . I would like to set the parameter mip.limits.solutions = 1 . How to do this with either .options( or .set_options( or any other way? I have tried the following but nothing works: from pyomo.environ import * opt = SolverFactory("cplex") opt.set_options('miplimitssolutions=1') # does not work opt.set_options('mip.limits.solutions=1') # does not work opt.options['mip'] = 'limits' # this works up to here but how to continue? 回答1: Pyomo's (LP file-based) CPLEX