If-Else Statement (Not $ sign)

Problems with syntax of GAMS
Post Reply
barsssk
User
User
Posts: 5
Joined: 6 years ago

If-Else Statement (Not $ sign)

Post by barsssk »

Hello everyone,

I am aware of $ sign, but in my knowledge it is used for conditional definitions of variables, equations, parameters and etc. What I want to do is that controlling a code block(solve statement in this case) as it can be basically done in every coding language. Here is an example:

if(x=1){
option mip=cplex;
option optcr = 0.00001;
model model1 /a,b,c/;
solve model1 min z using mip;
}else{
option mip=cplex;
option optcr = 0.00001;
model model2 /a,d,e/;
solve model2 min z using mip;
}

Is it possile to do this ?

Thanks in advance
User avatar
Renger
Posts: 639
Joined: 7 years ago

Re: If-Else Statement (Not $ sign)

Post by Renger »

Hi barssk

Take a look at the documentation https://www.gams.com/24.8/docs/userguid ... seif_2.htm

Cheers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
barsssk
User
User
Posts: 5
Joined: 6 years ago

Re: If-Else Statement (Not $ sign)

Post by barsssk »

Renger wrote: 6 years ago Hi barssk

Take a look at the documentation https://www.gams.com/24.8/docs/userguid ... seif_2.htm

Cheers
Renger
Thank you very much Renger. No idea why I couldnt find this before :)
Post Reply