I am solving a day ahead optimization problem. I am using the same set of variables and constraint and the same objective function in two cases, but I am getting a different outcome. The first case considers a single hydro plant with Nk units. The second generalizes the code to account for multiple hydro plants, each with different number of units. So everything is the same, with the same input. My question is that can changes in the data structure of variables result in change in the optimization result?
The following the first case
@variables(PO, begin
0 ≤ Ph[h=1:Nk, t=1:T] ≤ Phmax[h]
Phbase[t=1:T] >= 0
Phbuffer[t=1:T] >= 0
xh[1:T], Bin
end)
@constraints(PO, begin
Koynabuffer[t=1:T], sum(Ph[h,t] for h in 1:Nk) == Phbase[t] + Phbuffer[t]
EAvail_Base, sum(Phbase[t] for t in 1:T) * δₜ <= Eh_base
EAvail_Buffer, sum(Phbase[t] + Phbuffer[t] for t in 1:T) * δₜ <= Eh_base + Eh_buffer
MinH_Koyna[t=1:T], sum(Ph[h, t] for h = 1:Nk) ≥ KoynaP_min
PAvail_Koyna[t=1:T], sum(Ph[h, t] for h = 1:Nk) ≤ (Koyna_DC - KoynaP_min) * xh[t] + KoynaP_min
# Koyna Ramp Constraints
RampUpKoyna[h=1:Nk, t=2:T], Ph[h, t] - Ph[h, t-1] ≤ RU_Koyna[h] * AF_hydro[h] * δₜm
RampDnKoyna[h=1:Nk, t=2:T], Ph[h, t] - Ph[h, t-1] ≥ -RU_Koyna[h] * AF_hydro[h] * δₜm
end)
The second case is as follows:
@variables(PO, begin
0 ≤ Ph[p=1:N_Hydro_Plants, k=1:Nk[p], t=1:T] ≤ Hydro_IC_unit[p][k] # Power per unit
Phbase[p=1:N_Hydro_Plants, t=1:T] >= 0 # Base TMC per plant
Phbuffer[p=1:N_Hydro_Plants, t=1:T] >= 0
xh[p=1:N_Hydro_Plants, t=1:T], Bin
end)
@constraints(PO, begin
# Plant-level Hydro Generation Constraints (like original)
# Total plant power = base + buffer
Hydrobuffer[p=1:N_Hydro_Plants, t=1:T], sum(Ph[p,k,t] for k in 1:Nk[p]) == Phbase[p,t] + Phbuffer[p,t]
# Plant-level energy availability constraints
EAvail_Base[p=1:N_Hydro_Plants], sum(Phbase[p,t] for t in 1:T) * δₜ <= Eh_base[p]
EAvail_Buffer[p=1:N_Hydro_Plants], sum(Phbase[p,t] + Phbuffer[p,t] for t in 1:T) * δₜ <= Eh_base[p] + Eh_buffer[p]
# Plant-level minimum power constraint (total plant generation >= TM)
MinH_Hydro[p=1:N_Hydro_Plants, t=1:T], sum(Ph[p,k,t] for k in 1:Nk[p]) >= HydroP_min[p]
# Plant-level capacity constraint using plant binary (original formulation)
# If xh=0: Ph_total <= TM, if xh=1: Ph_total <= DC
PAvail_Hydro[p=1:N_Hydro_Plants, t=1:T], sum(Ph[p,k,t] for k in 1:Nk[p]) <= (Hydro_DC[p] - HydroP_min[p]) * xh[p,t] + HydroP_min[p]
# Unit-level Hydro Ramp Constraints (include AF factor as in original)
RampUpHydro[p=1:N_Hydro_Plants, k=1:Nk[p], t=2:T], Ph[p,k,t] - Ph[p,k,t-1] <= RU_Hydro_unit[p][k] * AF_Hydro_unit[p][k]
RampDnHydro[p=1:N_Hydro_Plants, k=1:Nk[p], t=2:T], Ph[p,k,t] - Ph[p,k,t-1] >= -RD_Hydro_unit[p][k] * AF_Hydro_unit[p][k]
end)