|
What is the new Z variable in the optimization problem? |
Top Previous Next |
|
In the optimization problem I had three variables as it was originally stated but in the GAMS formulation I have four. Why? GAMS requires all optimization models to be of a special form. Namely, given the model
Maximize cx
It must be rewritten as
R=CX
where R is a variable unrestricted in sign. This variable can be named however you want it named (in the above example case Z). There always must be at least one of these in every problem which is the objective function variable and it must be named as the item to maximize or minimize. Thus in a problem one needs to declare a new unrestricted variable and define it through an equation. In our optimization example (optimize.gms) we declared Z as a Variable (not a Positive Variable), then we declared and specified an equation setting Z equal to the objective function expression and told the solver to maximize Z,
VARIABLES Z; EQUATIONS OBJ, land , labor; OBJ.. Z =E= 109 * Xcorn + 90 * Xwheat + 115 * Xcotton; SOLVE PROBLEM USING LP MAXIMIZING Z;
Note users do not always have to add such an equation if there is a variable in the model that is unrestricted in sign that can be used as the objective function. For example the equation solving case (nonlinsys.gms) uses a maximization of ba as a dummy objective function (as further discussed below the problem is really designed to just solve the nonlinear system of equations and the objective is just there because the model type used needed one). |