Guys! I have a problem: I have created an Abstract Model(). In this model, model.deltaP[t] is a variable and greater and equal 0, model.deltaPmax[t] is a parameter, model.Pg[j, t] is an unsolved variable, model.Pp[j, t] is also an unsolved variable, and model.Pmax[j] is a parameter. The value of model.deltaP[t] is determined by the expression model.deltaPmax[t] - sum(model.PGmax[j] - model.Pg[j, t] + model.Pp[j, t] for j in model.K). If the value of model.deltaPmax[t] - sum(model.PGmax[j] - model.Pg[j, t] + model.Pp[j, t]) is less than or equal to 0, then model.deltaP[t] should be set to 0. On the other hand, if the value of model.deltaPmax[t] - (model.PGmax[j] - model.Pg[j, t] + model.Pp[j, t]) for j in model.K is greater than 0, then model.deltaP[t] should be set to model.deltaPmax[t] - sum(model.PHGmax[j] - model.Pg[j, t] + model.Pp[j, t] for j in model.K). How should this code be written? The following is my code, how should I modify it?
model.deltaPmax = Param(model.K)
model.PGmax = Param(model.T)
model.deltaP = Var(model.T, domain=NonNegativeReals)
model.Pg =Var(model.K, model.T, domain=NonNegativeReals)
model.Pp = Var(model.K, model.T, domain=NonNegativeReals)
def frequency1_rule(model, t):
model.deltaP[t] = model.deltaPmax[t] - sum(model.PGmax[j] - model.Pg[j, t] + model.Pp[j, t] for j in model.K)
if model.deltaP[t].value >= 0:
return model.deltaP[t] == model.deltaPmax[t] - sum(model.PGmax[j] - model.Pg[j, t] + model.Pp[j, t] for j in model.K)
else:
return model.deltaP[t] == 0
model.frequency1 = Constraint(model.T, rule=frequency1_rule)
Thank you !