# electric-PCa.mod
#
# Altyernative price consistent
# NCP 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:
#
#######################################################################
### 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}; # amount produced by f at node n1, sold at n2
var y{ARCS} ; # amount of shipment from n1 to n2
var S{N} ; # total sales at node n
var ss{ARCS} ; # slacks for easier complementarity
var a{ARCS} ; # amount bought by arbitrager at n1, sold at n2
var w{ARCS} default 1; # unit charge of shipment received by ISO
### multipliers (each firm has different multipliers)
var l_cap{F,N} ; # capacity constraint
var l_sal{N}; # total sales
var l_slk{ARCS}; # definition of slacks
var l_arb{ARCS} ; # arbitrager
var l_mar{ARCS}; # market clearing
var l_ISO{ARCS} ; # ISO
subject to
### first order equations wrt s[f,i,j]
FO_s {f in F, (i,j) in ARCS}:
0 <= - (P0[j] - P0[j]/Q0[j]*S[j]) + w[i,j] + c[f,i]
+ l_cap[f,i] - l_sal[j] - l_mar[i,j]
complements s[f,i,j] >= 0;
### first order equations wrt y[i,j] for every leader f
FO_y {(i,j) in ARCS}:
0 <= l_mar[i,j] + l_ISO[i,j]*(-w[i,j]+e[i,j])
complements y[i,j] >= 0;
### first order equations wrt S[i] for every leader f
FO_S {f in F, i in N}:
0 <= P0[i]/Q0[i]*(sum{j in N: (j,i) in ARCS}(s[f,j,i]+a[j,i]-a[i,j]))
+ l_sal[i]
+ sum{j in N:(j,i) in ARCS} l_slk[j,i]*(P0[i]/Q0[i])
- sum{j in N:(i,j) in ARCS} l_slk[i,j]*(P0[i]/Q0[i])
complements S[i] >= 0;
### first order equations wrt ss[i,j] for every leader f
FO_ss{(i,j) in ARCS}:
0 <= l_slk[i,j] + l_arb[i,j]*a[i,j] complements ss[i,j] >= 0;
### first order equations wrt a[i,j] for every leader f
FO_a {(i,j) in ARCS}:
0 <= - (P0[j]-P0[j]/Q0[j]*S[j]) + (P0[i]-P0[i]/Q0[i]*S[i]) + w[i,j]
- l_sal[j] + l_sal[i] + l_arb[i,j]*ss[i,j] - l_mar[i,j]
complements a[i,j] >= 0;
### first order equations wrt w[i,j] for every leader f
FO_w {f in F, (i,j) in ARCS}:
0 <= a[i,j] + s[f,i,j] - l_slk[i,j] - l_ISO[i,j]*y[i,j]
complements w[i,j] <= e[i,j];
### capacity constraint
cap{f in F,i in N}: 0 <= l_cap[f,i] complements CAP[f,i] - sum{j in N:(i,j) in ARCS} s[f,i,j] >= 0;
### total sales at node i
sales{i in N}: 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}: ss[i,j] =
- (P0[j] - P0[j]/Q0[j]*S[j])
+ (P0[i] - P0[i]/Q0[i]*S[i])
+ w[i,j];
### arbitrager's optimality conditions (follower)
arbitrager{(i,j) in ARCS}: 0 <= a[i,j] complements ss[i,j] >= 0;
### market clearing condition
market{(i,j) in ARCS}: y[i,j] = sum{f in F} s[f,i,j] + a[i,j]
complements w[i,j];
### ISO's optimality conditions
ISO{(i,j) in ARCS}: 0 <= y[i,j] complements -w[i,j]+e[i,j] >= 0;