function v = gap(z)

% gap function of a bimatrix game

global C1 C2

[m,n] = size(C1) ;

x = z(1:m) ;
y = z(m+1:m+n) ;

% Solution without linprog
v = x'*(C1+C2)*y - min(C1*y) - min(C2'*x) ;

% Solution with linprog
% options = optimset('Display','off');
% [~,v1]=linprog(C1*y,[],[],ones(1,m),1,zeros(m,1),[],options);
% [~,v2]=linprog(C2'*x,[],[],ones(1,n),1,zeros(n,1),[],options);
% v = x'*(C1+C2)*y - v1 - v2 ;





