$title Example: Fibonacci example using dynamic sets option limrow = 0, limcol = 0; set I / A, B, 1*20 /; set J(I) /1*20/; variable x(I), cost; positive variable x; equation fibonacci(I) objective; * define fibonacci equation only over the set J fibonacci(J(I)).. x(I) =e= (x(I-1)+x(I-2)); objective.. cost =e= sum(I,x(I)); x.fx('A') = 1; x.fx('B') = 1; model fib /fibonacci, objective/; solve fib using lp minimizing cost; display x.l; * now modify the set J: delete the last two elements. J('19') = no; J('20') = no; * after the solve, x('19') and x('20') will be set to their * lower bounds of zero, since they are no longer constrained by * the "fibonacci" constraint. There's no need to change the model - * by changing J we have changed the definition of the "fibonacci" * constraint. solve fib using lp minimizing cost; display x.l