16.01.2015 Views

GAMS — The Solver Manuals - Available Software

GAMS — The Solver Manuals - Available Software

GAMS — The Solver Manuals - Available Software

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

124 CONOPT<br />

of 4.1**2, which means that Jacobian values outside the range EXP(-4.1)=0.017 to EXP(+4.1)=60.4 are about<br />

as common at values inside. This range is for most models acceptable, while a variance of 5, corresponding to<br />

about half the derivatives outside the range EXP(-5)=0.0067 to EXP(+5)=148, can be dangerous.<br />

6.5.1 Scaling of Intermediate Variables<br />

Many models have a set of variables with a real economic or physical interpretation plus a set of intermediate<br />

or helping variables that are used to simplify the model. We have seen some of these in section 6.3 on Simple<br />

Expressions. It is usually rather easy to select good scaling units for the real variables since we know their order<br />

of magnitude from economic or physical considerations. However, the intermediate variables and their defining<br />

equations should preferably also be well scaled, even if they do not have an immediate interpretation. Consider<br />

the following model fragment where X, Y, and Z are variables and Y is the intermediate variable:<br />

SET P / P0*P4 /<br />

PARAMETER A(P) / P0 211, P1 103, P2 42, P3 31, P4 6 /<br />

YDEF .. Y =E= SUM(P, A(P)*POWER(X,ORD(P)-1));<br />

ZDEF .. Z =E= LOG(Y);<br />

X lies in the interval 1 to 10 which means that Y will be between 211 and 96441 and Z will be between 5.35 and<br />

11.47. Both X and Z are reasonably scaled while Y and the terms and derivatives in YDEF are about a factor 1.e4<br />

too large. Scaling Y by 1.e4 and renaming it YS gives the following scaled version of the model fragment:<br />

YDEFS1 .. YS =E= SUM(P, A(P)*POWER(X,ORD(P)-1))*1.E-4;<br />

ZDEFS1 .. Z =E= LOG(YS*1.E4);<br />

<strong>The</strong> Z equation can also be written as<br />

ZDEFS2 .. Z<br />

=E= LOG(YS) + LOG(1.E4);<br />

Note that the scale factor 1.e-4 in the YDEFS1 equation has been placed on the right hand side. <strong>The</strong> mathematically<br />

equivalent equation<br />

YDEFS2 .. YS*1.E4 =E= SUM(P, A(P)*POWER(X,ORD(P)-1));<br />

will give a well scaled YS, but the right hand side terms of the equation and their derivatives have not changed<br />

from the original equation YDEF and they are still far too large.<br />

6.5.2 Using the Scale Option in <strong>GAMS</strong><br />

<strong>The</strong> rules for good scaling mentioned above are exclusively based on algorithmic needs. <strong>GAMS</strong> has been developed<br />

to improve the effectiveness of modelers, and one of the best ways seems to be to encourage modelers to write<br />

their models using a notation that is as ”natural” as possible. <strong>The</strong> units of measurement is one part of this<br />

natural notation, and there is unfortunately often a conflict between what the modeler thinks is a good unit and<br />

what constitutes a well scaled model.<br />

To facilitate the translation between a natural model and a well scaled model <strong>GAMS</strong> has introduced the concept<br />

of a scale factor, both for variables and equations. <strong>The</strong> notation and the definitions are quite simple. First<br />

of all, scaling is by default turned off. To turn it on, enter the statement ”.SCALEOPT = 1;” in your<br />

<strong>GAMS</strong> program somewhere after the MODEL statement and before the SOLVE statement. ”” is the name<br />

of the model to be solved. If you want to turn scaling off again, enter the statement ”.SCALEOPT = 0;”<br />

somewhere before the next SOLVE.<br />

<strong>The</strong> scale factor of a variable or an equation is referenced with the suffix ”.SCALE”, i.e. the scale factor of<br />

variable X(I) is referenced as X.SCALE(I). Note that there is one scale value for each individual component of a<br />

multidimensional variable or equation. Scale factors can be defined in assignment statements with X.SCALE(I)

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!