Pyomo / PyomoGallery

A collection of Pyomo examples
Other
284 stars 158 forks source link

Gams $ convert to Pyomo #10

Closed spartakos87 closed 7 years ago

spartakos87 commented 7 years ago

There is any effective way to convert right dollar of gams to pyomo? For example vr(t) = tr*sr*sum(a$(ord(t)+ord(a) gt card(t)), yv(a)*delta(a)); thx

jsiirola commented 7 years ago

This is really not the best place to put user support questions. The preferred locations for posting user questions are either to the mailing list (pyomo-forum@googlegroups.com) or on StackOverflow.

That said, assuming a and t are defined by Sets model.A and model.T, and that your intent in the ord() calls is to convert the sdet members to their numeric value, then something akin to the following would work:

def con_rule(m, t):
    return m.vr[t] == m.tr * m.sr * sum(m.yv[a]*delta[a] for a in m.A if t+a>len(m.T))
model.con = Constraint(model.T, rule=con_rule)