index set control

Problems with syntax of GAMS
Post Reply
User avatar
irfan
User
User
Posts: 2
Joined: 1 year ago
Location: TURKIYE

index set control

Post by irfan » 4 months ago

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;

cladelpino
User
User
Posts: 108
Joined: 1 year ago

Re: index set control

Post by cladelpino » 4 months ago

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 ?

User avatar
irfan
User
User
Posts: 2
Joined: 1 year ago
Location: TURKIYE

Re: index set control

Post by irfan » 4 months ago

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.

cladelpino
User
User
Posts: 108
Joined: 1 year ago

Re: index set control

Post by cladelpino » 4 months ago

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.

Post Reply