## Recalculating parameters based on model solution

Problems with modeling
James702
User Posts: 1
Joined: 2 years ago

### Recalculating parameters based on model solution

Hello all

I am a fairly experienced GAMS user but this one remains a mystery:

I am reading a paper that involves optimizing cattle diets under environmental policy scenarios (i.e. methane restrictions). The model is an LP model written in GAMS. From the text of the paper, the authors describe that the model involves a process of updating model parameters based on the optimal solution of the model. To put it in their words:

'the feed composition matrix calculated using the predicted DMI (dry matter intake) might not reflect the nutrient composition of feeds at the
model solution intake level. To ensure that protein and energy requirements are met, an iterative process was used in which the feed composition matrix was updated according to the actual intake at the model solution and the model was re-solved. The process was repeated
until a stable solution was found; that is, the DMI and concentrate proportions of the diet were relatively con-
stant in the final linear program.'

All the programming I have done in GAMS simply involves setting up a model, with a given objective function and constraints, and hitting 'Run'.
The model these people developed involves recalculating parameters during the model solve phase, and then re-running the model with the updated parameters. They give no indicartion of how this was actually coded. I'm thinking it could have potentially been done using a loop, but am not really sure.

If anyone knows of how this would be implemented in code, and what, if any, types of solvers are used, it would be appreciated. Thanks

PS: the link to the paper: https://www.ncbi.nlm.nih.gov/pubmed/22365210

Renger
Posts: 545
Joined: 3 years ago

### Re: Recalculating parameters based on model solution

Hi
This can be done in a loop (or a while loop, if you have a specific convergence criterium)

Assuming that parameter a is a model parameter and AVAR is the solution of the model
parameter apar;
variable AVAR;

set iterations iter /1*100/

loop(iter,
solve yourmodel;
apar = AVAR.L;
);

Cheers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist