|
Ranging analysis |
Top Previous Next |
|
Some users are interested in getting ranging output in the form of LP cost and right hand side ranging results. Unfortunately, the base version of GAMS does not yield such information. The user wishing such information has two alternatives. First, one may cause the model to be repeatedly solved under a set of values for the key parameter using the procedures discussed in the Doing a Comparative Analysis with GAMS chapter but this is cumbersome if a lot of parameters are involved. Second, one can use solver dependent features of GAMS (which currently work with OSL or CPLEX) and retrieve the ranging information following the procedures discussed next. In turn the ranging information is included in the LST file and can be retrieved into a GAMS parameter. There is a document on the GAMS web page called Sensitivity Analysis, with GAMS/CPLEX and GAMS/OSL at http://www.gams.com/docs/sensitiv.htm which gives instructions on how to get ranging analyses from the OSL or CPLEX solvers. Use of this approach requires one to implement a solver options file telling the solver to generate all possible or selected ranging information. There is also an option one can use which causes the ranging information to be saved in an auxiliary file importable by GAMS, subject to some potential small editing changes. The steps to using this procedure are as follows
objrng all rhsrng all
or for OSL use
objrng rhsrng
objrng variablename1,variablename2 rhsrng equationname
in both OSL and CPLEX where variablename and equationname are named variables and equations in your GAMS model.
transport.OptFile=1; transport.DictFile = 4;
rngrestart filename
where filename is the name of the include file. Example: Suppose we take the problem resource.gms and set it up to do include ranging analysis. To do this we add the colored lines as below between the model statement and the solve statement creating the file ranging.gms.
MODEL RESALLOC /ALL/; option lp=cplex; FILE OPT Cplex option file / cplex.OPT /; PUT OPT; PUT 'objrng all '/ 'rhsrng all '/; PUTCLOSE OPT; resalloc.optfile=1; resalloc.dictfile=4; SOLVE RESALLOC USING LP MAXIMIZING PROFIT;
These lines choose the solver, write the options file using the procedure discussed in the Solver Option files chapter, activate the options file and write the dictionary file.
In turn the LST file output is augmented with the ranging information as follows
EQUATION NAME LOWER CURRENT UPPER ------------- ----- ------- ----- OBJT -INF 0 +INF AVAILABLE(SMLLATHE) 95.6204 140 151.333 AVAILABLE(LRGLATHE) 83.9286 90 112.705 AVAILABLE(CARVER) 103.093 120 +INF AVAILABLE(LABOR) 97.9317 125 175.453
VARIABLE NAME LOWER CURRENT UPPER ------------- ----- ------- ----- PRODUCTION(FUNCTNORM) -3.92507 0 27.8421 PRODUCTION(FUNCTMXSML) -INF 0 11.2991 PRODUCTION(FUNCTMXLRG) -INF 0 4.07934 PRODUCTION(FANCYNORM) -4.97175 0 4.42299 PRODUCTION(FANCYMXSML) -INF 0 8.39683 PRODUCTION(FANCYMXLRG) -4.29115 0 14.7057 PROFIT 1.33227e-015 1 +INF
In our example adding the line
rngrestart rngfile.gms
to the options file (rangeinc.gms) causes the file rngfile.gms to be generated that contains the ranging results in parameters. These parameters are named with the variable and equation names with the letters RNG appended. They have the same basic set dependency but with an additional set (RNGLIM) added. That set is assumed to be defined by the user and has the elements lo and up for the upper and lower ranges. In this case the file looks like
PARAMETER OBJTRNG(RNGLIM) / LO -INF UP +INF /; PARAMETER AVAILABLERNG(RESOURCE,RNGLIM) / SMLLATHE.LO 95.62037037 SMLLATHE.UP 151.3333333 LRGLATHE.LO 83.92857143 LRGLATHE.UP 112.7045827 CARVER.LO 103.0926264 CARVER.UP +INF LABOR.LO 97.93170732 LABOR.UP 175.4526316 /; PARAMETER PRODUCTIONRNG(PROCESS,RNGLIM) / FUNCTNORM.LO -3.925065963 FUNCTNORM.UP 27.84210526 FUNCTMXSML.LO -INF FUNCTMXSML.UP 11.29905545 FUNCTMXLRG.LO -INF FUNCTMXLRG.UP 4.079341865 FANCYNORM.LO -4.971748151 FANCYNORM.UP 4.422993062 FANCYMXSML.LO -INF FANCYMXSML.UP 8.3968312 FANCYMXLRG.LO -4.291153846 FANCYMXLRG.UP 14.70565635 /; PARAMETER PROFITRNG(RNGLIM) / LO 1.33226763e-015 UP +INF /; Notes:
Z – CX =0 AX < b
as discussed in the Quick Start Tutorial chapter.
MODEL RESALLOC /ALL/; option lp=cplex; FILE OPT Cplex option file / cplex.OPT /; PUT OPT; $setglobal filename rngfile.gms PUT 'objrng all '/ 'rhsrng all '/ 'rngrestart %filename%'/; PUTCLOSE OPT; resalloc.optfile=1; resalloc.dictfile=4; SOLVE RESALLOC USING LP MAXIMIZING PROFIT;
Set rnglim /lo,up/; PARAMETER OBJTRNG(RNGLIM) PARAMETER AVAILABLERNG(RESOURCE,RNGLIM) PARAMETER PRODUCTIONRNG(PROCESS,RNGLIM) PARAMETER PROFITRNG(RNGLIM) ; execute_unload 'passtorange.gdx',resource,process,rnglim; execute 'GAMS incmyranges --filename=%filename%' execute_load 'passtorange.gdx',OBJTRNG, AVAILABLERNG, PRODUCTIONRNG, PROFITRNG;
where a couple of tricks are used
set resource, process, rnglim; $gdxin passtorange.gdx $Load resource process rnglim $include "%filename%" execute_unload 'passtorange.gdx',OBJTRNG, AVAILABLERNG, PRODUCTIONRNG, PROFITRNG;
the names of the range containing parameters must be known and the appropriate unload commands issued.
objrng xcrop,xlive,sales rhsrng labc,landb |