Constraints not satisfied for the generated optimal solutions
AnsweredHi,
I have an optimization problem, which indicates an optimal solution is given. But the "ApparantPowerLimitEV" constraints are apparently not satisfied. I would appreciate any insight for that.
Best regards,
Sen
import gurobipy as gp
from gurobipy import GRB, quicksum
import pandas as pd
import numpy as np
import math
def func_optimization(c_loss, c_baseload, c_ev, c_hp_up, c_hp_down, c_pv, p_pv_fore, p_ev_max, p_hp_set, p_baseload):
# units in kA, kV, MW, MVA, MVar, Euro
# values for single phase
s_pv = 3.75E-3/3# apparant power limits, 4.5/1.2, divided by 3 phase, inverter size
s_ev = 3.7E-3/3
s_trafo = 0.63/3
n_bus = 195
n_houses = 182
p_hp_max = [] # HP capacity in kW
for i in range(n_houses):
p_hp_max.append(math.ceil(max(np.genfromtxt("load182\\hpload_customer{}.csv".format(i+1))))/3 * 1E-3)
house_index = []
for i in range(n_bus):
if i not in [0,17,24,45,52,62,64,78,93,135,140,144,167]:
house_index.append(i)
pf = 0.92 # baseload & HP
tan_phi_load = (np.sqrt(1-pf**2))/pf
pf_ev_pv_limit = 0.95
tan_phi_evpv = (np.sqrt(1-pf_ev_pv_limit**2))/pf_ev_pv_limit
q_baseload = p_baseload * tan_phi_load
v_ref = 0.23 # kV
v_lb = 0.96 #pu
v_ub = 1.04
epse_network = pd.read_excel("epse_network.xlsx")
m = gp.Model("GEC")
# m.Params.LogToConsole = 0
# define variables
p = m.addVars(n_bus, lb = -float('inf'), vtype = GRB.CONTINUOUS, name = "PBusInjection")
p_houses = m.addVars(n_houses, lb = -float('inf'), vtype = GRB.CONTINUOUS, name = "PHouseBusInjection")
q = m.addVars(n_bus, lb = -float('inf'), vtype = GRB.CONTINUOUS, name = "QBusInjection")
q_houses = m.addVars(n_houses, lb = -float('inf'), vtype = GRB.CONTINUOUS, name = "QHouseBusInjection")
P = m.addVars(n_bus-1, lb = -float('inf'), vtype = GRB.CONTINUOUS, name = "PLine")
Q = m.addVars(n_bus-1, lb = -float('inf'), vtype = GRB.CONTINUOUS, name = "QLine")
v = m.addVars(n_bus, lb = (v_lb*v_ref)**2, ub = (v_ub*v_ref)**2, vtype = GRB.CONTINUOUS, name = "VoltSquare")
l = m.addVars(n_bus-1, lb = 0, vtype = GRB.CONTINUOUS, name = "CurrentSquare")
p_pv = m.addVars(n_houses, lb = 0, vtype = GRB.CONTINUOUS, name = "PVactivePower")
q_pv = m.addVars(n_houses, lb = -float('inf'), vtype = GRB.CONTINUOUS, name = "PVreactivePower")
p_ev = m.addVars(n_houses, lb = 0, vtype = GRB.CONTINUOUS, name = "EVactivePower")
q_ev = m.addVars(n_houses, lb = -float('inf'), vtype = GRB.CONTINUOUS, name = "EVreactivePower")
p_hp = m.addVars(n_houses, lb = 0, vtype = GRB.CONTINUOUS, name = "HPactivePower")
q_hp = m.addVars(n_houses, lb = 0, vtype = GRB.CONTINUOUS, name = "HPreactivePower")
p_pv_down = m.addVars(n_houses, lb = 0, vtype = GRB.CONTINUOUS, name = "PVcurtailedActivePower")
p_ev_down = m.addVars(n_houses, lb = 0, vtype = GRB.CONTINUOUS, name = "EVcurtailedActivePower")
p_hp_down = m.addVars(n_houses, lb = 0, vtype = GRB.CONTINUOUS, name = "HPcurtailedActivePower")
p_hp_up = m.addVars(n_houses, lb = 0, vtype = GRB.CONTINUOUS, name = "HPincreasedActivePower")
p_base_curtailed = m.addVars(n_houses, lb = 0, ub = 0, vtype = GRB.CONTINUOUS, name = "CurtailedBaseActivePower")
# define constraints
# for slack bus, power balance
m.addConstr(p[0] == P[0] + P[25] + P[63] + P[94] + P[136])
m.addConstr(q[0] == Q[0] + Q[25] + Q[63] + Q[94] + Q[136])
m.addQConstr(p[0]*p[0] + q[0]*q[0] <= s_trafo**2, "trafoLimit") # transformer loading constraints, #1 additional constraint
# for non-slack bus, power balance
for j in range(1,n_bus):
P_outFlow = 0
for i in range(n_bus-1):
if epse_network.at[i,'startNode'] == j:
P_outFlow += P[epse_network.at[i,'endNode']-1]
m.addConstr(p[j] == P_outFlow - (P[j-1]-l[j-1]*epse_network.at[j-1,'r_ohm']))
for j in range(1,n_bus):
Q_outFlow = 0
for i in range(n_bus-1):
if epse_network.at[i,'startNode'] == j:
Q_outFlow += Q[epse_network.at[i,'endNode']-1]
m.addConstr(q[j] == Q_outFlow - (Q[j-1]-l[j-1]*epse_network.at[j-1,'x_ohm']))
# voltage relation
for i in range(n_bus-1):
m.addConstr(v[epse_network.at[i,'endNode']] == v[epse_network.at[i,'startNode']]\
-2*(epse_network.at[i,'r_ohm']*P[epse_network.at[i,'endNode']-1] \
+ epse_network.at[i,'x_ohm']*Q[epse_network.at[i,'endNode']-1])
+(epse_network.at[i,'r_ohm']**2+epse_network.at[i,'x_ohm']**2)*l[epse_network.at[i,'endNode']-1])
# socp constraints
for i in range(n_bus-1):
m.addQConstr(P[epse_network.at[i,'endNode']-1] * P[epse_network.at[i,'endNode']-1]\
+Q[epse_network.at[i,'endNode']-1] * Q[epse_network.at[i,'endNode']-1] <=
l[epse_network.at[i,'endNode']-1] * v[epse_network.at[i,'startNode']], name = "SOCP{}".format(i))
for i in range(n_bus):
if i not in house_index and i != 0: # slack bus + residential loads
m.addConstr(p[i] == 0)
m.addConstr(q[i] == 0)
m.addConstrs(p_houses[i] == p[house_index[i]] for i in range(n_houses))
m.addConstrs(q_houses[i] == q[house_index[i]] for i in range(n_houses))
m.addConstrs(p_houses[i] == p_pv[i] + p_base_curtailed[i] - p_baseload[i] - p_ev[i] - p_hp[i] for i in range(n_houses))
m.addConstrs(q_houses[i] == q_pv[i] +p_base_curtailed[i] * tan_phi_load - q_baseload[i] + q_ev[i] - q_hp[i] \
for i in range(n_houses))
for i in range(n_houses):
m.addQConstr(p_pv[i]*p_pv[i] + q_pv[i]*q_pv[i] <= s_pv**2, name = "ApparantPowerLimitPV{}".format(i))
m.addQConstr(p_ev[i]*p_ev[i] + q_ev[i]*q_ev[i] <= s_ev**2, name = "ApparantPowerLimitEV{}".format(i))
m.addConstr(-p_pv[i] * tan_phi_evpv <= q_pv[i])
m.addConstr(q_pv[i] <= p_pv[i] * tan_phi_evpv)
m.addConstr(-p_ev[i] * tan_phi_evpv <= q_ev[i])
m.addConstr(q_ev[i] <= p_ev[i] * tan_phi_evpv )
m.addConstr(q_hp[i] == p_hp[i] * tan_phi_load)
m.addConstr(p_ev[i] <= p_ev_max[i])
m.addConstr(p_ev_down[i] == p_ev_max[i] - p_ev[i])
m.addConstr(p_pv[i] <= p_pv_fore[i])
m.addConstr(p_pv_down[i] == p_pv_fore[i] - p_pv[i])
m.addConstr(p_hp[i] <= p_hp_max[i])
m.addConstr(p_hp_down[i] >= p_hp_set[i] - p_hp[i])
m.addConstr(p_hp_up[i] >= p_hp[i] - p_hp_set[i])
m.addConstr(p_base_curtailed[i] <= p_baseload[i]) #2 additional constraint
for i in range(n_bus-1):
m.addConstr(l[i] <= (epse_network.at[i,'currentLim_kA'])**2)
m.addConstr(v[0] == v_ref**2) #3 additional constraint
# define objective
obj = quicksum(l[i]*epse_network.at[i,'r_ohm'] * c_loss for i in range(n_bus-1))\
+ quicksum(c_baseload[i]*p_base_curtailed[i] for i in range(n_houses))\
+ quicksum(c_ev[i]*p_ev_down[i] for i in range(n_houses))\
+ quicksum(c_pv[i]*p_pv_down[i] for i in range(n_houses))\
+ quicksum(c_hp_up[i]*p_hp_up[i] for i in range(n_houses))\
+ quicksum(c_hp_down[i]*p_hp_down[i] for i in range(n_houses))
m.setObjective(obj, GRB.MINIMIZE)
# m.setParam('MIPGap', 1E-10)
# m.setParam('NonConvex', 2)
# m.setParam('NumericFocus', 3)
m.optimize()
m.write("model.mps")
dict_optimizedResults = {
"p": [p[i].X for i in range(n_bus)],
"q": [q[i].X for i in range(n_bus)],
"p_ev": [p_ev[i].X for i in range(n_houses)],
"p_houses": [-p_houses[i].X for i in range(n_houses)], # minus for consistency with power flow
"v": [np.sqrt(v[i].X)/v_ref for i in range(n_bus)],
"l": [np.sqrt(l[i].X)/epse_network.at[i,'currentLim_kA'] for i in range(n_bus-1)],
"p_ev_down": [p_ev_down[i].X for i in range(n_houses)],
"p_pv_down": [p_pv_down[i].X for i in range(n_houses)],
"p_hp_up": [p_hp_up[i].X for i in range(n_houses)],
"p_hp_down": [p_hp_down[i].X for i in range(n_houses)],
"q_ev": [q_ev[i].X for i in range(n_houses)],
"q_pv": [q_pv[i].X for i in range(n_houses)],
"P": [P[i].X for i in range(n_bus-1)],
"Q": [Q[i].X for i in range(n_bus-1)],
"q_houses": [-q_houses[i].X for i in range(n_houses)],
"p_pv": [p_pv[i].X for i in range(n_houses)],
"p_hp": [p_hp[i].X for i in range(n_houses)],
"q_hp": [q_hp[i].X for i in range(n_houses)],
"p_base_curtailed": [p_base_curtailed[i].X for i in range(n_houses)]
} #.X squeeze out values from single element array, same as np.squeeze
return dict_optimizedResults
if __name__ == "__main__":
n_houses = 182
c_loss = 40
c_baseload = np.ones(n_houses) * 5000
c_ev = np.ones(n_houses) * 200
c_hp_up = np.ones(n_houses) * 200
c_hp_down = np.ones(n_houses) * 200
c_pv = np.ones(n_houses) * 400
p_pv_fore = np.ones(n_houses) * 5e-3/3
p_ev_max = np.ones(n_houses) * 3.7e-3/3
p_hp_set = np.ones(n_houses) * 1e-3/3
p_baseload = np.ones(n_houses) * 1.5e-3/3
dict_optimizedResults = func_optimization(c_loss, c_baseload, c_ev, c_hp_up,\
c_hp_down, c_pv, p_pv_fore, p_ev_max, p_hp_set, p_baseload)
p = dict_optimizedResults["p"]
q = dict_optimizedResults["q"]
p_ev = dict_optimizedResults["p_ev"]
p_houses = dict_optimizedResults["p_houses"]
v = dict_optimizedResults["v"]
l = dict_optimizedResults["l"]
p_ev_down = dict_optimizedResults["p_ev_down"]
p_pv_down = dict_optimizedResults["p_pv_down"]
p_hp_up = dict_optimizedResults["p_hp_up"]
p_hp_down = dict_optimizedResults["p_hp_down"]
q_ev = dict_optimizedResults["q_ev"]
q_pv = dict_optimizedResults["q_pv"]
P = dict_optimizedResults["P"]
Q = dict_optimizedResults["Q"]
q_houses = dict_optimizedResults["q_houses"]
p_pv = dict_optimizedResults["p_pv"]
p_hp = dict_optimizedResults["p_hp"]
q_hp = dict_optimizedResults["q_hp"]
p_base_curtailed = dict_optimizedResults["p_base_curtailed"]
# np.array(p_pv)*np.array(p_pv) + np.array(q_pv)*np.array(q_pv) <= (3.75E-3/3)**2
print(np.array(p_ev)*np.array(p_ev) + np.array(q_ev)*np.array(q_ev) <= (3.7E-3/3)**2)
Gurobi Optimizer version 9.1.2 build v9.1.2rc0 (win64)
Thread count: 6 physical cores, 12 logical processors, using up to 12 threads
Optimize a model with 3897 rows, 3533 columns and 9295 nonzeros
Model fingerprint: 0x34a91ef3
Model has 559 quadratic constraints
Coefficient statistics:
Matrix range [3e-06, 1e+00]
QMatrix range [1e+00, 1e+00]
Objective range [6e-02, 5e+03]
Bounds range [5e-02, 6e-02]
RHS range [2e-04, 8e-02]
QRHS range [2e-06, 4e-02]
Presolve removed 1873 rows and 1133 columns
Presolve time: 0.02s
Presolved: 2959 rows, 2971 columns, 7804 nonzeros
Presolved model has 377 second-order cone constraints
Ordering time: 0.00s
Barrier statistics:
AA' NZ : 1.052e+04
Factor NZ : 2.751e+04 (roughly 3 MBytes of memory)
Factor Ops : 3.046e+05 (less than 1 second per iteration)
Threads : 1
Objective Residual
Iter Primal Dual Primal Dual Compl Time
0 2.05070280e+05 -3.08660958e+04 1.29e+01 3.31e+02 1.73e+03 0s
1 2.19335888e+05 -1.02472862e+04 3.27e+00 1.45e-01 4.11e+02 0s
2 2.24320909e+03 -5.09929184e+03 2.70e-02 1.53e-03 4.44e+00 0s
3 2.64225397e+02 -1.64580346e+03 2.30e-03 2.08e-04 5.75e-01 0s
4 8.40633504e+01 -7.31873593e+02 2.88e-04 7.31e-05 1.77e-01 0s
5 4.63350240e+01 -1.70545059e+02 3.98e-05 1.74e-05 4.34e-02 0s
6 3.51567556e+01 -3.72334243e+00 1.70e-06 2.66e-06 7.57e-03 0s
7 3.20440355e+01 1.62213111e+01 2.54e-07 1.08e-06 3.07e-03 0s
8 3.14501810e+01 2.66238038e+01 9.16e-08 3.16e-07 9.37e-04 0s
9 3.11540917e+01 2.95557412e+01 4.46e-08 9.54e-08 3.11e-04 0s
10 3.09653096e+01 3.03441617e+01 2.11e-08 3.24e-08 1.21e-04 0s
11 3.08616565e+01 3.06376577e+01 8.08e-09 1.40e-08 4.36e-05 0s
12 3.08057390e+01 3.07469451e+01 1.46e-09 3.12e-09 1.14e-05 0s
13 3.07947295e+01 3.07861565e+01 7.10e-10 2.28e-09 1.67e-06 0s
14 3.07918198e+01 3.07889494e+01 3.02e-10 1.41e-10 5.58e-07 0s
15 3.07902874e+01 3.07895271e+01 8.00e-11 2.09e-10 1.48e-07 0s
16 3.07898735e+01 3.07896256e+01 2.29e-11 6.29e-10 4.82e-08 0s
17 3.07897457e+01 3.07896622e+01 6.13e-12 7.69e-10 1.62e-08 0s
Barrier solved model in 17 iterations and 0.08 seconds
Optimal objective 3.07897457e+01
p_ev
Out[10]:
[0.001233333252782066,
0.0012333332525010464,
0.0012333332517102484,
0.001233333250372892,
0.0012333332499916679,
0.0012333332499489874,
0.0012333332503263114,
0.0012333332506982873,
0.0012333332542703067,
0.0012333332512244383,
0.00123333325139316,
0.0012333332550746,
0.0012333332515416682,
0.0012333332523684715,
0.0012333332513185624,
0.0012333332501297115,
0.0012333332502187594,
0.001233333249433389,
0.0012333332495219358,
0.001233333249329937,
0.001233333249406215,
0.0012333332494701102,
0.0012333332496593885,
0.0012333332563687852,
0.0012333332537996242,
0.001233333252463197,
0.0012333332511307675,
0.0012333332497659521,
0.0012333332504141773,
0.0012333332502574704,
0.00123333325027089,
0.001233333248771793,
0.001233333250480398,
0.0012333332505039343,
0.0012333332500927688,
0.0012333332500642751,
0.001233333249935114,
0.0012333332498628289,
0.00123333325000536,
0.0012333332499465447,
0.0012333332499082001,
0.0012333332490451314,
0.0012333332505473026,
0.0012333332506291369,
0.001233333250760434,
0.0012333332511183278,
0.001233333251284109,
0.0012333332516006597,
0.0012333332520220624,
0.0012333332523055958,
0.001233333253480267,
0.0012333332525507996,
0.0012333332520636116,
0.00123333325227984,
0.0012333332524677152,
0.0012333332526184237,
0.0012333332527373329,
0.0012333332534038978,
0.0012333332531642065,
0.0012333332517241887,
0.0012333332503338952,
0.0012333332451969147,
0.0012333332491449144,
0.0012333332533603545,
0.0012333332559667336,
0.0012333332524869878,
0.0012333332521854109,
0.0012333332552761356,
0.0012333332509511727,
0.0012333332505245248,
0.0012333332509304065,
0.0012333332521033077,
0.0012333332510161262,
0.001233333251559035,
0.001233333251999008,
0.0012333332524770025,
0.001233333252782051,
0.0012333332529143618,
0.0012333332530614686,
0.00123333325329808,
0.001233333253827112,
0.0012333332542884563,
0.00123333325496401,
0.0012333332546344824,
0.0012333332556610564,
0.0012333332566584253,
0.001233333243286641,
0.0012333332419534947,
0.001233333239432697,
0.0012333332361240048,
0.0012333332335696808,
0.0012333332313730027,
0.0012333332291553046,
0.001233333227796732,
0.0012333332260394264,
0.0012333332295156733,
0.0012333332226202455,
0.0012333332208311711,
0.0012333332242489307,
0.0012333332164269628,
0.0012333332126987034,
0.0012333332064233828,
0.0012333332108843314,
0.0012333332119932022,
0.001233333212160083,
0.0012333332117271533,
0.0012333332112160187,
0.0012333332114659757,
0.0012333332143360976,
0.0012333332116775566,
0.0012333329433020029,
0.0012333327699911704,
0.0012333326819956019,
0.0012333326028831943,
0.001233332470098713,
0.0012333323875501285,
0.0012333322498076817,
0.00123333211173316,
0.0012333318658926447,
0.0012333326488273488,
0.0012333324902222625,
0.0012333323055739797,
0.001233332109201997,
0.001233331788522198,
0.0012333313086584847,
0.0012333305689876035,
0.0007531264744131414,
0.0012333332520964326,
0.0012333332565416355,
0.001233333255038179,
0.0012333332451745548,
0.0012333332414488213,
0.0012333332390941055,
0.001233333235591954,
0.0012333332355910223,
0.001233333234396786,
0.0012333332339733221,
0.0012333332332811235,
0.001233333232602145,
0.0012333332321453156,
0.001233333231314278,
0.0012333332306874005,
0.0012333332300427866,
0.001233333229415896,
0.0012333332289996305,
0.0012333332282870577,
0.0012333332277571873,
0.0012333332271517025,
0.001233333226000865,
0.0012333332227089729,
0.001233333218709325,
0.0012333332222172605,
0.0012333332088776397,
0.0012333332344330354,
0.0012333332229862272,
0.001233333232574333,
0.0012333332342870475,
0.001233333232888928,
0.0012333332305017222,
0.0012333332283539183,
0.0012333332262169103,
0.001233333223816642,
0.001233333221459102,
0.001233333220171853,
0.0012333332186366612,
0.0012333332178176312,
0.0012333332137426211,
0.0012333332160243864,
0.0012333332470454868,
0.0012333332463591174,
0.00123333324389708,
0.0012333332453337408,
0.0012333332452322365,
0.0012333332451536574,
0.0012333332450464674,
0.0012333332451207198,
0.0012333332448803591,
0.0012333332448267917,
0.0012333332447901704,
0.001233333244587632,
0.0012333332449424642,
0.0012333332447169662]
q_ev
Out[11]:
[-1.5277253314616634e-05,
0.00037360614173411865,
0.00037523855694493235,
0.0003765956302091952,
0.00037816883005703403,
0.00037974221467751933,
0.00038077320343655183,
0.0003806983641203059,
0.000378949278803331,
0.00037877414492769454,
0.00037733767984386593,
0.000373569203437942,
0.0003729283065512942,
0.00034982145577331416,
0.0003627096131320957,
0.0003707261378307198,
0.0003749966199803653,
0.00037234999798129256,
0.0003720984050397518,
0.00036933765927170176,
0.0003668374077416811,
0.0003641113646304407,
0.00034664328438037965,
0.00039903775096147555,
0.000378941223186012,
0.00038042977260349024,
0.0002993142373910245,
0.0003740710682518846,
0.000377921180281007,
0.0003760821263988625,
0.0003736483156409993,
0.00036832970271792284,
0.0003693893832041429,
0.00036351870386342844,
0.0003482758022322873,
0.0003434797955908811,
0.00034507885671630767,
0.0003498630034054995,
0.00035528877230676443,
0.00035970797690809464,
0.0003634269062842279,
0.0003666778176301701,
0.00037069462979755235,
0.0003727051683831811,
0.0003744921609455361,
0.000375635899881211,
0.0003759187315716343,
0.0003746949241924505,
0.00036384717111727957,
0.0003572252066840983,
0.0003546402168222046,
0.00034419319924172004,
0.0003663778699450615,
0.0003602744916818296,
0.0003494635398962761,
0.0003366451374980089,
0.00032270989526903617,
0.0003116392165659691,
0.00036705792778912564,
0.0003718244202715988,
0.0003728427031712608,
0.00037212472815333,
0.00037178343730583796,
0.0003553846260991837,
0.0003583068176026689,
0.0003614723802772628,
0.00035855778150735966,
0.0003565125878807588,
0.0003546413460002336,
0.0003504526074202619,
0.0002912008523513049,
0.0002708930119952993,
0.00040080361576071285,
0.00034853658286835735,
0.0003666840917690416,
0.0003757966429554406,
0.0003718555602533748,
0.0003676118673051058,
0.0003652168750126532,
0.00037590733696184604,
0.00037331647556735893,
0.00036935311117049295,
0.00036519994962676034,
0.0003602605626502151,
0.00035421061177901605,
0.0003218121162976321,
0.0004053704323529162,
0.0004053709275406744,
0.0004053713369190403,
0.00040537185811238277,
0.0004053724818487709,
0.0004053730939673325,
0.000405373619733065,
0.0004053740436585927,
0.0004053743984342177,
0.0004053744457675026,
0.00040537499054057216,
0.0004053752286658731,
0.0004053752518995869,
0.0004053756302033533,
0.0004053758249560817,
0.0004053760259529834,
0.00040537595544512116,
0.000405375929108169,
0.0004053759176553948,
0.00040537592308126624,
0.00040537594523833696,
0.0004053760155190308,
0.00040537573867044336,
0.00040537609888249176,
0.00040537631333804804,
0.00040537628683408935,
0.0004053762667819521,
0.00040537624700120886,
0.00040537621225666183,
0.00040537618749225316,
0.00040537614397956437,
0.0004053759683728894,
0.00040537602871328093,
0.00040537626115778603,
0.00040537622104304556,
0.0004053761716530331,
0.00040537611691604834,
0.0004053760213406481,
0.00040537587472792635,
0.0004053756445819304,
0.0002475402187311366,
0.00039303593581517304,
0.0003969142667244717,
0.0003972811995423591,
0.0003913430303771793,
0.000390851247472809,
0.0003862900952042909,
0.00021201670933272037,
0.000382923257737441,
0.0003850865145056343,
0.0003856329571606935,
0.0003859178232937027,
0.00038617204098006564,
0.00038636983151256075,
0.0003863566390854425,
0.000385676007696241,
0.00038358780843017107,
0.0003785835474730043,
0.0003669594382101524,
0.00033820908956056113,
0.000355240239661575,
0.00035845942054637376,
0.00033173941325878196,
0.00034285888194438366,
0.00034562825250420196,
0.000363323822282177,
0.00036108569139026994,
0.0003632904758418646,
0.0003537031975528387,
0.00035582180338959425,
0.00035161046811082395,
0.0003594906620172991,
0.0003657699896286284,
0.0003714040903128629,
0.00037634010221674393,
0.00038060109565409976,
0.0003795107452805929,
0.0003683494335068236,
0.0003507639718658886,
0.00033059496327534233,
0.0003414332971095936,
0.00034896597883785204,
0.00038129696013731903,
0.0003775997698430381,
0.0003772372028438467,
0.0003771177935785762,
0.00037711429291828897,
0.00037628626053609686,
0.00037458280567339046,
0.00037234131788860416,
0.00036948683211101885,
0.00036469071408198927,
0.00035815449750258325,
0.00035016311590584874,
0.0003421319277170009,
0.0003374571156860299]
q_ev
Out[12]:
[-1.5277253314616634e-05,
0.00037360614173411865,
0.00037523855694493235,
0.0003765956302091952,
0.00037816883005703403,
0.00037974221467751933,
0.00038077320343655183,
0.0003806983641203059,
0.000378949278803331,
0.00037877414492769454,
0.00037733767984386593,
0.000373569203437942,
0.0003729283065512942,
0.00034982145577331416,
0.0003627096131320957,
0.0003707261378307198,
0.0003749966199803653,
0.00037234999798129256,
0.0003720984050397518,
0.00036933765927170176,
0.0003668374077416811,
0.0003641113646304407,
0.00034664328438037965,
0.00039903775096147555,
0.000378941223186012,
0.00038042977260349024,
0.0002993142373910245,
0.0003740710682518846,
0.000377921180281007,
0.0003760821263988625,
0.0003736483156409993,
0.00036832970271792284,
0.0003693893832041429,
0.00036351870386342844,
0.0003482758022322873,
0.0003434797955908811,
0.00034507885671630767,
0.0003498630034054995,
0.00035528877230676443,
0.00035970797690809464,
0.0003634269062842279,
0.0003666778176301701,
0.00037069462979755235,
0.0003727051683831811,
0.0003744921609455361,
0.000375635899881211,
0.0003759187315716343,
0.0003746949241924505,
0.00036384717111727957,
0.0003572252066840983,
0.0003546402168222046,
0.00034419319924172004,
0.0003663778699450615,
0.0003602744916818296,
0.0003494635398962761,
0.0003366451374980089,
0.00032270989526903617,
0.0003116392165659691,
0.00036705792778912564,
0.0003718244202715988,
0.0003728427031712608,
0.00037212472815333,
0.00037178343730583796,
0.0003553846260991837,
0.0003583068176026689,
0.0003614723802772628,
0.00035855778150735966,
0.0003565125878807588,
0.0003546413460002336,
0.0003504526074202619,
0.0002912008523513049,
0.0002708930119952993,
0.00040080361576071285,
0.00034853658286835735,
0.0003666840917690416,
0.0003757966429554406,
0.0003718555602533748,
0.0003676118673051058,
0.0003652168750126532,
0.00037590733696184604,
0.00037331647556735893,
0.00036935311117049295,
0.00036519994962676034,
0.0003602605626502151,
0.00035421061177901605,
0.0003218121162976321,
0.0004053704323529162,
0.0004053709275406744,
0.0004053713369190403,
0.00040537185811238277,
0.0004053724818487709,
0.0004053730939673325,
0.000405373619733065,
0.0004053740436585927,
0.0004053743984342177,
0.0004053744457675026,
0.00040537499054057216,
0.0004053752286658731,
0.0004053752518995869,
0.0004053756302033533,
0.0004053758249560817,
0.0004053760259529834,
0.00040537595544512116,
0.000405375929108169,
0.0004053759176553948,
0.00040537592308126624,
0.00040537594523833696,
0.0004053760155190308,
0.00040537573867044336,
0.00040537609888249176,
0.00040537631333804804,
0.00040537628683408935,
0.0004053762667819521,
0.00040537624700120886,
0.00040537621225666183,
0.00040537618749225316,
0.00040537614397956437,
0.0004053759683728894,
0.00040537602871328093,
0.00040537626115778603,
0.00040537622104304556,
0.0004053761716530331,
0.00040537611691604834,
0.0004053760213406481,
0.00040537587472792635,
0.0004053756445819304,
0.0002475402187311366,
0.00039303593581517304,
0.0003969142667244717,
0.0003972811995423591,
0.0003913430303771793,
0.000390851247472809,
0.0003862900952042909,
0.00021201670933272037,
0.000382923257737441,
0.0003850865145056343,
0.0003856329571606935,
0.0003859178232937027,
0.00038617204098006564,
0.00038636983151256075,
0.0003863566390854425,
0.000385676007696241,
0.00038358780843017107,
0.0003785835474730043,
0.0003669594382101524,
0.00033820908956056113,
0.000355240239661575,
0.00035845942054637376,
0.00033173941325878196,
0.00034285888194438366,
0.00034562825250420196,
0.000363323822282177,
0.00036108569139026994,
0.0003632904758418646,
0.0003537031975528387,
0.00035582180338959425,
0.00035161046811082395,
0.0003594906620172991,
0.0003657699896286284,
0.0003714040903128629,
0.00037634010221674393,
0.00038060109565409976,
0.0003795107452805929,
0.0003683494335068236,
0.0003507639718658886,
0.00033059496327534233,
0.0003414332971095936,
0.00034896597883785204,
0.00038129696013731903,
0.0003775997698430381,
0.0003772372028438467,
0.0003771177935785762,
0.00037711429291828897,
0.00037628626053609686,
0.00037458280567339046,
0.00037234131788860416,
0.00036948683211101885,
0.00036469071408198927,
0.00035815449750258325,
0.00035016311590584874,
0.0003421319277170009,
0.0003374571156860299]
-
Official comment
This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum. Or why not try our AI Gurobot?. -
Hi Sen,
Could you show me which values of 'ApparantPowerLimitEV' are violated?
Also, it often helps to use the Model.printQuality() to check the feasibility of the most violated bound, constraint, or integrality if there are any violated. It will give you output like the following:
Solution quality statistics for model Unnamed :
Maximum violation:
Bound : 0.00000000e+00
Constraint : 0.00000000e+00
Integrality : 0.00000000e+00Can you run m.printQuality() after you call m.optimize() and show us the results? We would expect the values for your 'ApparantPowerLimitEV' constraint to be less than the FeasibilityTol (default 1e-6).
1 -
Hi Alison,
Element-wise, p_ev[i]^2 + q_ev[i]^2 should be less than (1.2333E-3)^2, while in the optimized results, p_ev[i] is 1.2333E-3, q_ev = 0.4E-3, so the constraints are not satisfied. Please also find below output from printQuality function. Could you share any insight on this? Thanks!
Solution quality statistics for model GEC :
Maximum violation (unscaled/scaled):
Bound : 0.00000000e+00 / 0.00000000e+00
Constraint : 1.64329481e-07 / 1.64329481e-07 (ApparantPowerLimitEV109)0 -
Hi Alison,
The problem is solved for me. I understand from the printQuality() output that my optimization problem has a violation of 1.64E-7, which is not acceptable for me while being acceptable for Gurobi under default setting. So I can either change the Gurobi default setting to a smaller value like 1E-9 or enlarge the violation by multiplying a large number on both sides of the inequality constraints.
Best regards,
Sen
0 -
Sen, that's exactly right.
You can always tighten the FeasibilityTol (default 1e-6) or, if you simply want to tighten that single constraint, scale the constraint.
Good find!
0
Post is closed for comments.
Comments
5 comments