22 views

Skip to first unread message

Jun 26, 2023, 12:54:55 PM6/26/23

to Pyomo Forum

I have a generation planning model where there is a generation-demand node balance equality constraint.

For some case studies, some dual variables of these equations are reported as negative because the constraint is formulated as

- sum of generation in the node = - node demand

where usually I would expect to be created as

sum of generation in the node = node demand

Can the way the constraint is created be controlled? Can be detected how has been created?

Thanks in advance for the help

Andrés

Jun 27, 2023, 11:26:48 AM6/27/23

to pyomo...@googlegroups.com

Pyomo generally uses (and preserves) whatever expression that you provide. The one exception is that all variables have to be in the “body” of the constraint. This means that expressions of the form “f(x) == g(y)” (where x and y are variables)
will be converted to “f(x) – g(y) == 0”. Similar things happen to inequalities (“f(x) <= g(y)” goes to “f(x) – g(y) <= 0” and “f(x) >= g(y)” goes to “g(y) – f(x) <= 0”). I don’t see how Pyomo would be negating both sides of your constraint. Can you share
the constraint definition that you are using?

__ __

John

--

You received this message because you are subscribed to the Google Groups "Pyomo Forum" group.

To unsubscribe from this group and stop receiving emails from it, send an email to
pyomo-forum...@googlegroups.com.

To view this discussion on the web visit
https://groups.google.com/d/msgid/pyomo-forum/a5b15e2a-4ca4-43e6-977b-701aff2a62edn%40googlegroups.com.

Jun 28, 2023, 8:17:20 AM6/28/23

to pyomo...@googlegroups.com

Hi John,

thanks for the answer

Here it is the original constraint where the parameter is in the RHS but there are also some variables in the RHS

def eBalance(mTEPES,n,nd):

if sum(1 for g in g2n[nd]) + sum(1 for lout in lout[nd]) + sum(1 for ni,cc in lin[nd]):

return (sum(mTEPES.vTotalOutput[p,sc,n,g] for g in g2n[nd]) - sum(mTEPES.vESSTotalCharge[p,sc,n,es]
for es in e2n[nd]) +
mTEPES.vENS[p,sc,n,nd] == mTEPES.pDemand[p,sc,n,nd] +

sum(mTEPES.vLineLosses[p,sc,n,nd,lout ] for lout in loutl[nd]) + sum(mTEPES.vFlow[p,sc,n,nd,lout
] for lout in lout[nd]) +

sum(mTEPES.vLineLosses[p,sc,n,ni,nd,cc] for ni,cc in linl [nd]) - sum(mTEPES.vFlow[p,sc,n,ni,nd,cc]
for ni,cc in lin [nd]))

else:

return Constraint.Skip

setattr(mTEPES, 'eBalance_'+str(p)+'_'+str(sc)+'_'+str(st), Constraint(mTEPES.n, mTEPES.nd, rule=eBalance, doc='load generation balance [GW]'))

and the fixed constraint where only the parameter is in the RHS

def eBalance(OptModel,n,nd):

if sum(1 for g in g2n[nd]) + sum(1 for lout in lout[nd]) + sum(1 for ni,cc in lin[nd]):

return (sum(mTEPES.vTotalOutput[p,sc,n,g] for g in g2n[nd]) - sum(mTEPES.vESSTotalCharge[p,sc,n,es]
for es in e2n[nd]) +
mTEPES.vENS[p,sc,n,nd] -

sum(mTEPES.vLineLosses[p,sc,n,nd,lout ] for lout in loutl[nd]) - sum(mTEPES.vFlow[p,sc,n,nd,lout
] for lout in lout[nd]) -

sum(mTEPES.vLineLosses[p,sc,n,ni,nd,cc] for ni,cc in linl [nd]) + sum(mTEPES.vFlow[p,sc,n,ni,nd,cc]
for ni,cc in lin [nd])) == mTEPES.pDemand[p,sc,n,nd]

else:

return Constraint.Skip

setattr(mTEPES, 'eBalance_'+str(p)+'_'+str(sc)+'_'+str(st), Constraint(mTEPES.n, mTEPES.nd, rule=eBalance, doc='load generation balance [GW]'))
Parameters start with p and variables with v

Best regards

Andrés

To view this discussion on the web visit
https://groups.google.com/d/msgid/pyomo-forum/SA9PR09MB4829710CFD0DC09C37470F17DA27A%40SA9PR09MB4829.namprd09.prod.outlook.com.

Reply all

Reply to author

Forward

0 new messages

Search

Clear search

Close search

Google apps

Main menu