# electric-NCPa.mod
#
# Altyernative 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} >= 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{ARCS} default 1; # unit charge of shipment received by ISO
### 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
### multipliers of simple bounds on complementary variables
var nu_a {F,ARCS};
var nu_ss{F,ARCS};
var nu_y {F,ARCS};
var nu_w {F,ARCS};
minimize dummy: 0;
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[f,j] - l_mar[f,i,j]
complements s[f,i,j] >= 0;
### first order equations wrt y[i,j] for every leader f
FO_y {f in F, (i,j) in ARCS}:
nu_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}:
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[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])
complements S[i] >= 0;
### first order equations wrt ss[i,j] for every leader f
FO_ss{f in F, (i,j) in ARCS}:
nu_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}:
nu_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}:
nu_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}: CAP[f,i] >= sum{j in N:(i,j) in ARCS} s[f,i,j]
complements l_cap[f,i] >= 0;
### 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]
complements w[i,j];
### arbitrager's optimality conditions (follower)
arbitrager1{f in F, (i,j) in ARCS}:
0 <= a[i,j] complements ss[i,j] + nu_a[f,i,j] >= 0;
arbitrager2{f in F, (i,j) in ARCS}:
0 <= ss[i,j] complements a[i,j] + nu_ss[f,i,j] >= 0;
arbitrager3{f in F, (i,j) in ARCS}:
0 <= l_arb[f,i,j] complements nu_a[f,i,j] + nu_ss[f,i,j] >= 0;
### ISO's optimality conditions
ISO1{f in F, (i,j) in ARCS}:
0 <= y[i,j] complements -w[i,j]+e[i,j] + nu_y[f,i,j] >= 0;
ISO2{f in F, (i,j) in ARCS}:
0 <= -w[i,j]+e[i,j] complements y[i,j] + nu_w[f,i,j] >= 0;
ISO3{f in F, (i,j) in ARCS}:
0 <= l_ISO[f,i,j] complements nu_y[f,i,j] + nu_w[f,i,j] >= 0;