|
Changing model structure |
Top Previous Next |
|
Many studies involve model structure modifications. A context sensitive model structure by making constraints or terms in the model conditional (see the discussion in the Conditionals chapter). In particular in the example a conditional constraint on maximum cattle (cowlimit) could be set up based on a scalar (cowlim) and controlled by the scenario looping procedure (comparemod.gms).
scalar cowlim activates cowlimit constraint /1/ equation cowlimit conditional equation on cow limits; cowlimit$cowlim.. sum((animals,livemanage), liveprod(animals,livemanage))=l=100; model farmcowlim /all/ parameter cowlims(scenarios) cowlimit by scenario /base 0, cowlim 1/; loop(scenarios, cowlim=cowlims(scenarios); SOLVE FARMcowlim USING LP MAXIMIZING NETINCOME; );
which imposes the constraint in a conditional manner. It can be desirable from the standpoint of integrity of an advanced basis (see discussion in the Advanced Basis Usage chapter) to make the model size invariant. In such a case one would alter the code above so the constraint was practically rather than physically removes. This could be accomplished by altering the code above to be
scalar cowlim activates cowlimit constraint /1/ equation cowlimit conditional equation on cow limits; cowlimit.. sum((animals,livemanage), liveprod(animals,livemanage))=l=100+(1-cowlim)*1000000; model farmcowlim /all/ parameter cowlims(scenarios) cowlimit by scenario /base 0, cowlim 1/; loop(scenarios, cowlim=cowlims(scenarios); SOLVE FARMcowlim USING LP MAXIMIZING NETINCOME; );
which keeps the constraint but limits the farm to the unattainable million+ cows if the unlimited scenario is being run. Similarly for variables to be eliminated one could alter objective function coefficients so they became very undesirable (adding a term to a maximization problem like (3-1000000$eliminatevar)*x to the objective equation). |