I am dealing with a discrete math optimization problem on a complete graph. My variables are the arcs but I want to delete the arcs that "cost too much". I have $n$ nodes which means I have $n(n-1)$ arcs before deletion. I define the following set in AMPL

ARCS:={i in 1..n, j in 1..n : i!=j && d[i,j]<= R}

where d[i,j] is the cost on the arc (i,j) and R the limit I am putting.

My problem is that I don't know how to index the variables now. I know I can write

sum{ i in 1..n, j in 1..n : (i,j) in ARCS} blablabla[i,j]

But I think this is quite a tedious way to do. I thought I could write something like this sum{e in ARCS} blablabla[e[0],e[1]]


1 Answer 1



sum{(i,j) in ARCS} blablabla[i,j]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.