2

I'm having some trouble modeling this constraint in Julia

enter image description here

right now I have

for k=1:v
 for j = 2:nodes
  @constraint(model,sum(x[i,j,k] for i=1:nodes) == sum(x[j,i,k] for i=1:n))
 end
end

where nodes is the customer set, n includes the depot and the depot clone. K is the number of vehicles, i is the start node and j is the end node.

DJK
  • 8,924
  • 4
  • 24
  • 40
  • 2
    What is the question exactly? – Alexander Morley Jan 06 '17 at 08:17
  • I'm not sure this is the correct way to model the constraint, because I am not getting a fully connected path. Sorry if I was not clear, but I'm looking to see if I anyone knows if I'm modeling it Correctly or not. – DJK Jan 07 '17 at 17:24

1 Answers1

1

I am not sure that you asked a real question but here is how I would model this constraint in julia :

@constraints(model, begin
[i in 2:nodes, k in 1:K], sum(x[j, i, k] for j in 1:nodes if j != i) == sum(x[i, j, k] for j in 1:nodes if j != i) 
end)

If you are not in a complete graph, be sure that you have well defined your variable x[i, j, k] so that it is equal to 0 when there is no arc between i and j.