@@ -4,6 +4,7 @@ function goc3_model(
44 T = Float64,
55 include_ctg = true , # contingencies will be specified in input data
66 result_set = [],
7+ user_callback = dummy_extension,
78 kwargs...
89 )
910
@@ -241,10 +242,11 @@ function goc3_model(
241242 end
242243
243244 # 4.2.1 Bus power mismatch and penalized mismatch definitions
244- c_11 = constraint (core, p_it_plus[b. i, b. t] - p_it[b. i, b. t] for b in sc_data. busarray; ucon = fill (Inf , size (sc_data. busarray)))
245- c_12 = constraint (core, p_it_plus[b. i, b. t] + p_it[b. i, b. t] for b in sc_data. busarray; ucon = fill (Inf , size (sc_data. busarray)))
246- c_13 = constraint (core, q_it_plus[b. i, b. t] - q_it[b. i, b. t] for b in sc_data. busarray; ucon = fill (Inf , size (sc_data. busarray)))
247- c_14 = constraint (core, q_it_plus[b. i, b. t] + q_it[b. i, b. t] for b in sc_data. busarray; ucon = fill (Inf , size (sc_data. busarray)))
245+ c11 = constraint (core, p_it_plus[b. i, b. t] - p_it[b. i, b. t] for b in sc_data. busarray; ucon = fill (Inf , size (sc_data. busarray)))
246+ c12 = constraint (core, p_it_plus[b. i, b. t] + p_it[b. i, b. t] for b in sc_data. busarray; ucon = fill (Inf , size (sc_data. busarray)))
247+ c13 = constraint (core, q_it_plus[b. i, b. t] - q_it[b. i, b. t] for b in sc_data. busarray; ucon = fill (Inf , size (sc_data. busarray)))
248+ c14 = constraint (core, q_it_plus[b. i, b. t] + q_it[b. i, b. t] for b in sc_data. busarray; ucon = fill (Inf , size (sc_data. busarray)))
249+ cons = (c11= c11, c12= c12, c13= c13, c14= c14)
248250 # 4.2.2 Bus pwoer mismatch penalty
249251 c15 = constraint (core, z_it_p[b. i, b. t] - b. dt* sum (sc_data. c_p)* p_it_plus[b. i, b. t] for b in sc_data. busarray)
250252 c16 = constraint (core, z_it_q[b. i, b. t] - b. dt* sum (sc_data. c_q)* q_it_plus[b. i, b. t] for b in sc_data. busarray)
@@ -254,6 +256,7 @@ function goc3_model(
254256 c17_cs = constraint! (core, c17, cs. bus + I* (cs. t- 1 ) => - p_jt_cs[cs. j_cs, cs. t] for cs in sc_data. csarray)
255257 c17_sh = constraint! (core, c17, sh. bus + I* (sh. t- 1 ) => - p_jt_sh[sh. j_sh, sh. t] for sh in sc_data. shuntarray)
256258
259+
257260 # Reminder: fr and to split for ln, xf, and dc
258261 c17_fr_ln = constraint! (core, c17, ln. fr_bus + I* (ln. t- 1 ) => - p_jt_fr_ln[ln. j_ln, ln. t] for ln in sc_data. aclbrancharray)
259262 c17_fr_xf = constraint! (core, c17, xf. fr_bus + I* (xf. t- 1 ) => - p_jt_fr_xf[xf. j_xf, xf. t] for xf in sc_data. acxbrancharray)
@@ -272,7 +275,6 @@ function goc3_model(
272275 c18_to_ln = constraint! (core, c18, ln. to_bus + I* (ln. t- 1 ) => - q_jt_to_ln[ln. j_ln, ln. t] for ln in sc_data. aclbrancharray)
273276 c18_to_xf = constraint! (core, c18, xf. to_bus + I* (xf. t- 1 ) => - q_jt_to_xf[xf. j_xf, xf. t] for xf in sc_data. acxbrancharray)
274277 c18_to_dc = constraint! (core, c18, dc. to_bus + I* (dc. t- 1 ) => - q_jt_to_dc[dc. j_dc, dc. t] for dc in sc_data. dclinearray)
275-
276278
277279 # 4.3.2 Reserve shortfall penalties
278280 c28 = constraint (core, z_nt_rgu[n. n_p, n. t] - n. dt* n. c_rgu* p_nt_rgu_plus[n. n_p, n. t] for n in sc_data. preservearray)
@@ -283,7 +285,6 @@ function goc3_model(
283285 c33 = constraint (core, z_nt_rrd[n. n_p, n. t] - n. dt* n. c_rrd* p_nt_rrd_plus[n. n_p, n. t] for n in sc_data. preservearray)
284286 c34 = constraint (core, z_nt_qru[n. n_q, n. t] - n. dt* n. c_qru* q_nt_qru_plus[n. n_q, n. t] for n in sc_data. qreservearray)
285287 c35 = constraint (core, z_nt_qrd[n. n_q, n. t] - n. dt* n. c_qrd* q_nt_qrd_plus[n. n_q, n. t] for n in sc_data. qreservearray)
286-
287288
288289 # 4.3.3 Reserve requirements
289290 c36 = constraint (core, p_nt_rgu_req[n. n_p, n. t]/ n. σ_rgu for n in sc_data. preservearray)
@@ -477,7 +478,6 @@ function goc3_model(
477478
478479 # 4.8.3 AC branch flows
479480
480-
481481 c148_ln = constraint (core, - p_jt_fr_ln[ln. j_ln, ln. t] + ln. u_on* ((ln. g_sr+ ln. g_fr)* v_it[ln. fr_bus, ln. t]^ 2 + (- ln. g_sr* cos (θ_it[ln. fr_bus, ln. t] - θ_it[ln. to_bus, ln. t])
482482 - ln. b_sr* sin (θ_it[ln. fr_bus, ln. t] - θ_it[ln. to_bus, ln. t]))* v_it[ln. fr_bus, ln. t]* v_it[ln. to_bus, ln. t]) for ln in sc_data. aclbrancharray)
483483 c148_xf = constraint (core, - p_jt_fr_xf[xf. j_xf, xf. t] + xf. u_on* ((xf. g_sr+ xf. g_fr)* v_it[xf. fr_bus, xf. t]^ 2 / (τ_jt_xf[xf. j_xf, xf. t]^ 2 ) + (- xf. g_sr* cos (θ_it[xf. fr_bus, xf. t] - θ_it[xf. to_bus, xf. t] - φ_jt_xf[xf. j_xf, xf. t])
@@ -494,7 +494,6 @@ function goc3_model(
494494 + ln. g_sr* sin (θ_it[ln. fr_bus, ln. t] - θ_it[ln. to_bus, ln. t]))* v_it[ln. fr_bus, ln. t]* v_it[ln. to_bus, ln. t]) for ln in sc_data. aclbrancharray)
495495 c151_xf = constraint (core, - q_jt_to_xf[xf. j_xf, xf. t] + xf. u_on* ((- xf. b_sr- xf. b_to- xf. b_ch/ 2 )* v_it[xf. to_bus, xf. t]^ 2 + (xf. b_sr* cos (θ_it[xf. fr_bus, xf. t] - θ_it[xf. to_bus, xf. t] - φ_jt_xf[xf. j_xf, xf. t])
496496 + xf. g_sr* sin (θ_it[xf. fr_bus, xf. t] - θ_it[xf. to_bus, xf. t] - φ_jt_xf[xf. j_xf, xf. t]))* v_it[xf. fr_bus, xf. t]* v_it[xf. to_bus, xf. t]/ τ_jt_xf[xf. j_xf, xf. t]) for xf in sc_data. acxbrancharray)
497-
498497
499498 # 4.8.4 DC lines
500499 c156 = constraint (core, p_jt_fr_dc[dc. j_dc, dc. t] + p_jt_to_dc[dc. j_dc, dc. t] for dc in sc_data. dclinearray)
@@ -535,11 +534,10 @@ function goc3_model(
535534 c163_sh = constraint! (core, c163, sh. bus + I* (sh. t- 1 ) + I* L_T* (sh. k- 1 ) => - p_jt_sh[sh. j_sh, sh. t] for sh in sc_data. k_shuntarray)
536535 c163_dc_fr = constraint! (core, c163, dc. fr_bus + I* (dc. t- 1 ) + I* L_T* (dc. ctg- 1 ) => - p_jt_fr_dc[dc. j_dc, dc. t] for dc in sc_data. jtk_dc_flattened)
537536 c163_dc_to = constraint! (core, c163, dc. to_bus + I* (dc. t- 1 ) + I* L_T* (dc. ctg- 1 ) => - p_jt_fr_dc[dc. j_dc, dc. t] for dc in sc_data. jtk_dc_flattened)
537+
538538 end
539539
540540
541- model = ExaModel (core; kwargs... )
542-
543541 vars = (b_jt_sh = b_jt_sh,
544542 g_jt_sh = g_jt_sh,
545543 # Split e_w_plus into separate sets for W_en_min and W_en_max ad for pr, cs
@@ -657,6 +655,128 @@ function goc3_model(
657655 τ_jt_xf = τ_jt_xf,
658656 φ_jt_xf = φ_jt_xf)
659657
658+ cons = (
659+ c11 = c11,
660+ c12 = c12,
661+ c13 = c13,
662+ c14 = c14,
663+ c15 = c15,
664+ c16 = c16,
665+ c17 = c17,
666+ c18 = c18,
667+ c28 = c28,
668+ c29 = c29,
669+ c30 = c30,
670+ c31 = c31,
671+ c32 = c32,
672+ c33 = c33,
673+ c34 = c34,
674+ c35 = c35,
675+ c36 = c36,
676+ c37 = c37,
677+ cmax38 = cmax38,
678+ c38 = c38,
679+ c39 = c39,
680+ c40 = c40,
681+ c41 = c41,
682+ c42 = c42,
683+ c43 = c43,
684+ c44 = c44,
685+ c45 = c45,
686+ c46 = c46,
687+ c47 = c47,
688+ c68_pr = c68_pr,
689+ c68_cs = c68_cs,
690+ c69_pr = c69_pr,
691+ c69_cs = c69_cs,
692+ c70_pr = c70_pr,
693+ c70_cs = c70_cs,
694+ c71_pr = c71_pr,
695+ c71_cs = c71_cs,
696+ c72_pr = c72_pr,
697+ c72_cs = c72_cs,
698+ c73_pr = c73_pr,
699+ c73_cs = c73_cs,
700+ c74_pr = c74_pr,
701+ c74_cs = c74_cs,
702+ c75_pr = c75_pr,
703+ c75_cs = c75_cs,
704+ c76_pr = c76_pr,
705+ c76_cs = c76_cs,
706+ c78_pr = c78_pr,
707+ c78_cs = c78_cs,
708+ c79_pr = c79_pr,
709+ c79_cs = c79_cs,
710+ c94_pr = c94_pr,
711+ c94_cs = c94_cs,
712+ c95_pr = c95_pr,
713+ c95_cs = c95_cs,
714+ c96_pr = c96_pr,
715+ c96_cs = c96_cs,
716+ c97_pr = c97_pr,
717+ c97_cs = c97_cs,
718+ c98_pr = c98_pr,
719+ c98_cs = c98_cs,
720+ c99_pr = c99_pr,
721+ c99_cs = c99_cs,
722+ c100_pr = c100_pr,
723+ c100_cs = c100_cs,
724+ c101_pr = c101_pr,
725+ c102_pr = c102_pr,
726+ c102_cs = c102_cs,
727+ c103_pr = c103_pr,
728+ c104_pr = c104_pr,
729+ c104_cs = c104_cs,
730+ c105_cs = c105_cs,
731+ c109 = c109,
732+ c110 = c110,
733+ c111 = c111,
734+ c112 = c112,
735+ c113 = c113,
736+ c114 = c114,
737+ c115 = c115,
738+ c116 = c116,
739+ c117 = c117,
740+ c118 = c118,
741+ c119 = c119,
742+ c120 = c120,
743+ c121 = c121,
744+ c122 = c122,
745+ c123 = c123,
746+ c124 = c124,
747+ c125 = c125,
748+ c126 = c126,
749+ c127 = c127,
750+ c128 = c128,
751+ c130_pr = c130_pr,
752+ c130_cs = c130_cs,
753+ c131_pr = c131_pr,
754+ c131_cs = c131_cs,
755+ c132 = c132,
756+ c133 = c133,
757+ c134 = c134,
758+ c135 = c135,
759+ c139_ln = c139_ln,
760+ c139_xf = c139_xf,
761+ c140_ln = c140_ln,
762+ c140_xf = c140_xf,
763+ c141_ln = c141_ln,
764+ c141_xf = c141_xf,
765+ c144 = c144,
766+ c145 = c145,
767+ c146 = c146,
768+ c147 = c147,
769+ c148_ln = c148_ln,
770+ c148_xf = c148_xf,
771+ c149_ln = c149_ln,
772+ c149_xf = c149_xf,
773+ c150_ln = c150_ln,
774+ c150_xf = c150_xf,
775+ c151_ln = c151_ln,
776+ c151_xf = c151_xf,
777+ c156 = c156
778+ )
779+
660780 if include_ctg
661781 vars = (;vars... ,
662782 s_jtk_plus_ln = s_jtk_plus_ln,
@@ -670,11 +790,30 @@ function goc3_model(
670790 z_tk_ctg = z_tk_ctg,
671791 z_t_ctg_min = z_t_ctg_min,
672792 z_t_ctg_avg = z_t_ctg_avg)
793+ cons = (;cons... ,
794+ c4= c4,
795+ c5= c5,
796+ c10= c10,
797+ c158_ln= c158_ln,
798+ c158_xf= c158_xf,
799+ c159_ln= c159_ln,
800+ c159_xf= c159_xf,
801+ c160_ln= c160_ln,
802+ c160_xf= c160_xf,
803+ c161_ln= c161_ln,
804+ c161_xf= c161_xf,
805+ c162= c162,
806+ c163= c163)
673807 end
674808
809+ vars2, cons2 = user_callback (core, vars, cons)
810+ model = ExaModel (core; kwargs... )
811+
812+ vars = (;vars... , vars2... )
813+ cons = (;cons... , cons2... )
675814
676815 @info " built model"
677- return model, sc_data_array , vars, lengths
816+ return model, cons , vars, lengths, sc_data_array
678817
679818end
680819
0 commit comments