Skip to content

Tag: pyomo

Formulating the constraint x[i+1]<= x[i] in Pyomo

I have my decision variable x which is indexed on the list N. I want the constraint that x[i+1] <= x[i] or x[i] <= x[i-1]. But how do I do this in Pyomo without going out of range with my index? This thus doesn’t work. Anyone an idea how to do this? Answer You could use Constraint.Skip to avoid ac…

Pyomo find minimal sum of list values

I want to have an indexed binary variable so pyomo optimises it to minimise the total sum of the list while picking at least 2 elements. When I remove the (imo redundant) model.q I receive: ValueError: No variables appear in the Pyomo model constraints or objective. This is not supported by the NL file interf…

Using NEOS as a Pyomo solver

I have recently started in doing some OR, and have been trying to use Pyomo and NEOS to do some optimation problems. I have been following along with one of the UT Austin Pyomo lectures, and when my GLPT was being difficult to be installed, I moved on to NEOS. I am having some difficulty in now receiving a so…

Switching to Pyomo – Syntax issue with sets

I have used the algebraic modelling language AMPL but I’m now making the switch to python and Pyomo. I’m struggling a bit with its syntax though. In AMPL I would have something like this: How can I implement the last line in Pyomo? Any help is much appreciated, thank you! Best regards, Johannes An…