I have a fairly basic MILP that I'm trying to solve, but while my code runs ok I do not actually get any values. I think this is because of my objective function (since changing it to something trivial does produce an answer):
def OPEX (m):
return sum (m.Q_ng[u,t]*m.ng_price[t] + m.E_imp[t]*m.el_price_imp[t] - m.E_exp[t]*m.el_price_exp[t] for u in m.U for t in m.P)
m.obj = Objective(rule=OPEX)
I need to minimise the sum over u
and t
, is this how you would go about it?
My problem ended up being how I wrote my constraints. According to the book by William E. Hart, Carl Laird, Jean-Paul Watson and David L. Woodruff: Pyomo - Optimization Modeling in Python, you can write functions with
_rule
appended to them and then when you define your constraint just name it the same without using rule, e.g.However this doesn't seem to work (possibly because in the book they use coopr which includes other libraries / modules and not just Pyomo)