$ontext Usage: gams listing9.gms Tragedy of the Commons: Each agent i sends x(i) units of flow along the shared channel with capacity 1. The value each agent obtains by sending x(i) units is x(i)*(1 - sum(j, x(j))). Each agent tries to solve the following: maximize_{x(i)} x(i)*(1 - sum(j, x(j))) suject to sum(j, x(j)) <= 1 0 <= x(i) <= 1 There is a unique equilibrium solution x(i) = 1/(N+1). Then The value for each player: 1/(N+1)^2 The total value : N/(N+1)^2 \approx 1/N The equilibrium is obtained when all agents are playing their optimal selfish strategy. However, if agents cooperate in a way that the total flow sum(i, x(i)) is 1/2, then the total value is 1/4, which could be much larger than 1/N for large enough N. This is called the tragedy of the commons. Contributor: Youngdae Kim, Dec 2016 $offtext $if not set N $set N 5 set i / 1*%N% /; alias(i,j); variables obj(i); positive variables x(i); equations defobj(i), cap; defobj(i).. obj(i) =E= x(i)*(1 - sum(j, x(j))); cap.. sum(i, x(i)) =L= 1; model m / defobj, cap /; file info / '%emp.info%' /; put info 'equilibrium'; loop(i, put 'max', obj(i), x(i), defobj(i), cap /; ); putclose; x.up(i) = 1; * Specify SharedEqu option in the jams.opt file to allow shared constraints. $echo SharedEqu > jams.opt m.optfile = 1; solve m using emp; parameters cap_m(i); execute_load '%gams.scrdir%/ugdx.dat', cap_m=cap; display x.l, cap_m;