selkie17.gms : SELKIE test suite: obj variable setting

Description

Test if the value of the objective variable is set correctly after solve.

Contributor: Youngdae Kim (11.07.2017)


Small Model of Type : GAMS


Category : GAMS Test library


Main file : selkie17.gms

$title 'SELKIE test suite: obj variable setting'  (SELKIE17,SEQ=773)

$ontext

Test if the value of the objective variable is set correctly after solve.

Contributor: Youngdae Kim (11.07.2017)

$offtext

$if not set TESTTOL $set TESTTOL 1e-4
scalar tol / %TESTTOL% /;
file opt   / 'selkie.opt' /;
file info  / '%emp.info%' /;

set i / 1*5 /;
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 /;

put info 'equilibrium';
loop(i,
    put / 'max', obj(i), x(i), defobj(i), cap
);
putclose;

x.up(i) = 1;

putclose opt 'use_mcpopt yes';
m.optfile = 1;
option emp = selkie;

solve m using emp;

abort$[ smax{i, abs(x.l(i)   - 0.1667)} > tol ]  'bad x.l', x.l;
abort$[ smax{i, abs(obj.l(i) - 0.0278)} > tol ]  'bad obj.l', obj.l;
abort$[ abs(cap.m)                      > tol ]  'bad cap.m', cap.m;

$onecho > agent1_gms

Variables  x6,x7,x8,x9,x10,u6;

Positive Variables  x6,x7,x8,x9,x10,u6;

Equations  e6,dL_dx6;

e6.. 1 =G=    x6 + x7 + x8 + x9 + x10;

dL_dx6.. (-(1 - x6 - x7 - x8 - x9 - x10 - x6))/(1) + u6 =G= 0;

* set non-default bounds
x6.up = 1;


* fix levels belonging to other agents
x7.fx = 0;
x8.fx = 0;
x9.fx = 0;
x10.fx = 0;

Model m / e6.u6,dL_dx6.x6 /;

Solve m using mcp;

$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  x6,x7,x8,x9,x10,u6;

Positive Variables  x6,x7,x8,x9,x10,u6;

Equations  e6,dL_dx7;

e6.. 1 =G=    x6 + x7 + x8 + x9 + x10;

dL_dx7.. (-(1 - x6 - x7 - x8 - x9 - x10 - x7))/(1) + u6 =G= 0;

* set non-default bounds
x7.up = 1;


* fix levels belonging to other agents
x6.fx = 0;
x8.fx = 0;
x9.fx = 0;
x10.fx = 0;

Model m / e6.u6,dL_dx7.x7 /;

Solve m using mcp;

$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  x6,x7,x8,x9,x10,u6;

Positive Variables  x6,x7,x8,x9,x10,u6;

Equations  e6,dL_dx8;

e6.. 1 =G=    x6 + x7 + x8 + x9 + x10;

dL_dx8.. (-(1 - x6 - x7 - x8 - x9 - x10 - x8))/(1) + u6 =G= 0;

* set non-default bounds
x8.up = 1;


* fix levels belonging to other agents
x6.fx = 0;
x7.fx = 0;
x9.fx = 0;
x10.fx = 0;

Model m / e6.u6,dL_dx8.x8 /;

Solve m using mcp;

$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  x6,x7,x8,x9,x10,u6;

Positive Variables  x6,x7,x8,x9,x10,u6;

Equations  e6,dL_dx9;

e6.. 1 =G=    x6 + x7 + x8 + x9 + x10;

dL_dx9.. (-(1 - x6 - x7 - x8 - x9 - x10 - x9))/(1) + u6 =G= 0;

* set non-default bounds
x9.up = 1;


* fix levels belonging to other agents
x6.fx = 0;
x7.fx = 0;
x8.fx = 0;
x10.fx = 0;

Model m / e6.u6,dL_dx9.x9 /;

Solve m using mcp;

$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  x6,x7,x8,x9,x10,u6;

Positive Variables  x6,x7,x8,x9,x10,u6;

Equations  e6,dL_dx10;

e6.. 1 =G=    x6 + x7 + x8 + x9 + x10;

dL_dx10.. (-(1 - x6 - x7 - x8 - x9 - x10 - x10))/(1) + u6 =G= 0;

* set non-default bounds
x10.up = 1;


* fix levels belonging to other agents
x6.fx = 0;
x7.fx = 0;
x8.fx = 0;
x9.fx = 0;

Model m / e6.u6,dL_dx10.x10 /;

Solve m using mcp;

$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';

obj.l(i) = 0;
x.l(i) = 0;

putclose opt 'agent_group {{1..5}}';
m.optfile = 1;
option emp = selkie;

solve m using emp;

abort$[ smax{i, abs(x.l(i)   - 0.1667)} > tol ]  'bad x.l', x.l;
abort$[ smax{i, abs(obj.l(i) - 0.0278)} > tol ]  'bad obj.l', obj.l;
abort$[ abs(cap.m)                      > tol ]  'bad cap.m', cap.m;

$onecho > agent6_gms

Variables  x6,x7,x8,x9,x10,u6;

Positive Variables  x6,x7,x8,x9,x10,u6;

Equations  e6,dL_dx6,dL_dx7,dL_dx8,dL_dx9,dL_dx10;

e6.. 1 =G=    x6 + x7 + x8 + x9 + x10;

dL_dx6.. (-(1 - x6 - x7 - x8 - x9 - x10 - x6))/(1) + u6 =G= 0;

dL_dx7.. (-(1 - x6 - x7 - x8 - x9 - x10 - x7))/(1) + u6 =G= 0;

dL_dx8.. (-(1 - x6 - x7 - x8 - x9 - x10 - x8))/(1) + u6 =G= 0;

dL_dx9.. (-(1 - x6 - x7 - x8 - x9 - x10 - x9))/(1) + u6 =G= 0;

dL_dx10.. (-(1 - x6 - x7 - x8 - x9 - x10 - x10))/(1) + u6 =G= 0;

* set non-default bounds
x6.up = 1;
x7.up = 1;
x8.up = 1;
x9.up = 1;
x10.up = 1;


Model m / e6.u6,dL_dx6.x6,dL_dx7.x7,dL_dx8.x8,dL_dx9.x9,dL_dx10.x10 /;

Solve m using mcp;

$offecho

execute 'cat agent6_gms > agent6.gms.want';
execute 'cat "%gams.scrdir%agent6.gms" > agent6.gms.got';
execute '=diff -bw agent6.gms.want agent6.gms.got';
abort$errorlevel 'Files agent6.gms.want and agent6.gms.got differ';