GAMS Reader - Solution for the exercises

II.1.            Results for Introductory level

Results from 2.1.1.


Your desktop should look similar to this:

 



Results from 2.1.2.

 


Results from 2.1.3.


After running the model, the GAMS-IDE should look similar to this[1]:

 


Results from 2.1.4.

In our simple example, the report on the variables should be as follows :

LOWER           LEVEL         UPPER         MARGINAL

---- VAR X1       -INF            3.0000        +INF             .

---- VAR X2       -INF            5.0000        +INF             .

---- VAR Y        -INF            8.0000        +INF             .

  X1          Explanatory text on the meaning of X1

  X2          Explanatory text on the meaning of X2

  Y           Explanatory text on the meaning of Y

 

Therefore, the optimal values for variables X1, X2 and Y are 3, 5 and 8 respectively. Note that none of the variables has an lower or upper bound. INF means infinity, so the variables can take infinitely large and small values. The marginal value of all variables is zero, which confirms that the solution found is optimal.


Results from 2.1.5.

Removing the semi-colon from equation QX1 results in the following window:

At the end of the listing file the list of errors are explained:

“409 Unrecognizable item - skip to find a new statement; looking for a ';' or a key word to get started again” is displayed.

Results from 2.1.6.

The problem is UNBOUNDED, because you can keep lowering the value of Y by lowering X1. Remember that X1 should be less than A, not equal to. So X1 can get any value below 3. Consequently, Y can get any value below 8. The minimum is then minus infinity; GAMS reports this as unbounded.

The listing file gives the following solve summary:

**** SOLVER STATUS     1 NORMAL COMPLETION

**** MODEL STATUS      3 UNBOUNDED

Results from 2.1.7.

The results for the variables when the tax rate (tax) equals 30 is:

              LOWER          LEVEL          UPPER         MARGINAL

VAR DAMAGE    -INF         6000.0000        +INF             .

VAR ST_RATE   -INF            0.5000        +INF             .

VAR CATTLE    -INF          500.0000        +INF             .

VAR OBJ       -INF         4000.0000        +INF             .

For tax=20, obj equals 6000; for tax=10, obj equals 6000 and for tax=0, obj equals 4000; the optimal value of tax is 15, when obj equals 6250.

Make sure that you use the explanatory text.

Results from 2.1.8.

The values of X1 and Y should be identical to the earlier exercises: 3 and 8, respectively.

Did you think of removing the equation declaration and the equation definition for QX2?

The full model for emissions can look like this:

PARAMETERS

      coef  Emission coefficient CO2

      OTHER Emissions of other greenhouse gasses;

Coef=0.03;

OTHER=5;

VARIABLES

      CO2   Emissions of CO2

      PRD   Production quantity

      EMIS  Total emissions of greenhouse gasses;

EQUATIONS

      QPRD  Equation for economic production

      QCO2  Equation for CO2 emissions

      QEMIS Equation for total climate emissions;

 

QPRD..      PRD =G= 100;

QCO2..      CO2 =E= coef*PRD;

QEMIS..     EMIS =E= CO2+OTHER;

 

MODEL CLIMATE /ALL/;

SOLVE CLIMATE USING DNLP MINIMIZING EMIS;

 

 

With solution:

                        LOWER     LEVEL     UPPER    MARGINAL

---- VAR EMIS           -INF      8.000     +INF       .

---- VAR CO2            -INF      3.000     +INF       .

---- VAR PRD            -INF    100.000     +INF       .


II.2.            Results for Intermediate level

Results from 2.2.1

At the end of the listing file, the following lines have been added by GAMS:

 VARIABLE  EMIS.L  = 8.000 Total emissions of greenhouse gasses

 PARAMETER OTHER   = 5.000 Emissions of other greenhouse gasses

Results from Exercise 2.2.2. Commenting out a single line

The line with the comment does not change the results.

Results from Exercise 2.2.3. Using SCALARS

SCALARS

coef    emission coefficient   /0.03/

OTHER   other emissions /5/;

The result does not change.

Results from Exercise 2.2.4. Solving more than one model

As the value of OTHER has increased from 5 to 7, we expect that the value of RES2 equals RES1+2. The display statement gives:

     PARAMETER RES1                 =        8.000

     PARAMETER RES2                 =       10.000

The other values in the model have not changed (PRD and CO2 are unaffected).

Remember to check for each solve whether GAMS has found an optimal solution!

Results from 2.2.5

The display statement changes to:

----     31 PARAMETER RES

1st solve  8.000,    2nd solve 10.000

Results from 2.2.6

In the solution listing, the solution for CO2 is not influenced, but PRD is changed:

              LOWER          LEVEL         UPPER         MARGINAL

---- VAR CO2  -INF           3.0000        +INF             .

  CO2         Emissions of CO2

 

---- VAR PRD         Production quantity

         LOWER          LEVEL          UPPER         MARGINAL

1        -INF           10.0000        +INF             .

2        -INF           50.0000        +INF             .

3        -INF           40.0000        +INF             .

Results from Exercise 2.2.7. Summing over an index

No changes in the results.

Results from 2.2.8

For each year 2000 to 2004 the same values result in the model:

----     45 PARAMETER RES

                 2000        2001        2002        2003        2004

1st solve       8.000       8.000       8.000       8.000       8.000

2nd solve      10.000      10.000      10.000      10.000      10.000

The new variable TOTEMIS equals 40 in the first solve and 50 in the second solve.

Results from 2.2.9

The values of variable PRD changes, as does the parameter RES (and for instance also CO2 and CONCENT).

---- VAR PRD         Production quantity

              LOWER          LEVEL          UPPER         MARGINAL

1.2000        -INF           10.0000        +INF             .

1.2001        -INF           11.0000        +INF             .

1.2002        -INF           12.0000        +INF             .

1.2003        -INF           13.0000        +INF             .

1.2004        -INF           14.0000        +INF             .

2.2000        -INF           50.0000        +INF             .

2.2001        -INF           52.0000        +INF             .

2.2002        -INF           54.0000        +INF             .

2.2003        -INF           56.0000        +INF             .

2.2004        -INF           58.0000        +INF             .

3.2000        -INF           40.0000        +INF             .

3.2001        -INF           42.0000        +INF             .

3.2002        -INF           44.0000        +INF             .

3.2003        -INF           46.0000        +INF             .

3.2004        -INF           48.0000        +INF             .

 

----     55 PARAMETER RES

                 2000        2001        2002        2003        2004

1st solve       8.000       8.150       8.300       8.450       8.600

2nd solve      10.000      10.150      10.300      10.450      10.600

Results from 2.2.10

The model results do not change, but you can see the difference in the solution for PRD:

---- VAR PRD         Production quantity

              LOWER          LEVEL          UPPER         MARGINAL

1.2000          .            10.0000        +INF             .

1.2001          .            11.0000        +INF             .

1.2002          .            12.0000        +INF             .

1.2003          .            13.0000        +INF             .

1.2004          .            14.0000        +INF             .

2.2000          .            50.0000        +INF             .

2.2001          .            52.0000        +INF             .

2.2002          .            54.0000        +INF             .

2.2003          .            56.0000        +INF             .

2.2004          .            58.0000        +INF             .

3.2000          .            40.0000        +INF             .

3.2001          .            42.0000        +INF             .

3.2002          .            44.0000        +INF             .

3.2003          .            46.0000        +INF             .

3.2004          .            48.0000        +INF             .

The lower bounds are no longer “-INF”, but a dot is given. This dot indicates zero.

Results from 2.2.11

If your model behaves normally, the starting values do not influence the results. So in this simple example, nothing changes.

Results from 2.2.12

Note that the lower and upper bound go on PRD (the variable) and not on PRD_DATA (the parameter); you cannot put bounds on parameters, as their values are already fixed.

If you put the upper value on PRD(“2”,T) at a level below the value in PRD_DATA(“2”,T), then the model becomes infeasible. The model does not make any sense anymore: the value cannot be smaller than 55 and larger than PRD_DATA(“2”,T) at the same time. So the upper bound on PRD(“2”,T) should be removed.

The solution listing for PRD for the first simulation contains:

---- VAR PRD         Production quantity

              LOWER          LEVEL          UPPER         MARGINAL

1.2000        12.0000        12.0000        +INF            0.0300

1.2001        12.0000        12.0000        +INF            0.0300

1.2002        12.0000        12.0000        +INF             .

1.2003        12.0000        13.0000        +INF             .

1.2004        12.0000        14.0000        +INF             .

2.2000          .            50.0000        +INF             .

2.2001          .            52.0000        +INF             .

2.2002          .            54.0000        +INF             .

2.2003          .            56.0000        +INF             .

2.2004          .            58.0000        +INF             .

3.2000          .            40.0000        +INF             .

3.2001          .            42.0000        +INF             .

3.2002          .            44.0000        +INF             .

3.2003          .            46.0000        +INF             .

3.2004          .            48.0000        +INF             .

And the display statement at the end delivers:

----     63 PARAMETER RES

                 2000        2001        2002        2003        2004

1st solve       8.060       8.180       8.300       8.450       8.600

2nd solve      10.060      10.180      10.300      10.450      10.600

So the lower bound on PRD(“1”,T) affects the results for 2000 and 2001. Annual emissions, as reported in parameter RES are 0.06 and 0.03 higher than without the bounds.

Results from Exercise 2.2.13. Fixing variables

Fixing the level of PRD(“3”,”2000”) to 45 in the first solve will affect production in 2000 and consequently also emissions (and concentration).

---- VAR PRD         Production quantity

              LOWER          LEVEL          UPPER         MARGINAL

1.2000        12.0000        12.0000        +INF            0.0300

1.2001        12.0000        12.0000        +INF            0.0300

1.2002        12.0000        12.0000        +INF             .

1.2003        12.0000        13.0000        +INF             .

1.2004        12.0000        14.0000        +INF             .

2.2000          .            50.0000        +INF             .

2.2001          .            52.0000        +INF             .

2.2002          .            54.0000        +INF             .

2.2003          .            56.0000        +INF             .

2.2004          .            58.0000        +INF             .

3.2000        45.0000        45.0000        45.0000         0.0300

3.2001          .            42.0000        +INF             .

3.2002          .            44.0000        +INF             .

3.2003          .            46.0000        +INF             .

3.2004          .            48.0000        +INF             .

 

----     66 PARAMETER RES

                 2000        2001        2002        2003        2004

1st solve       8.210       8.180       8.300       8.450       8.600

2nd solve      10.060      10.180      10.300      10.450      10.600

Results from 2.2.14

Nothing changes, you just wrote the code in a different way.

Results from 2.2.15

From the solution listing of the first solve, it shows:

---- VAR DAM Damages from climate change in terms of production losses

              LOWER          LEVEL          UPPER         MARGINAL

1.2000        -INF            0.0500        +INF             .

1.2001        -INF            0.0500        +INF             .

1.2002        -INF            0.0500        +INF             .

1.2003        -INF            0.0500        +INF             .

1.2004        -INF            0.0500        +INF             .

2.2000        -INF            0.0500        +INF             .

2.2001        -INF            0.0500        +INF             .

2.2002        -INF            0.0500        +INF             .

2.2003        -INF            0.0500        +INF             .

2.2004        -INF            0.0500        +INF             .

3.2000        -INF            0.0500        +INF             .

3.2001        -INF            0.0500        +INF             .

3.2002        -INF            0.0500        +INF             .

3.2003        -INF            0.0500        +INF             .

3.2004        -INF            0.0500        +INF             .

The display statement shows:

----     68 PARAMETER RES

                 2000        2001        2002        2003        2004

1st solve       8.135       8.039       8.153       8.277       8.420

2nd solve       9.925      10.039      10.153      10.277      10.420

As a result of the damages, production goes down; this will lead to lower emissions and concentrations. Emissions are not exactly 5 percent lower than in the previous exercise, as the bounds on the variables also influence the results.

Using the conditional statement on the damage function, damages will be:

---- VAR DAM Damages from climate change in terms of production losses

              LOWER          LEVEL          UPPER         MARGINAL

1.2000        -INF            0.0500        +INF             .

1.2001        -INF            0.0500        +INF             .

1.2002        -INF            0.0500        +INF             .

1.2003        -INF            0.0500        +INF             .

1.2004        -INF            0.0500        +INF             .

2.2000        -INF            0.0500        +INF             .

2.2001        -INF            0.1000        +INF             .

2.2002        -INF            0.1000        +INF             .

2.2003        -INF            0.1000        +INF             .

2.2004        -INF            0.1000        +INF             .

3.2000        -INF            0.0500        +INF             .

3.2001        -INF            0.0500        +INF             .

3.2002        -INF            0.0500        +INF             .

3.2003        -INF            0.0500        +INF             .

3.2004        -INF            0.0500        +INF             .

 

----     68 PARAMETER RES

                 2000        2001        2002        2003        2004

1st solve       8.135       7.961       8.072       8.193       8.333

2nd solve       9.925       9.961      10.072      10.193      10.333

The higher damages will strengthen the effects on emissions.

Results from 2.2.16

Sector-specific emission coefficients:

----     71 PARAMETER RES

                 2000        2001        2002        2003        2004

1st solve       8.145       7.960       8.047       8.136       8.229

2nd solve       9.970       9.960      10.047      10.136      10.229

Remember that the sector specific coef is also part of the equation CO2. COEF should be moved inside the SUM.

Changing the conditional statement for damages leads to:

---- VAR DAM Damages from climate change in terms of production losses

              LOWER          LEVEL          UPPER         MARGINAL

1.2000        -INF            0.0500        +INF             .

1.2001        -INF            0.0500        +INF             .

1.2002        -INF            0.0500        +INF             .

1.2003        -INF            0.0500        +INF             .

1.2004        -INF            0.0500        +INF             .

2.2000        -INF            0.0500        +INF             .

2.2001        -INF            0.0500        +INF             .

2.2002        -INF            0.1000        +INF             .

2.2003        -INF            0.1000        +INF             .

2.2004        -INF            0.1000        +INF             .

3.2000        -INF            0.0500        +INF             .

3.2001        -INF            0.0500        +INF             .

3.2002        -INF            0.0500        +INF             .

3.2003        -INF            0.0500        +INF             .

3.2004        -INF            0.0500        +INF             .

 

----     71 PARAMETER RES

                 2000        2001        2002        2003        2004

1st solve       8.145       8.063       8.047       8.136       8.229

2nd solve       9.970      10.063      10.047      10.136      10.229

Results from 2.2.17

The model status:

L O O P S         SOL        1st solve

               S O L V E      S U M M A R Y

     MODEL   CLIMATE             OBJECTIVE  CONCENT

     TYPE    DNLP                DIRECTION  MINIMIZE

     SOLVER  MINOS5              FROM LINE  62

 

**** SOLVER STATUS     1 NORMAL COMPLETION

**** MODEL STATUS      2 LOCALLY OPTIMAL

**** OBJECTIVE VALUE               39.6216

 

 RESOURCE USAGE, LIMIT          0.109     1000.000

 ITERATION COUNT, LIMIT        15        10000

 EVALUATION ERRORS              0            0

 

The results:

----     71 PARAMETER RES

                 2000        2001        2002        2003        2004

1st solve       8.050       7.915       7.805       7.884       7.967

2nd solve       9.827       9.915       9.805       9.884       9.967

Results from 2.2.18

----     28 PARAMETER INDEX         Straight line from zero to one

2001 0.250,    2002 0.500,    2003 0.750,    2004 1.000

Note that the solution listing does not display zero values; hence INDEX(“2000”) is not displayed.

Results from 2.2.19

In all cases, the optimal value for alpha is 0.8, which is equal to the upper bound. This means that GAMS gives the lowest possible weight to OTHER emissions. As these exceed the values of CO2 emissions, this was to be expected: GAMS tries to find the lowest combined emissions and adjusts the value of alpha to that purpose.

Solving Exercise 2.1.7. with free variable:

LOWER     LEVEL     UPPER    MARGINAL

---- VAR TAX            -INF     15.000     +INF       .

---- VAR DAMAGE         -INF  37500.000     +INF       .

---- VAR ST_RATE        -INF      1.250     +INF       .

---- VAR CATTLE         -INF   1250.000     +INF       EPS

---- VAR OBJ            -INF   6250.000     +INF       .

The optimal tax rate is 15.

Results from 2.2.20

----  63 PARAMETER check  Auxiliary parameter to check matching totals

( ALL       0.000 )

 

----  63 PARAMETER smalldataset  The aggregated dataset (usable input)

                  agri    industry    services        cons     Col_tot

agri             5.000                              45.000      50.000

industry        15.000     190.000      30.000     115.000     350.000

services        10.000      40.000     370.000     280.000     700.000

primary_in      20.000     120.000     300.000                 440.000

Row_tot         50.000     350.000     700.000     440.000

Results from 2.2.21

Did you remember to change the set SOL? The command OTHER(T)=7 in the loop should be changed to OTHER(T)=OTHER(T)+2.

----     70 PARAMETER RES

                 2000        2001        2002        2003        2004

1st solve       8.050       7.915       7.805       7.884       7.967

2nd solve       9.827       9.915       9.805       9.884       9.967

3rd solve      11.827      11.915      11.805      11.884      11.967

The model focuses on the build-up of greenhouse gasses stemming from production. One could use the model to analyse the relationship between production quantities per sector and the building-up of greenhouse gas emissions. The inclusion of damages makes this model more realistic, as higher production values lead to higher damages, which in turn will destroy some produced goods. The relationship between damages and concentrations is that damages reduce production and hence reduce emissions of CO2. Consequently, concentrations of greenhouse gasses also go down. But there are a few problems: in this model, production plays only a negative role as it causes emissions, but in reality, production will increase consumption and hence utility and is thus a ‘good’ thing. Then, if production is ‘good’, damages are ‘bad’, while they are only ‘good’ in this model. But either good or bad, damages will decrease emissions.

You can make the model more realistic by including emission reductions through abatement, by including and maximising consumption subject to a present concentration maximum, et cetera.

 



[1] If you use a different solver than Minos, the process window will look different, but the same essential information is displayed.