scale01.gms : Test results of scaled model

Description

In this test we take the trnsport model and apply arbitrary scaling factors to
variables and equations. We solve the model with different solvelink settings
and and check if we get the same results.

Keyword: solveLink, scale, scaleopt

Contributor: Lutz Westermann, March 2016


Small Model of Type : GAMS


Category : GAMS Test library


Main file : scale01.gms

$Title 'Test results of scaled model' (SCALE01,SEQ=692)

$onText
In this test we take the trnsport model and apply arbitrary scaling factors to
variables and equations. We solve the model with different solvelink settings
and and check if we get the same results.

Keyword: solveLink, scale, scaleopt

Contributor: Lutz Westermann, March 2016
$offText


$call gamslib -q trnsport
$include trnsport.gms

$onechoV > report.gms
rep0('%1', 'z.l') = z.l;
rep0('%1', 'z.m') = z.m;
rep0('%1', 'cost.l') = cost.l;
rep0('%1', 'cost.m') = cost.m;
rep0('%1', 'objval') = transport.objval;;

repi('%1', 'supply.l', i) = supply.l(i);
repi('%1', 'supply.m', i) = supply.m(i);

repj('%1', 'demand.l', j) = demand.l(j);
repj('%1', 'demand.m', j) = demand.m(j);

repij('%1', 'x.l', i, j) = x.l(i,j);
repij('%1', 'x.m', i, j) = x.m(i,j);
$offecho

set runs / default
           scale-SL%Solvelink.Chain Script%
           scale-SL%Solvelink.Call Script%
           scale-SL%Solvelink.Call Module%
           scale-SL%Solvelink.Load Library%
           scale-SL%Solvelink.Async Grid%
           scale-SL%Solvelink.Async Threads% /;

parameter rep0(runs,*), repi(runs,*,i), repj(runs,*,j), repij(runs,*,i,j);

* Solve with default settings
option lp=cplexd;
Solve transport using lp minimizing z ;
$batinclude report default

* Set some scales
transport.scaleOpt = 1;
cost.scale = 2;
supply.scale(i) = 3;
demand.scale(j) = 4;

z.scale = 0.1;
x.scale(i,j) = 0.2;

* Solve with scales activated and SL=%Solvelink.Chain Script%
transport.solveLink = %Solvelink.Chain Script%;
Solve transport using lp minimizing z ;
$batinclude report scale-SL%Solvelink.Chain Script%

* Solve with scales activated and SL=%Solvelink.Call Script%
transport.solveLink = %Solvelink.Call Script%;
Solve transport using lp minimizing z ;
$batinclude report scale-SL%Solvelink.Call Script%

* Solve with scales activated and SL=%Solvelink.Call Module%
transport.solveLink = %Solvelink.Call Module%;
Solve transport using lp minimizing z ;
$batinclude report scale-SL%Solvelink.Call Module%

* Solve with scales activated and SL=%Solvelink.Load Library%
transport.solveLink = %Solvelink.Load Library%;
Solve transport using lp minimizing z ;
$batinclude report scale-SL%Solvelink.Load Library%

* Solve with scales activated and SL=%Solvelink.Load Grid%
transport.solvelink=%Solvelink.Async Grid%;
solve transport using lp minimizing z;
display$readyCollect (transport.handle) 'problem waiting for job';
display$handlecollect(transport.handle) 'collected result';
display$handledelete (transport.handle) 'preoblem deleting handle';
$batinclude report scale-SL%Solvelink.Async Grid%

* Solve with scales activated and SL=%Solvelink.Load Threads%
transport.solvelink=%Solvelink.Async Threads%;
solve transport using lp minimizing z;
display$readyCollect (transport.handle) 'problem waiting for job';
display$handlecollect(transport.handle) 'collected result';
display$handledelete (transport.handle) 'preoblem deleting handle';
$batinclude report scale-SL%Solvelink.Async Threads%

set error0, errori, errorj, errorij;

alias (*,u);

error0(runs,u)     $(not sameas(runs,'default')) = abs(rep0(runs,u)      - rep0('default',u)     ) > 1e-6;
errori(runs,u,i)   $(not sameas(runs,'default')) = abs(repi(runs,u,i)    - repi('default',u,i)   ) > 1e-6;
errorj(runs,u,j)   $(not sameas(runs,'default')) = abs(repj(runs,u,j)    - repj('default',u,j)   ) > 1e-6;
errorij(runs,u,i,j)$(not sameas(runs,'default')) = abs(repij(runs,u,i,j) - repij('default',u,i,j)) > 1e-6;

abort$(card(error0) + card(errori) + card(errorj) + card(errorij)) 'Unexpected differences',
       error0, errori, errorj, errorij, rep0, repi, repj, repij;