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.chainScript%
           scale-SL%solveLink.callScript%
           scale-SL%solveLink.callModule%
           scale-SL%solveLink.loadLibrary%
           scale-SL%solveLink.asyncGrid%
           scale-SL%solveLink.aSyncThreads% /;

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

* Solve with default settings
option lp=cplex;
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.chainScript%
transport.solveLink = %solveLink.chainScript%;
Solve transport using lp minimizing z ;
$batInclude report scale-SL%solveLink.chainScript%

* Solve with scales activated and SL=%solveLink.callScript%
transport.solveLink = %solveLink.callScript%;
Solve transport using lp minimizing z ;
$batInclude report scale-SL%solveLink.callScript%

* Solve with scales activated and SL=%solveLink.callModule%
transport.solveLink = %solveLink.callModule%;
Solve transport using lp minimizing z ;
$batInclude report scale-SL%solveLink.callModule%

* Solve with scales activated and SL=%solveLink.loadLibrary%
transport.solveLink = %solveLink.loadLibrary%;
Solve transport using lp minimizing z ;
$batInclude report scale-SL%solveLink.loadLibrary%

* Solve with scales activated and SL=%Solvelink.Load Grid%
transport.solvelink=%solveLink.asyncGrid%;
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.asyncGrid%

* Solve with scales activated and SL=%Solvelink.Load Threads%
transport.solvelink=%solveLink.aSyncThreads%;
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.aSyncThreads%

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;