Optimal solution in a loop (NLP) Topic is solved

Solver related questions
Post Reply
doti2109
User
User
Posts: 4
Joined: 3 years ago

Optimal solution in a loop (NLP)

Post by doti2109 »

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
abhosekar
Moderator
Moderator
Posts: 295
Joined: 3 years ago

Re: Optimal solution in a loop (NLP)

Post by abhosekar »

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
doti2109
User
User
Posts: 4
Joined: 3 years ago

Re: Optimal solution in a loop (NLP)

Post by doti2109 »

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
doti2109
User
User
Posts: 4
Joined: 3 years ago

Re: Optimal solution in a loop (NLP)

Post by doti2109 »

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
abhosekar
Moderator
Moderator
Posts: 295
Joined: 3 years ago

Re: Optimal solution in a loop (NLP)

Post by abhosekar »

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_Gam ... AOnuminfes
(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
doti2109
User
User
Posts: 4
Joined: 3 years ago

Re: Optimal solution in a loop (NLP)

Post by doti2109 »

Merci beaucoup. Notre problème est effectivement résolu. :D
Post Reply