Rerun the same model with updated constraint

Hi,

I’m trying to run the same model again with updated constraint limits, the update will be an average of a calculated variable from the first run. What I am doing now is running the model, analyze the result, average the variable of interest, update the limits manually and rerun the model. Is there a way to do this with loop function?

Thanks,
Ahmed

Hi

You could do something like this:

parameter limit 'Updated limit of constraint x' /2/;

equations
   constraintx,
   constrainty(i);
   
constraintx..
      X =G= limit
 
constraintsy(i)..
      Y(i) =E= ...

set loopnr /1*3/;
loop(loopnr,
    solve mymodel;
    limit = sum(i, Y.L(i))/ card(i);
);

I hope this helps
Cheers
Renger