We are trying to solve a non-linear optimization system for H units in a loop (H=4000). We obtain optimal solutions for some units (f) and Infeasable (nf=H-f) for the others. How can we get the subset of units of H ie f for which we have obtained an optimal solution. We will continue to work only with those units for which we have an optimal solution.

Thank you for your answer.

Dorothée

Hi,

You can create a subset f(H).

Inside the loop, you can assign it elements to it. The broad idea is as follows. Following code fragment is syntactically incomplete.

loop(H,

solve…

if (feasible,

f(H) = yes;

);

);

f(H) = yes is the place where you assign elements to set f. After the completion of this loop, you can use set f. Hope this helps.

- Atharv

Thank you for your response. However, we have an error message of the type *unknown symbol* for “feasible”. Does this need to be declared previously? Thank you. Dorothée

Thank you very much Atharv, for your answer.

However, we have an error message of the type unknown symbol for “feasible”. Does this need to be declared previously? I suppose so but how?

Thank you again. Dorothée

As I mentioned in my message, the code fragment is not syntactically complete.

Instead of if (feasible, …)

You should check modelname.numinfes https://www.gams.com/latest/docs/UG_GamsCall.html#GAMSAOnuminfes

(of course, modelname here is your model name)

you would write

if (modelname.numinfes eq 0,

…

);

Again the code fragment is not tested for syntax and can have minor errors. Your question was about populating the set f and this is the way to do it.

- Atharv

Merci beaucoup. Notre problème est effectivement résolu.