OPF in AMPL — amplpower 0.0.0 documentation

# OPF in AMPL

Optimal Power Flow

      1########## SETS ##########
      2
      3set N;
      4set G;
      5set L;
      6
      7########## PARAMETERS ##########
      8
      9param OPF_TYPE symbolic;
     10param CONNECTIVITY symbolic;
     11param BASEMVA;
     12param MAXANGLE;
     13param MINANGLE;
     14param COST_2 {G};
     15param COST_1 {G};
     16param COST_0 {G};
     17param PG {G};
     18param QG {G};
     19param PMAX {G};
     20param PMIN {G};
     21param QMAX {G};
     22param QMIN {G};
     23param GEN_BUS {G};
     24param PD {N};
     25param QD {N};
     26param GS {N};
     27param BS {N};
     28param VMAX {N};
     29param VMIN {N};
     30param AMAX {N};
     31param AMIN {N};
     32param VOL0 {N};
     33param ANG0 {N};
     34param VOLR0 {N};
     35param VOLI0 {N};
     36param CF {L,N};
     37param CT {L,N};
     38param CG {G,N};
     39param GFF {L};
     40param BFF {L};
     41param GFT {L};
     42param BFT {L};
     43param GTF {L};
     44param BTF {L};
     45param GTT {L};
     46param BTT {L};
     47param BUS_I {N};
     48param BUS_TYPE {N};
     49param BUS_AREA {N};
     50param VM {N};
     51param VA {N};
     52param BASE_KV {N};
     53param ZONE {N};
     54param F_BUS {L};
     55param T_BUS {L};
     56param BR_R {L};
     57param BR_X {L};
     58param BR_B {L};
     59param RATE_A {L};
     60param RATE_B {L};
     61param RATE_C {L};
     62param TAP {L};
     63param SHIFT {L};
     64param BR_STATUS {L};
     65param ANGMIN {L};
     66param ANGMAX {L};
     67param VG {G};
     68param MBASE {G};
     69param GEN_STATUS {G};
     70param PC1 {G};
     71param PC2 {G};
     72param QC1MIN {G};
     73param QC1MAX {G};
     74param QC2MIN {G};
     75param QC2MAX {G};
     76param RAMP_AGC {G};
     77param RAMP_10 {G};
     78param RAMP_30 {G};
     79param RAMP_Q {G};
     80param APF {G};
     81param MODEL {G};
     82param STARTUP {G};
     83param SHUTDOWN {G};
     84param NCOST {G};
     85param PG0 {G};
     86param QG0 {G};
     87param PF0 {L};
     88param QF0 {L};
     89param PT0 {L};
     90param QT0 {L};
     91param PFLODC {L};
     92param PFUPDC {L};
     93param PFLOAC {L};
     94param PFUPAC {L};
     95param PTLOAC {L};
     96param PTUPAC {L};
     97param QFLOAC {L};
     98param QFUPAC {L};
     99param QTLOAC {L};
    100param QTUPAC {L};
    101param COSFTMAX {L};
    102param COSFTMIN {L};
    103param SINFTMAX {L};
    104param SINFTMIN {L};
    105param VRMAX {N};
    106param VRMIN {N};
    107param VIMAX {N};
    108param VIMIN {N};
    109
    110########## VARIABLES ##########
    111
    112var Pg {g in G} >= PMIN[g], <= PMAX[g]:= PG0[g];
    113var Qg {g in G} >= QMIN[g], <= QMAX[g]:= QG0[g];
    114var Pf {l in L} >= -RATE_A[l], <=RATE_A[l] := PF0[l];
    115var Pt {l in L} >= -RATE_A[l], <=RATE_A[l] := PT0[l];
    116var Qf {l in L} >= -RATE_A[l], <=RATE_A[l] := QF0[l];
    117var Qt {l in L} >= -RATE_A[l], <=RATE_A[l] := QT0[l];
    118var Vm {n in N} >= VMIN[n], <= VMAX[n] := VOL0[n];
    119var Vr {n in N} >= VRMIN[n], <=VRMAX[n] := VOLR0[n];
    120var Vi {n in N} >= VIMIN[n], <=VIMAX[n] := VOLI0[n];
    121var V2 {n in N} >= VMIN[n]^2, <= VMAX[n]^2 := VOL0[n]^2;
    122var Va {n in N} >= AMIN[n], <= AMAX[n] := ANG0[n];
    123var cosft {l in L} >= COSFTMIN[l], <= COSFTMAX[l] := VOL0[F_BUS[l]]*VOL0[T_BUS[l]]*cos(ANG0[F_BUS[l]]-ANG0[T_BUS[l]]);
    124var sinft {l in L} >= SINFTMIN[l], <= SINFTMAX[l] := VOL0[F_BUS[l]]*VOL0[T_BUS[l]]*sin(ANG0[F_BUS[l]]-ANG0[T_BUS[l]]);
    125var Pfa {l in L} >= min(PFLODC[l],PFLOAC[l]), <= max(PFUPDC[l],PFUPAC[l]) := PF0[l];
    126var Pta {l in L} >= PTLOAC[l], <= PTUPAC[l] := PT0[l];
    127var Qfa {l in L} >= QFLOAC[l], <= QFUPAC[l] := QF0[l];
    128var Qta {l in L} >= QTLOAC[l], <= QTUPAC[l] := QT0[l];
    129var u {n in N} >= 1, <= card(N);
    130var status {l in L} binary;
    131var statusf {l in L} binary;
    132var statust {l in L} binary;
    133
    134########## OBJECTIVE FUNCTION ##########
    135
    136minimize total_cost:
    137    sum {g in G} (COST_2[g] * (BASEMVA*Pg[g])^2 + COST_1[g] * (BASEMVA*Pg[g]) + COST_0[g]);
    138
    139########## POWER BALANCE ##########
    140
    141subject to active_power_balance_1 {n in N:OPF_TYPE='dc'}:
    142    sum {g in G} CG[g,n] * Pg[g] - PD[n] = sum {l in L} (CF[l,n] * Pf[l] + CT[l,n] * Pt[l]);
    143
    144subject to active_power_balance_2 {n in N:OPF_TYPE='acpolar'}:
    145    sum {g in G} CG[g,n] * Pg[g] - PD[n] = GS[n]*Vm[n]*Vm[n] + sum {l in L} (CF[l,n] * Pf[l] + CT[l,n] * Pt[l]);
    146
    147subject to reactive_power_balance_2 {n in N:OPF_TYPE='acpolar'}:
    148    sum {g in G} CG[g,n] * Qg[g] - QD[n] = -BS[n]*Vm[n]*Vm[n] + sum {l in L} (CF[l,n] * Qf[l] + CT[l,n] * Qt[l]);
    149
    150subject to active_power_balance_3_4 {n in N: OPF_TYPE = 'acrect' or OPF_TYPE = 'acjabr'}:
    151    sum {g in G} CG[g,n] * Pg[g] - PD[n] = GS[n]*V2[n] + sum {l in L} (CF[l,n] * Pf[l] + CT[l,n] * Pt[l]);
    152
    153subject to reactive_power_balance_3_4 {n in N: OPF_TYPE = 'acrect' or OPF_TYPE = 'acjabr'}:
    154    sum {g in G} CG[g,n] * Qg[g] - QD[n] = -BS[n]*V2[n] + sum {l in L} (CF[l,n] * Qf[l] + CT[l,n] * Qt[l]);
    155
    156########## POWER FLOW DEFINITIONS (BR_STATUS = 0) ##########
    157
    158subject to active_flow_from_0 {l in L:BR_STATUS[l] == 0}:
    159    Pf[l] = 0;
    160
    161subject to active_flow_to_0 {l in L:BR_STATUS[l] == 0}:
    162    Pt[l] = 0;
    163
    164subject to reactive_flow_from_0 {l in L:BR_STATUS[l] == 0}:
    165    Qf[l] = 0;
    166
    167subject to reactive_flow_to_0 {l in L:BR_STATUS[l] == 0}:
    168    Qt[l] = 0;
    169
    170########## POWER FLOW DEFINITIONS (BR_STATUS = 1) ##########
    171
    172subject to active_flow_from_1 {l in L:OPF_TYPE='dc' and BR_STATUS[l] == 1}:
    173    Pf[l] = (1 / BR_X[l]) * (Va[F_BUS[l]] - Va[T_BUS[l]]);
    174
    175subject to active_flow_to_1 {l in L:OPF_TYPE='dc' and BR_STATUS[l] == 1}:
    176    Pt[l] = (1 / BR_X[l]) * (Va[T_BUS[l]] - Va[F_BUS[l]]);
    177
    178subject to active_flow_from_2 {l in L:OPF_TYPE='acpolar' and BR_STATUS[l] == 1}:
    179    Pf[l] = GFF[l]*Vm[F_BUS[l]]*Vm[F_BUS[l]] + Vm[F_BUS[l]]*Vm[T_BUS[l]]*(GFT[l]*cos(Va[F_BUS[l]]-Va[T_BUS[l]])+BFT[l]*sin(Va[F_BUS[l]]-Va[T_BUS[l]]));
    180
    181subject to active_flow_to_2 {l in L:OPF_TYPE='acpolar' and BR_STATUS[l] == 1}:
    182    Pt[l] = GTT[l]*Vm[T_BUS[l]]*Vm[T_BUS[l]] + Vm[F_BUS[l]]*Vm[T_BUS[l]]*(GTF[l]*cos(Va[T_BUS[l]]-Va[F_BUS[l]])+BTF[l]*sin(Va[T_BUS[l]]-Va[F_BUS[l]]));
    183
    184subject to reactive_flow_from_2 {l in L:OPF_TYPE='acpolar' and BR_STATUS[l] == 1}:
    185    Qf[l] = -BFF[l]*Vm[F_BUS[l]]*Vm[F_BUS[l]] - Vm[F_BUS[l]]*Vm[T_BUS[l]]*(BFT[l]*cos(Va[F_BUS[l]]-Va[T_BUS[l]])-GFT[l]*sin(Va[F_BUS[l]]-Va[T_BUS[l]]));
    186
    187subject to reactive_flow_to_2 {l in L:OPF_TYPE='acpolar' and BR_STATUS[l] == 1}:
    188    Qt[l] = -BTT[l]*Vm[T_BUS[l]]*Vm[T_BUS[l]] - Vm[F_BUS[l]]*Vm[T_BUS[l]]*(BTF[l]*cos(Va[T_BUS[l]]-Va[F_BUS[l]])-GTF[l]*sin(Va[T_BUS[l]]-Va[F_BUS[l]]));
    189
    190subject to active_flow_from_3_4 {l in L:(OPF_TYPE='acrect' or OPF_TYPE = 'acjabr') and BR_STATUS[l] == 1}:
    191    Pf[l] = GFF[l]*V2[F_BUS[l]] + GFT[l]*cosft[l] + BFT[l]*sinft[l];
    192
    193subject to active_flow_to_3_4 {l in L:(OPF_TYPE='acrect' or OPF_TYPE = 'acjabr') and BR_STATUS[l] == 1}:
    194    Pt[l] = GTT[l]*V2[T_BUS[l]] + GTF[l]*cosft[l] - BTF[l]*sinft[l];
    195
    196subject to reactive_flow_from_3_4 {l in L:(OPF_TYPE='acrect' or OPF_TYPE = 'acjabr') and BR_STATUS[l] == 1}:
    197    Qf[l] = -BFF[l]*V2[F_BUS[l]] - BFT[l]*cosft[l] + GFT[l]*sinft[l];
    198
    199subject to reactive_flow_to_3_4 {l in L:(OPF_TYPE='acrect' or OPF_TYPE = 'acjabr') and BR_STATUS[l] == 1}:
    200    Qt[l] = -BTT[l]*V2[T_BUS[l]] - BTF[l]*cosft[l] - GTF[l]*sinft[l];
    201
    202########## POWER FLOW DEFINITIONS (BR_STATUS = 2) ##########
    203
    204subject to active_flow_from_1_switch {l in L: OPF_TYPE == 'dc' and BR_STATUS[l] == 2}:
    205    Pf[l] = status[l] * (1 / BR_X[l]) * (Va[F_BUS[l]] - Va[T_BUS[l]]);
    206
    207subject to active_flow_to_1_switch {l in L: OPF_TYPE == 'dc' and BR_STATUS[l] == 2}:
    208    Pt[l] = status[l] * (1 / BR_X[l]) * (Va[T_BUS[l]] - Va[F_BUS[l]]);
    209
    210subject to active_flow_from_2_switch {l in L: OPF_TYPE == 'acpolar' and BR_STATUS[l] == 2}:
    211    Pf[l] = status[l] * (GFF[l]*Vm[F_BUS[l]]*Vm[F_BUS[l]] + Vm[F_BUS[l]]*Vm[T_BUS[l]]*(GFT[l]*cos(Va[F_BUS[l]]-Va[T_BUS[l]])+BFT[l]*sin(Va[F_BUS[l]]-Va[T_BUS[l]])));
    212
    213subject to active_flow_to_2_switch {l in L: OPF_TYPE == 'acpolar' and BR_STATUS[l] == 2}:
    214    Pt[l] = status[l] * (GTT[l]*Vm[T_BUS[l]]*Vm[T_BUS[l]] + Vm[F_BUS[l]]*Vm[T_BUS[l]]*(GTF[l]*cos(Va[T_BUS[l]]-Va[F_BUS[l]])+BTF[l]*sin(Va[T_BUS[l]]-Va[F_BUS[l]])));
    215
    216subject to reactive_flow_from_2_switch {l in L: OPF_TYPE == 'acpolar' and BR_STATUS[l] == 2}:
    217    Qf[l] = status[l] * (-BFF[l]*Vm[F_BUS[l]]*Vm[F_BUS[l]] - Vm[F_BUS[l]]*Vm[T_BUS[l]]*(BFT[l]*cos(Va[F_BUS[l]]-Va[T_BUS[l]])-GFT[l]*sin(Va[F_BUS[l]]-Va[T_BUS[l]])));
    218
    219subject to reactive_flow_to_2_switch {l in L: OPF_TYPE == 'acpolar' and BR_STATUS[l] == 2}:
    220    Qt[l] = status[l] * (-BTT[l]*Vm[T_BUS[l]]*Vm[T_BUS[l]] - Vm[F_BUS[l]]*Vm[T_BUS[l]]*(BTF[l]*cos(Va[T_BUS[l]]-Va[F_BUS[l]])-GTF[l]*sin(Va[T_BUS[l]]-Va[F_BUS[l]])));
    221
    222subject to active_flow_from_3_4_switch {l in L: (OPF_TYPE == 'acrect' or OPF_TYPE == 'acjabr') and BR_STATUS[l] == 2}:
    223    Pf[l] = status[l] * (GFF[l]*V2[F_BUS[l]] + GFT[l]*cosft[l] + BFT[l]*sinft[l]);
    224
    225subject to active_flow_to_3_4_switch {l in L: (OPF_TYPE == 'acrect' or OPF_TYPE == 'acjabr') and BR_STATUS[l] == 2}:
    226    Pt[l] = status[l] * (GTT[l]*V2[T_BUS[l]] + GTF[l]*cosft[l] - BTF[l]*sinft[l]);
    227
    228subject to reactive_flow_from_3_4_switch {l in L: (OPF_TYPE == 'acrect' or OPF_TYPE == 'acjabr') and BR_STATUS[l] == 2}:
    229    Qf[l] = status[l] * (-BFF[l]*V2[F_BUS[l]] - BFT[l]*cosft[l] + GFT[l]*sinft[l]);
    230
    231subject to reactive_flow_to_3_4_switch {l in L: (OPF_TYPE == 'acrect' or OPF_TYPE == 'acjabr') and BR_STATUS[l] == 2}:
    232    Qt[l] = status[l] * (-BTT[l]*V2[T_BUS[l]] - BTF[l]*cosft[l] - GTF[l]*sinft[l]);
    233
    234########## POWER FLOW DEFINITIONS (BR_STATUS = 3) ##########
    235
    236subject to active_flow_from_1_bigm {l in L: OPF_TYPE == 'dc' and BR_STATUS[l] == 3}:
    237    Pfa[l] = (1 / BR_X[l]) * (Va[F_BUS[l]] - Va[T_BUS[l]]);
    238
    239subject to active_flow_to_1_bigm {l in L: OPF_TYPE == 'dc' and BR_STATUS[l] == 3}:
    240    Pta[l] = (1 / BR_X[l]) * (Va[T_BUS[l]] - Va[F_BUS[l]]);
    241
    242subject to Pfa_lower_1 {l in L: OPF_TYPE == 'dc' and BR_STATUS[l] == 3}:
    243    PFLODC[l] * (1 - status[l]) <= -Pf[l] + Pfa[l];
    244
    245subject to Pfa_upper_1 {l in L: OPF_TYPE == 'dc' and BR_STATUS[l] == 3}:
    246    -Pf[l] + Pfa[l] <= PFUPDC[l] * (1 - status[l]);
    247
    248subject to Pta_lower_1 {l in L: OPF_TYPE == 'dc' and BR_STATUS[l] == 3}:
    249    PFLODC[l] * (1 - status[l]) <= -Pt[l] + Pta[l];
    250
    251subject to Pta_upper_1 {l in L: OPF_TYPE == 'dc' and BR_STATUS[l] == 3}:
    252    -Pt[l] + Pta[l] <= PFUPDC[l] * (1 - status[l]);
    253
    254subject to active_flow_from_2_bigm {l in L: (OPF_TYPE == 'acrect' or OPF_TYPE == 'acjabr') and BR_STATUS[l] == 3}:
    255    Pfa[l] = GFF[l] * V2[F_BUS[l]] + GFT[l] * cosft[l] + BFT[l] * sinft[l];
    256
    257subject to active_flow_to_2_bigm {l in L: (OPF_TYPE == 'acrect' or OPF_TYPE == 'acjabr') and BR_STATUS[l] == 3}:
    258    Pta[l] = GTT[l] * V2[T_BUS[l]] + GTF[l] * cosft[l] - BTF[l] * sinft[l];
    259
    260subject to reactive_flow_from_2_bigm {l in L: (OPF_TYPE == 'acrect' or OPF_TYPE == 'acjabr') and BR_STATUS[l] == 3}:
    261    Qfa[l] = -BFF[l] * V2[F_BUS[l]] - BFT[l] * cosft[l] + GFT[l] * sinft[l];
    262
    263subject to reactive_flow_to_2_bigm {l in L: (OPF_TYPE == 'acrect' or OPF_TYPE == 'acjabr') and BR_STATUS[l] == 3}:
    264    Qta[l] = -BTT[l] * V2[T_BUS[l]] - BTF[l] * cosft[l] - GTF[l] * sinft[l];
    265
    266subject to Pfa_lower_2 {l in L: (OPF_TYPE == 'acrect' or OPF_TYPE == 'acjabr') and BR_STATUS[l] == 3}:
    267    PFLOAC[l] * (1 - status[l]) <= -Pf[l] + Pfa[l];
    268
    269subject to Pfa_upper_2 {l in L: (OPF_TYPE == 'acrect' or OPF_TYPE == 'acjabr') and BR_STATUS[l] == 3}:
    270    -Pf[l] + Pfa[l] <= PFUPAC[l] * (1 - status[l]);
    271
    272subject to Pta_lower_2 {l in L: (OPF_TYPE == 'acrect' or OPF_TYPE == 'acjabr') and BR_STATUS[l] == 3}:
    273    PTLOAC[l] * (1 - status[l]) <= -Pt[l] + Pta[l];
    274
    275subject to Pta_upper_2 {l in L: (OPF_TYPE == 'acrect' or OPF_TYPE == 'acjabr') and BR_STATUS[l] == 3}:
    276    -Pt[l] + Pta[l] <= PTUPAC[l] * (1 - status[l]);
    277
    278subject to Qfa_lower_2 {l in L: (OPF_TYPE == 'acrect' or OPF_TYPE == 'acjabr') and BR_STATUS[l] == 3}:
    279    QFLOAC[l] * (1 - status[l]) <= -Qf[l] + Qfa[l];
    280
    281subject to Qfa_upper_2 {l in L: (OPF_TYPE == 'acrect' or OPF_TYPE == 'acjabr') and BR_STATUS[l] == 3}:
    282    -Qf[l] + Qfa[l] <= QFUPAC[l] * (1 - status[l]);
    283
    284subject to Qta_lower_2 {l in L: (OPF_TYPE == 'acrect' or OPF_TYPE == 'acjabr') and BR_STATUS[l] == 3}:
    285    QTLOAC[l] * (1 - status[l]) <= -Qt[l] + Qta[l];
    286
    287subject to Qta_upper_2 {l in L: (OPF_TYPE == 'acrect' or OPF_TYPE == 'acjabr') and BR_STATUS[l] == 3}:
    288    -Qt[l] + Qta[l] <= QTUPAC[l] * (1 - status[l]);
    289
    290########## POWER FLOW LIMITS ##########
    291
    292subject to flowf_limits_1 {l in L:OPF_TYPE='dc' and (BR_STATUS[l] == 1 or BR_STATUS[l] == 2)}:
    293    -RATE_A[l] <= Pf[l] <= RATE_A[l];
    294
    295subject to flowt_limits_1 {l in L:OPF_TYPE='dc' and (BR_STATUS[l] == 1 or BR_STATUS[l] == 2)}:
    296    -RATE_A[l] <= Pt[l] <= RATE_A[l];
    297
    298subject to flowf_limits_dc_lower {l in L: OPF_TYPE == 'dc' and BR_STATUS[l] == 3}:
    299    Pf[l] >= -RATE_A[l] * status[l];
    300
    301subject to flowf_limits_dc_upper {l in L: OPF_TYPE == 'dc' and BR_STATUS[l] == 3}:
    302    Pf[l] <= RATE_A[l] * status[l];
    303
    304subject to flowt_limits_dc_lower {l in L: OPF_TYPE == 'dc' and BR_STATUS[l] == 3}:
    305    Pt[l] >= -RATE_A[l] * status[l];
    306
    307subject to flowt_limits_dc_upper {l in L: OPF_TYPE == 'dc' and BR_STATUS[l] == 3}:
    308    Pt[l] <= RATE_A[l] * status[l];
    309
    310subject to flow_limits_from_23_4 {l in L:(OPF_TYPE='acpolar' or OPF_TYPE = 'acrect' or OPF_TYPE = 'acjabr') and (BR_STATUS[l] == 1 or BR_STATUS[l] == 2)}:
    311    Pf[l]^2 + Qf[l]^2 <= RATE_A[l]^2;
    312
    313subject to flow_limits_to_23_4 {l in L:(OPF_TYPE='acpolar' or OPF_TYPE = 'acrect' or OPF_TYPE = 'acjabr') and (BR_STATUS[l] == 1 or BR_STATUS[l] == 2)}:
    314    Pt[l]^2 + Qt[l]^2 <= RATE_A[l]^2;
    315
    316subject to flow_limits_from_acrect {l in L: (OPF_TYPE == 'acpolar' or OPF_TYPE == 'acrect' or OPF_TYPE == 'acjabr') and BR_STATUS[l] == 3}:
    317    Pf[l]^2 + Qf[l]^2 <= RATE_A[l]^2 * status[l];
    318
    319subject to flow_limits_to_acrect {l in L: (OPF_TYPE == 'acpolar' or OPF_TYPE == 'acrect' or OPF_TYPE == 'acjabr') and BR_STATUS[l] == 3}:
    320    Pt[l]^2 + Qt[l]^2 <= RATE_A[l]^2 * status[l];
    321
    322########## RECTANGULAR DEFINITIONS ##########
    323
    324subject to eq_vol_squared {n in N:OPF_TYPE = 'acrect'}:
    325    V2[n] == Vr[n]*Vr[n] + Vi[n]*Vi[n];
    326
    327subject to eq_cosft {l in L:OPF_TYPE = 'acrect'}:
    328    cosft[l] == Vr[F_BUS[l]]*Vr[T_BUS[l]] + Vi[F_BUS[l]]*Vi[T_BUS[l]];
    329
    330subject to eq_sinft {l in L:OPF_TYPE = 'acrect'}:
    331    sinft[l] == Vi[F_BUS[l]]*Vr[T_BUS[l]] - Vr[F_BUS[l]]*Vi[T_BUS[l]];
    332
    333########## JABR RELAXATION ##########
    334
    335subject to jabr_relaxation_ft {l in L:OPF_TYPE = 'acrect' or OPF_TYPE = 'acjabr'}:
    336    cosft[l]^2 + sinft[l]^2 <= V2[F_BUS[l]]*V2[T_BUS[l]];
    337
    338# TODO: Add the relaxation by Muñoz where losses are positive?
    339
    340########## SLACK BUS ##########
    341
    342subject to eq_slack:
    343    Va[0] == 0;
    344
    345subject to eq_slack_imag:
    346    Vi[0] == 0;
    347
    348########## CONNECTIVITY CONSTRAINTS ##########
    349
    350subject to status_split {l in L: CONNECTIVITY = 'on' and (BR_STATUS[l] == 2 or BR_STATUS[l] == 3)}:
    351    statusf[l] + statust[l] == status[l];
    352
    353subject to connectivity {n in N: CONNECTIVITY = 'on'}:
    354    sum {l in L: F_BUS[l] == n} statusf[l] + sum {l in L: T_BUS[l] == n} statust[l] >= 1;
    355
    356subject to mtz_connectivity_f {l in L: CONNECTIVITY = 'on' and F_BUS[l] != 0 and T_BUS[l] != 0}:
    357    u[F_BUS[l]] - u[T_BUS[l]] + card(N) * statusf[l] <= card(N) - 1;
    358
    359subject to mtz_connectivity_t {l in L: CONNECTIVITY = 'on' and F_BUS[l] != 0 and T_BUS[l] != 0}:
    360    u[T_BUS[l]] - u[F_BUS[l]] + card(N) * statust[l] <= card(N) - 1;
    361
    362subject to eq_slack_mtz:
    363    u[0] == 1;
    364
    365########## STATUS FIX ##########
    366
    367subject to fix_status_0 {l in L: BR_STATUS[l] == 0}:
    368    status[l] == 0;
    369
    370subject to fix_status_1 {l in L: BR_STATUS[l] == 1}:
    371    status[l] == 1;
    372
    373# TODO: Split AMPL models?