Urgent, Please Help...

Im trying to run a VRP Model, but i have some issues; this is my model:

1.- HOW CAN I MAKE THAT THE VEHICLE BEGIN IN THE DEPOT, AND HOW CAN I MAKE THE SUBINDEX i BE DIFFERENT TO J IN THE SUM …


sets
i /i1i7/
m /m1
m7/
;
alias (i,j,k);

alias (subi,subj);
Sets offdiag0(i,j)
offdiag1(i,j)
offdiag2(i,j)
offdiag3(i,j)
offdiag4(i,j);

offdiag0(i,j)=yes;
offdiag0(i,i)=no;

scalar

Q /50/;

parameters

D(i)
/i2 150
i3 250
i4 300
i5 450
i6 345
i7 260 /
;

table c(i,j) ‘distance matrix (KM)’


i1 i2 i3 i4 i5 i6 i7
i1 97 205 139 86 60 220
i2 129 103 71 105 258
i3 219 125 175 386
i4 167 182 180
i5 51 296
i6 279
i7

;



c(i,j) = max(c(i,j),c(j,i));

set arcs(i,j);
arcs(i,j)$c(i,j) = yes;

set i0(i) /%depot%/;

set i2(i);
i2(i)$(not i0(i)) = yes;

scalar n ‘number of nodes’;
n = card(i);

binary variables x(i,j,m);

variable
z
y(i)
f
V
;

equations
R1(j)
R2(i)
R3(l,m)
R4(m)
R5(m)
R6(i,j)
R7
R8
R9
cost
;


R1… sum((i2(j),m), x(‘%depot%’,j)$offdiag0)) =e= 1; (i must to be diferent to j)

R2… sum((i2(i),m), x(i,‘%depot%’)) =e= 1;

R3… sum((i2(k),m), x(‘%depot%’,k))- sum((i2(k),m), x(k,‘%depot%’)) =e= 0

R4… sum((i2(i),m), x(i,‘%depot%’)) =l=1

R5… sum((i2(j),m), x(‘%depot%’,j)) =l=1

R6… y(j) =g= y(i) + D(j) - Q + (Q*((x(i,j,m)+(x(j,i,m))-((D(j)+D(i))*((x(j,i,m))

R7… y(j) =l= (y(‘%depot%’,j,m))*D(j)+(1-(x(‘%depot%’,j,m)))*Q

R8… D(i)=l=y(i)=l=Q

R9… sum((i2(j),m), x(‘%depot%’,j)) =e= V

cost… z =e= sum(arcs, c(arcs)*x(arcs));


model carro3 /all/;
*carro3.optfile=1;
solve carro3 using mip minimizing z;

Hi
If you want to sum over i leaving out the element j, you can do this as follows:

myeq(j)
      A(j) =E= sum(i$(not sameas(i,j), X(i,j));

How can you ensure that they start from the depot is, so I believe already part of your model:

sum((i2(j),m), x('%depot%',j)$offdiag0)) =e= 1; (i must to be diferent to j)

Cheers
Renger

Thanks alot :slight_smile: :slight_smile: