# electric-NLP.mod
#
# NLP formulation of EPEC derived from MPECs defined in AllFirms.mod
#
# MPEC of example due to Fukushima and Pang, "Quasi-Variational
# Inequalities, Nash-Equilibria, and Multi-Leader-Follower Games".
#
# The generator (firm) is the Stackelberg leader, and the ISO,
# arbitrager, and market clearing are the followers in this game.
# Another possibility is to have the ISO as a Leader as well.
#
# ampl coding by S. Leyffer, Argonne National Laboratory, Jan. 2005.
#
# Change log:
# Mar. 14, 2005: Corrected mistakes in c/s FO_ss and FO_w (all .mod files)
#######################################################################
### set definitions
set N; # set of nodes in network
set F; # set of firms (generators)
set ARCS in N cross N;
### parameters & constants
param c{F,N} default 0; # cost per unit generation at node n by firm f
param P0{N}; # price intercept of sales function at node n
param Q0{N}; # quatity intercept of sales function at node n
param e{ARCS}; # ISO's unit cost of shipping along arcs
param CAP{F,N}; # production capacity at node n for firm f
### variables
var s{F,ARCS} >= 0; # amount produced by f at node n1, sold at n2
var y{ARCS} >= 0; # amount of shipment from n1 to n2
var S{N} >= 0; # total sales at node n
var ss{ARCS} >= 0; # slacks for easier complementarity
var a{ARCS} >= 0; # amount bought by arbitrager at n1, sold at n2
var w{(i,j) in ARCS} <= e[i,j]; # unit charge of shipment received by ISO
### dummy multipliers
var ss_m{F,ARCS} default 0;
var a_m{F,ARCS} default 0;
var y_m{F,ARCS} default 0;
var w_m{F,ARCS} default 0;
### multipliers (each firm has different multipliers)
var l_cap{F,N} >= 0; # capacity constraint
var l_sal{F,N} ; # total sales
var l_slk{F,ARCS} ; # definition of slacks
var l_arb{F,ARCS} >= 0; # arbitrager
var l_mar{F,ARCS} ; # market clearing
var l_ISO{F,ARCS} >= 0; # ISO
### additional slacks for general complementarity constraints
var s_s{F,ARCS} >= 0;
var s_y{F,ARCS} >= 0;
var s_S{F,N} >= 0;
var s_ss{F,ARCS} >= 0;
var s_a{F,ARCS} >= 0;
var s_w{F,ARCS} >= 0;
var s_c{F,N} >= 0;
### minimize the complementarity error
minimize complementarity:
sum{f in F, (i,j) in ARCS} s_s[f,i,j] * s[f,i,j]
+ sum{f in F, (i,j) in ARCS} s_y[f,i,j] * y[i,j]
+ sum{f in F, i in N} s_S[f,i] * S[i]
+ sum{f in F, (i,j) in ARCS} s_ss[f,i,j]* ss[i,j]
+ sum{f in F, (i,j) in ARCS} s_a[f,i,j] * a[i,j]
+ sum{f in F, (i,j) in ARCS} s_w[f,i,j] * (-w[i,j]+e[i,j])
+ sum{(i,j) in ARCS} a[i,j] * ss[i,j]
+ sum{(i,j) in ARCS} y[i,j] * (-w[i,j]+e[i,j])
+ sum{f in F, i in N} s_c[f,i] * l_cap[f,i];
subject to
### first order equations wrt s[f,i,j]
FO_s {f in F, (i,j) in ARCS}:
s_s[f,i,j] = - (P0[j] - P0[j]/Q0[j]*S[j]) + w[i,j] + c[f,i]
+ l_cap[f,i] - l_sal[f,j] - l_mar[f,i,j];
### first order equations wrt y[i,j] for every leader f
FO_y {f in F, (i,j) in ARCS}:
s_y[f,i,j] = l_mar[f,i,j] + l_ISO[f,i,j]*(-w[i,j]+e[i,j]);
### first order equations wrt S[i] for every leader f
FO_S {f in F, i in N}:
s_S[f,i] = P0[i]/Q0[i]
*sum{j in N: (j,i) in ARCS}(s[f,j,i]+a[j,i]-a[i,j])
+ l_sal[f,i]
+ sum{j in N:(j,i) in ARCS} l_slk[f,j,i]*(P0[i]/Q0[i])
- sum{j in N:(i,j) in ARCS} l_slk[f,i,j]*(P0[i]/Q0[i]);
### first order equations wrt ss[i,j] for every leader f
FO_ss{f in F, (i,j) in ARCS}:
s_ss[f,i,j] = l_slk[f,i,j] + l_arb[f,i,j]*a[i,j];
### first order equations wrt a[i,j] for every leader f
FO_a {f in F, (i,j) in ARCS}:
s_a[f,i,j] = - (P0[j]-P0[j]/Q0[j]*S[j])
+ (P0[i]-P0[i]/Q0[i]*S[i]) + w[i,j]
- l_sal[f,j] + l_sal[f,i]
+ l_arb[f,i,j]*ss[i,j] - l_mar[f,i,j];
### first order equations wrt w[i,j] for every leader f
FO_w {f in F, (i,j) in ARCS}:
s_w[f,i,j] = (a[i,j] + s[f,i,j]) - l_slk[f,i,j] - l_ISO[f,i,j]*y[i,j];
### capacity constraint
cap{f in F,i in N}: s_c[f,i] = CAP[f,i] - sum{j in N:(i,j) in ARCS} s[f,i,j];
### total sales at node i
sales{i in N}: 0 = - S[i]
+ sum{f in F, j in N:(j,i) in ARCS} s[f,j,i]
+ sum{j in N:(i,j) in ARCS}( a[j,i] - a[i,j] );
### define slacks for complementarity
slacks{(i,j) in ARCS}: 0 = - ss[i,j]
- (P0[j] - P0[j]/Q0[j]*S[j])
+ (P0[i] - P0[i]/Q0[i]*S[i])
+ w[i,j];
### market clearing condition
market{(i,j) in ARCS}: y[i,j] = sum{f in F} s[f,i,j] + a[i,j];