recently I have been trying to solve the optimization problem in the paper named
‘System-level analysis of lignin valorization in lignocellulosic biorefineries’
using Pyomo. But the three constraints conflicts each other, which not happened before using GAMS.
I have revisited all the data and codes, but it is totally same with what I did by GAMS.
Therefore, I’m wondering if there is an inherent difference btw GAMS and Pyomo when it comes to dealing with constraints.
Can you guys help me, please?
In GAMS
EnergyBal_CB_HeatIn(j,pp)$(jcb(j) and pout_j(j,pp))..
EOUT(‘Heat’,pp) =e= sum((i,p)$(ii(i)+ir(i) and pin_j(j,p)), eta(i,p,’Heat’,pp)*FIN(i,p)) ;
EnergyBal_CB_HeatBal(j,pp)$(jcb(j) and pout_j(j,pp))..
kappa*EOUT(‘Heat’,pp) =e= EUT(‘Heat’) + EW + sum(p$(pin(p) and chi(‘Heat’,pp,p)=1), EC(‘Heat’,pp,p)) ;
EnergyBal_HeatUtil(i)$ie(i)..
EUT(i) =e= sum(j$jconv(j), mu(i,j)*X(j)) ;
In Pyomo
def _rule_EnergyBal_CB_HeatIn():
self.EnergyBal_CB_HeatIn = ConstraintList()
set_j = list(self.JCB)
set_pp = list(self.POUT)
all_combinations = product(set_j, set_pp)
for (j,pp) in all_combinations:
if (j,pp) not in self.POUT_J:
continue
self.EnergyBal_CB_HeatIn.add(self.EOUT['Heat',pp]== sum(self.eta[i,p,'Heat',pp] * self.FIN[i,p]
for i in (self.II | self.IR)
for p in self.PIN if (j,p) in self.PIN_J and (i,p,'Heat',pp) in self.eta))
_rule_EnergyBal_CB_HeatIn()
def _rule_EnergyBal_CB_HeatBal():
self.EnergyBal_CB_HeatBal = ConstraintList()
set_j = list(self.JCB)
set_pp = list(self.POUT)
all_combinations = product(set_j, set_pp)
for (j,pp) in all_combinations:
if (j,pp) not in self.POUT_J:
continue
self.EnergyBal_CB_HeatBal.add(self.kappa * self.EOUT['Heat',pp] == self.EUT['Heat'] + self.EW + sum(self.EC['Heat',pp,p]
for p in self.PIN if ('Heat',pp,p) in self.chi and self.chi['Heat',pp,p] == 1))
_rule_EnergyBal_CB_HeatBal()
def _rule_EnergyBal_HeatUtil(_m, i):
return _m.EUT[i] == sum(_m.mu[i,j] * _m.X[j]
for j in _m.JCONV
if (i,j) in _m.mu)
self.EnergyBal_HeatUtil = Constraint(self.IE, rule=_rule_EnergyBal_HeatUtil)
Reviewed all the constraints, deactivate/activate each of them to see where the problem happens.
최정웅 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.