secure.gms : Secure Work Files - Example 2

Description

This is example 2 of the Secure Work file document. Secure work files
allow us to hide selected data and formulation section of a GAMS
application.  The following program runs the models described in Annex
G of the GAMS User's Guide.


Small Model of Type : GAMS


Category : GAMS Model library


Main file : secure.gms

$title Secure Work Files - Example 2 (SECURE,SEQ=343)

$onText
This is example 2 of the Secure Work file document. Secure work files
allow us to hide selected data and formulation section of a GAMS
application.  The following program runs the models described in Annex
G of the GAMS User's Guide.


GAMS Development Corporation, Modeling Tool Box.

Keywords: constrained nonlinear system, nonlinear programming, GAMS language features,
          secure work files
$offText

$if not set MYPLICENSE $set MYPLICENSE "%gams.sysdir%plicense.txt"
$if not exist "%MYPLICENSE%" $abort Target license file "%MYPLICENSE%" does not exist. Specify via --MYPLICENSE=...

$set env ide=%gams.ide% lo=%gams.lo%

execute 'gams p1 s=p1 %env%';
execute 'gams u1 r=p1 %env%';
execute 'gams s1 r=p1 s=s1 plicense="%MYPLICENSE%" %env%';
execute 'gams u1 s=s1 %env%';

$onEcho > p1.gms
$call gamslib -q trnsport
$include trnsport.gms

* calculate input data -- model getc
Variable newc(i,j) 'new transport cost';

Equation defnewc(i,j) 'definition of new transport cost';

Model getc 'compute new transport data' / defnewc /;

defnewc(i,j).. newc(i,j) =e= f*d(i,j)/1000;

solve getc using cns;

* change objective function and save base value of x -- model newtrans
Scalar beta 'scale coeffisinet' / 1.1 /;

Equation newcost 'definition of new objective function';

Model newtrans / newcost, supply, demand /;

newcost.. z =e= sum((i,j), newc.l(i,j)*x(i,j)**beta);

solve newtrans using nlp minimizing z;

Parameter basex(i,j) 'base value of x';
basex(i,j) = x.l(i,j);

* transform results to percentage change -- model rep
Variable delta(i,j) 'percentage chnage from base value';

Equation defdelta(i,j) 'define delta';

Model rep / defdelta /;

defdelta(i,j)$basex(i,j).. delta(i,j) =e= 100*(x.l(i,j) - basex(i,j))/basex(i,j);

solve rep using cns;
$offEcho

$onEcho > u1.gms
Set s / one, two, three /;

Parameter
   sbeta(s) / one 1.25, two 1.5, three 2.0 /
   sf(s)    / one 85,   two 75,  three 50  /;

Parameter report 'summary report';
loop(s,
   beta = sbeta(s);
   f    = sf(s);
   solve getc using cns;
   solve newtrans using nlp minmizing z;
   solve rep using cns;
   report(i,j,s)       = delta.l(i,j);
   report('','beta',s) = beta;
   report('','f',s)    = f;
   report('obj','z',s) = z.l;
);
display report;
$offEcho

$onEcho > s1.gms
$hide all
$expose getc newtrans rep
$expose i j z delta
$expose f beta a b
$offEcho