Topic
• 3 replies
• Latest Post - ‏2014-05-23T06:20:37Z by AlexFleischer
viva0521
32 Posts

# Pinned topic lingo constraint in OPL

‏2014-05-22T00:43:56Z |

Hi, there

I am duplicating one of my lingo model to opl. Here I have one constraint in lingo as:

@For(path(i,j,o,d) | j#EQ#1 #and# j#NE#o #and# j#NE#d #AND# i#NE#o #and# i#NE#d #and# i#GE#9  #and# i#LE#10:x(i,j,o,d)= 0);

(i,j) here are the node index and supposed to be integer.This is to restrict the flow on specific arc is equal to 0.

So I tried following:

forall ( i, j in node, j == 1, j != o, j != d, i != o, i != d,  i == 9, i == 10) flow [i] [j] [o] [d] ==0.

It didn't work, any idea? Thanks in advance!

Updated on 2014-05-22T00:49:37Z at 2014-05-22T00:49:37Z by viva0521
• AlexFleischer
3096 Posts

#### Re: lingo constraint in OPL

‏2014-05-22T08:18:30Z

Hi

forall ( i, j in node, j == 1, j != o, j != d, i != o, i != d,  i == 9, i == 10)

can you try

forall ( i, j in node : (j == 1) && ( j != o) &&  (j != d)  &&  (i != o) &&  (i != d) &&  (i == 9) && (i == 10))

?

regards

• viva0521
32 Posts

#### Re: lingo constraint in OPL

‏2014-05-22T19:54:10Z

Hi

forall ( i, j in node, j == 1, j != o, j != d, i != o, i != d,  i == 9, i == 10)

can you try

forall ( i, j in node : (j == 1) && ( j != o) &&  (j != d)  &&  (i != o) &&  (i != d) &&  (i == 9) && (i == 10))

?

regards

Alex, thanks a lot! It works now. I really appreciate your valuable comments!

By the way, when I was trying to output my optimal solution, I wrote:

execute DISPLAY {
writeln("\n<from node, to node, , o, d, flow[i][j][o][d]>\n");
for(i,j in Node, o in Ori, d in Dest)
if(flow[i][j][o][d] > 0)
writeln("<",i,",",j,",",o,",",d,",",flow[i][j][o][d],">");
}

It is said for(i,j in Node, o in Ori, d in Dest) missing ")" after Node, I am wondering what is wrong here? Thanks again!

• AlexFleischer
3096 Posts

#### Re: lingo constraint in OPL

‏2014-05-23T06:20:37Z
• viva0521
• ‏2014-05-22T19:54:10Z

Alex, thanks a lot! It works now. I really appreciate your valuable comments!

By the way, when I was trying to output my optimal solution, I wrote:

execute DISPLAY {
writeln("\n<from node, to node, , o, d, flow[i][j][o][d]>\n");
for(i,j in Node, o in Ori, d in Dest)
if(flow[i][j][o][d] > 0)
writeln("<",i,",",j,",",o,",",d,",",flow[i][j][o][d],">");
}

It is said for(i,j in Node, o in Ori, d in Dest) missing ")" after Node, I am wondering what is wrong here? Thanks again!

Hi,

because in the scripting part, the syntax for "for" is not the same as for "forall"