# AllFirms.mod
#
# Defines the model for Gauss-Seidel/Jacobi iteration for ...
#
# 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
### maximize firm's revenue
maximize revenue{firm in F}:
sum{(j,i) in ARCS}( P0[i] - P0[i]/Q0[i]*S[i] )
*( s[firm,j,i] + a[j,i] - a[i,j] )
- sum{(i,j) in ARCS} w[i,j]*(a[i,j] + s[firm,i,j])
- sum{(i,j) in ARCS} c[firm,i]*s[firm,i,j];
subject to
### capacity constraint
cap{f in F,i in N}: sum{j in N:(i,j) in ARCS} s[f,i,j] - 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];
### 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;