\$title 'SELKIE test suite' (SELKIE04,SEQ=760) \$ontext This example was taken from the following papers: F. H. Murphy et al. A mathematical programming approach for determining oligopolistic market equilibrium. Mathematical Programming 24 (1982) 92--106. The solution is q* = (36.933, 41.818, 43.707, 42.659, 39.179). Contributor: Youngdae Kim (10.26.2016) \$offtext \$if not set TESTTOL \$set TESTTOL 1e-4 scalar tol / %TESTTOL% /; file opt / 'selkie.opt' /; file info / '%emp.info%' /; sets i agents / 1*5 /; alias(i,j); parameters c(i) / 1 10, 2 8, 3 6, 4 4, 5 2 / K(i) / 1 5, 2 5, 3 5, 4 5, 5 5 / beta(i) / 1 1.2, 2 1.1, 3 1.0, 4 0.9, 5 0.8 / gamma / 1.1 / ; variables obj(i); positive variables q(i); equations objdef(i) ; objdef(i).. obj(i) =e= q(i)*5000**(1.0/gamma)*sum(j, q(j))**(-1.0/gamma) - (c(i)*q(i) + beta(i)/(beta(i)+1)*K(i)**(-1/beta(i))*q(i)**((beta(i)+1)/beta(i))); model nep / objdef /; file empinfo / '%emp.info%' /; put empinfo 'equilibrium' /; loop(i, put 'max ', obj(i), q(i), objdef(i) /; ); putclose empinfo; q.l(i) = 10; option emp = selkie; solve nep using emp; abort\$[ abs(q.l('1') - 36.9325) > tol ] 'bad q.l("1")', q.l; abort\$[ abs(q.l('2') - 41.8181) > tol ] 'bad q.l("2")', q.l; abort\$[ abs(q.l('3') - 43.7066) > tol ] 'bad q.l("3")', q.l; abort\$[ abs(q.l('4') - 42.6592) > tol ] 'bad q.l("4")', q.l; abort\$[ abs(q.l('5') - 39.1790) > tol ] 'bad q.l("5")', q.l; \$onecho > agent1_gms Variables x1,x6,x7,x8,x9,x10; Positive Variables x6,x7,x8,x9,x10; Equations e1; e1.. -(2305.15431536512*(x6 + x7 + x8 + x9 + x10)**(-0.909090909090909)*x6 - ( 0.142653871201291*x6**1.83333333333333 + 10*x6)) + x1 =E= 0; * set non-default levels and fix prox terms x6.l = 10; * fix levels belonging to other agents x7.fx = 10; x8.fx = 10; x9.fx = 10; x10.fx = 10; Model m / e1 /; Solve m using nlp maximizing x1; \$offecho execute 'cat agent1_gms > agent1.gms.want'; execute 'cat "%gams.scrdir%agent1.gms" > agent1.gms.got'; execute '=diff -bw agent1.gms.want agent1.gms.got'; abort\$errorlevel 'Files agent1.gms.want and agent1.gms.got differ'; \$onecho > agent2_gms Variables x2,x6,x7,x8,x9,x10; Positive Variables x6,x7,x8,x9,x10; Equations e2; e2.. -(2305.15431536512*(x6 + x7 + x8 + x9 + x10)**(-0.909090909090909)*x7 - ( 0.121267971709307*x7**1.90909090909091 + 8*x7)) + x2 =E= 0; * set non-default levels and fix prox terms x7.l = 10; * fix levels belonging to other agents x6.fx = 10; x8.fx = 10; x9.fx = 10; x10.fx = 10; Model m / e2 /; Solve m using nlp maximizing x2; \$offecho execute 'cat agent2_gms > agent2.gms.want'; execute 'cat "%gams.scrdir%agent2.gms" > agent2.gms.got'; execute '=diff -bw agent2.gms.want agent2.gms.got'; abort\$errorlevel 'Files agent2.gms.want and agent2.gms.got differ'; \$onecho > agent3_gms Variables x3,x6,x7,x8,x9,x10; Positive Variables x6,x7,x8,x9,x10; Equations e3; e3.. -(2305.15431536512*(x6 + x7 + x8 + x9 + x10)**(-0.909090909090909)*x8 - ( 0.1*x8**2 + 6*x8)) + x3 =E= 0; * set non-default levels and fix prox terms x8.l = 10; * fix levels belonging to other agents x6.fx = 10; x7.fx = 10; x9.fx = 10; x10.fx = 10; Model m / e3 /; Solve m using nlp maximizing x3; \$offecho execute 'cat agent3_gms > agent3.gms.want'; execute 'cat "%gams.scrdir%agent3.gms" > agent3.gms.got'; execute '=diff -bw agent3.gms.want agent3.gms.got'; abort\$errorlevel 'Files agent3.gms.want and agent3.gms.got differ'; \$onecho > agent4_gms Variables x4,x6,x7,x8,x9,x10; Positive Variables x6,x7,x8,x9,x10; Equations e4; e4.. -(2305.15431536512*(x6 + x7 + x8 + x9 + x10)**(-0.909090909090909)*x9 - ( 0.0792237818795091*x9**2.11111111111111 + 4*x9)) + x4 =E= 0; * set non-default levels and fix prox terms x9.l = 10; * fix levels belonging to other agents x6.fx = 10; x7.fx = 10; x8.fx = 10; x10.fx = 10; Model m / e4 /; Solve m using nlp maximizing x4; \$offecho execute 'cat agent4_gms > agent4.gms.want'; execute 'cat "%gams.scrdir%agent4.gms" > agent4.gms.got'; execute '=diff -bw agent4.gms.want agent4.gms.got'; abort\$errorlevel 'Files agent4.gms.want and agent4.gms.got differ'; \$onecho > agent5_gms Variables x5,x6,x7,x8,x9,x10; Positive Variables x6,x7,x8,x9,x10; Equations e5; e5.. -(2305.15431536512*(x6 + x7 + x8 + x9 + x10)**(-0.909090909090909)*x10 - ( 0.0594435826645709*x10**2.25 + 2*x10)) + x5 =E= 0; * set non-default levels and fix prox terms x10.l = 10; * fix levels belonging to other agents x6.fx = 10; x7.fx = 10; x8.fx = 10; x9.fx = 10; Model m / e5 /; Solve m using nlp maximizing x5; \$offecho execute 'cat agent5_gms > agent5.gms.want'; execute 'cat "%gams.scrdir%agent5.gms" > agent5.gms.got'; execute '=diff -bw agent5.gms.want agent5.gms.got'; abort\$errorlevel 'Files agent5.gms.want and agent5.gms.got differ'; * Test the model without writing agent's problem into a file. putclose opt 'write_agent_model no'; nep.optfile = 1; obj.l(i) = 0; q.l(i) = 10; solve nep using emp; abort\$[ abs(q.l('1') - 36.9325) > tol ] 'bad q.l("1")', q.l; abort\$[ abs(q.l('2') - 41.8181) > tol ] 'bad q.l("2")', q.l; abort\$[ abs(q.l('3') - 43.7066) > tol ] 'bad q.l("3")', q.l; abort\$[ abs(q.l('4') - 42.6592) > tol ] 'bad q.l("4")', q.l; abort\$[ abs(q.l('5') - 39.1790) > tol ] 'bad q.l("5")', q.l;