Addition of new objective

23 views
Skip to first unread message

Kirn Zafar

unread,
Apr 24, 2024, 6:33:32 PM4/24/24
to Open-DSOPF
Hi, 

I want to add another objective function to this code . Could anyone please guide me if I'm doing it correct. 

Here are some parts of the code pertaining to the new objective function. 

if 1==1:
# PV Control variables
if 1==1:
model.P_control = pyo.Var(model.PVs, model.time, within=pyo.NonNegativeReals, bounds=(0.0,1.0), initialize=0.001)
model.Thanphi_control = pyo.Var(model.PVs, model.time, bounds=(0.0,math.tan(math.acos(min_Cosphi))), initialize=0.001)
model.Inverter_number=pyo.Var(model.PVs, model.time,bounds=(0.0,PV_size), initialize=1)
#################################
def PV_inverter_number_limit_rule(model, pv, t):
PV_count=0
max_P = PV_Gen_data[pv,'Profile'].loc[t]
max_S = (max_P**2+ (max_P*math.tan(math.acos(min_Cosphi)))**2)**0.5
for pv in PV_set:
if max_S > PV_Gen_data[pv,'Rating']*1000*Inverter_S_oversized:
PV_count=PV_count+1
return PV_count*model.Inverter_number[pv,t]
model.PV_inverter_number_limit_rule = pyo.Expression(model.PVs,model.time,rule=PV_inverter_number_limit_rule)

#################################################

if 1==0: # Dummy objective function just for testing errors (it's always one or another)
model.obj = pyo.Objective(expr=model.Dummy)
if 1==1:
def Objective_rule(model):
return sum(sum((-1e3 * model.P_control[pv,t] + model.Thanphi_control[pv,t]+model.Inverter_number) for pv in model.PVs) for t in model.time)


#model.C_e = Constraint(expr=model.f2 - model.s == model.e)
model.obj = pyo.Objective(rule=Objective_rule)



############################3333
Thank you so much. 

Reply all
Reply to author
Forward
0 new messages