## index set control

Problems with syntax of GAMS
irfan
User Posts: 2
Joined: 2 years ago
Location: TURKIYE

### index set control

I wrote a equation my model vrp. But it didn't run. x is a binary variable, x(i,j,k) i source and j destination, k is a vehicle. p is an any arrival point, when k. vehicle arrive p.th point and then depart. p and pp is an alias i,j respectivelly. Could anyone solve this problem.
Thanks.

arrive(k).. sum((i,pp),x(i,pp,k)) - sum((p,j)\$(p.val=pp.val),x(p,j,k))=e=0;

User Posts: 108
Joined: 2 years ago

### Re: index set control

Hmm, this line is incorrect:

arrive(k).. sum((i,pp),x(i,pp,k)) - sum((p,j)\$(p.val=pp.val),x(p,j,k))=e=0;

You don't have "control" of set pp at that point, more informally, which element of pp do you mean to appear ?

What is the constraint supposed to achieve ?

irfan
User Posts: 2
Joined: 2 years ago
Location: TURKIYE

### Re: index set control

Hi, thank you for your response,
this constraint typicslly VRP arriving and depart constraint. if value of pp=1, value of p should be 1, shortly, when a vehicle arrive i.th point and then depart i.point. (i: source, j: destination), is syntax "\$(p.val=pp.val)" assing pp value to p value. Or may be write this equation to RHS for assignning. Thanks.

User Posts: 108
Joined: 2 years ago

### Re: index set control

I don't know VRP models and sincerely I can't understand from your description what this constraint is supposed to achieve. Do you mean:

"If a vehicle arrives at a point p, it must also leave it" ?

If so, this can be written as:

arrAndDep(k,p).. sum(i\$(not sameas(i,p)),x(i,p,k)) =e= sum(i\$(not sameas(i,p)),x(p,i,k)) ;

Beware this constraint does not exclude "roundtrips" (i.e. "going back to the source") or routes that "visit" p more than one time.