Dear GAMS experts,

I have a modeling problem which seems not to be difficult to solve, but I cannot find a way to handle it.

Assume there are two variables in your model that one of the variables is integer (X) and another one is binary (Y).

If X is 0 then Y is 0 as well, otherwise if X=1,2,3, … then Y=1.

I don’t know how I can define these conditional equation in GAMS, since one cannot define an equation in GAMS with conditions on variables.

Can anybody help me?

Thanks for your time to read the post.

Hi, try these equations:

eq… X =l= M*Y

eq… X =g= Y

M is a parameter and the upper bound of X

If Y =1

X =l= M

X =g= 1

if Y = 0

X =l= 0

X =g= 0

Bye!

Dear Manassaldi,

Thank you very much to reply my post.

Your idea is great and I would try to apply it to my model.

Sincerely yours.

Dear Manassaldi,

can you please tell how to handle binary variables in a model as a normal variable? like in TSP x(i,j) is a binary variable when an edge is chosen between vertex i and vertex j. Can we treat this variable as a normal variable? please help.

Hi, solving the relaxed problem the binary variables become continuous. Try solving the model as RMIP instead of MIP.

Cheers!

But then it will give the wrong output in case of TSP. Lets say we have the following code, what if we want binary variable x(i,j) as normal variable?, can we do it and solve it using LP that still give us the same result as MIP in quick time.

mTSP.txt (5.68 KB)

Hi, I don’t think you can change the nature of a problem. It is possible that there is an alternative LP version but I don’t think so. Otherwise nobody would solve MIP models.

I hope I have been helpful

best

Thank you @Manassaldi

People have suggested different formulations (saying it as ILP) in their papers for TSP but all the ILP’s given in GAMS library are solved by MIP only. Do you have any idea where can I find out GAMS code of TSP solved using LP.

Thanks in advance.

Hi, I don’t know where to find this. But, You can try to implement the proposed models in GAMS.

Best.