|
Using GAMS scaling assistance |
Top Previous Next |
|
Generally the user can do a better job than the solver in scaling due to understanding of the model structure. GAMS also allow user controlled model scaling that can be employed to improve over solver based scaling. This procedure allows the user to specify scaling factors that are used to both alter the units in the model at hand resulting in a better-scaled model and descale the results. The procedure accepts a scale factor, both for variables and equations. The syntax to enter such commands for variables and equations is:
variablename.scale(setdependency)=k1; equationname.scale(setdependency)=k2;
equationname is the name of a problem equation; scale is a variable or equation attribute setdependency are the associated set elements; and k1 is a number or expression giving a number that will multiply all coefficients associated with the named variable k2 is a number or expression giving a number that will divide all coefficients associated with the named equation Scaling is turned off by default. Setting the model attribute modelname.scaleopt to 1 activates the scaling feature.
modelname.scaleopt=1;
where modelname is that named used in the model and solve statements. The scaling statements that would be used in a GAMS program of the scaling example discussed above are (scale.gms)
scalemod.scaleopt=1; obj.scale=10000; z.scale=obj.scale; avail.scale("r1")=10000; x.scale("x1")= avail.scale("r1"); avail.scale("r3")=1000; avail.scale("r4")=50; x.scale("x4")=1/50;
In turn, GAMS would automatically scale the model and would present the results after reverse scaling to recover the original solution. More generally in a model with variables named PRODUCTION and SALES along with equations named RESOURCES and PRODBAL one could introduce the scaling statements
modelname.scaleopt=1; SCALFACTOR(ITEMS)=50; SCALFACTOR("CARS")=100; PRODUCTION.SCALE (ITEMS) = 1000; SALES.SCALE (PRODUCTS) = 2000; RESOURCES.SCALE (TYPES,OTHERSET) = SCALFACTOR(ITEMS); PRODBAL.SCALE ("CARS") = 50;
much as in the manner of defining upper or lower bounds. Note here I can set scales using set indexing as in normal GAMS calculations.
|