Problem with loop Topic is solved

Problems with syntax of GAMS
Post Reply
Bingo LI
User
User
Posts: 19
Joined: 2 years ago

Problem with loop

Post by Bingo LI » 3 months ago

Dear All,
I am solving a problem with GAMS 24.4/cplex. There are two Loop in my model, and they have to exist in my model. In addition, the function of “break” or “continue” is infeasible.
I want to terminate the inner LOOP "t", and start a new outer LOOP "k" when some condition is met, such as " b(k,t)>5". However, the result is wrong when I terminate the inner LOOP. Could you please help in obtaining the right results?
Thank you.

20200620100548.png
20200620100548.png (8.51 KiB) Viewed 1353 times
Attachments
Untitled_1.gms
(645 Bytes) Downloaded 41 times
test.xlsx
(14.83 KiB) Downloaded 41 times

User avatar
dirkse
Moderator
Moderator
Posts: 127
Joined: 4 years ago
Location: Fairfax, VA

Re: Problem with loop

Post by dirkse » 3 months ago

Bingo,

You mention CPLEX, but your GAMS code doesn't contain any models or solves. You mention the "break" and "continue" statements, but you don't use those in your GAMS code. So I'm confused as to whether these things are relevant to your question or not.

In the code you sent, you don't reset the condition for the inner loop prior to entering the inner loop. You have to set converge_ini to 0 inside the outer loop prior to entering the inner loop. Then the computation does something reasonable.

You can do this more easily using a break statement. I included this variant in the example attached.
Steve.gms
(981 Bytes) Downloaded 42 times
It worked fine for me with GAMS 30.3.

-Steve

Bingo LI
User
User
Posts: 19
Joined: 2 years ago

Re: Problem with loop

Post by Bingo LI » 3 months ago

Thank you for your answer.
The problem is solved by setting converge_ini to 0.
The function of “break” or “continue” is not contained in GAMS 24.4.
Again, thank you.

Li

Post Reply