Mathematical Modeling with LPL : Explain and run a Model
Problem Statement
Modeling Description
||
Back to MatMod
model cvrp2 "Sequential Formulation"; set i,j,k "nodes set"; parameter c{i}; D{i,j}; K; C; binary variable x{i,j|i<>j}; variable L{i} [c..C]; T{i}; TZ; constraint A: sum{j} x[1,j] = K; B1{i|i<>1}: sum{j} x[i,j] = 1; B2{j|j<>1}: sum{i} x[i,j] = 1; S2{i,j|i
1}: L[i] - L[j] <= (1-x)*C - c[i]; minimize obj: sum{i,j} D*x; model data; string File:=['P-n19-k2.vrp']; //opt=212 (problem 1) (K=2) --string File:=['E-n22-k4.vrp'];//opt=375 (problem 2) (K=4) --string File:=['A-n32-k5.vrp'];//opt=784 (problem 3) (K=5) parameter X{i}; Y{i}; dum;; Read(File&',%1;-1:CAPACITY',dum,dum,C); Read{i}('%1:NODE_COORD_SECTION:DEMAND_SECTION',i,X,Y); Read{i}('%1:DEMAND_SECTION:DEPOT_SECTION',i,c); K:=Ceil(sum{i} c/C); D{i,j} := Trunc(Sqrt((X[i]-X[j])^2+(Y[i]-Y[j])^2)+0.5); parameter min0:=min{i,j|D} D; max0:=max{i,j|D} D; set e{i,j}:=D<2*min0; set e1{i,j}:=D>=max0/1.5; set e2{i,j}:=D<=3.5*min0; end model output friend data; set h:=1..K; parameter C{i}; E{i,j|i>1 and j>1}:=x; nC:=Graph.Components(E,C); CC{i,h}:=C=h+1 or i=1; L{h}:=sum{i,j|x and CC[i,h] and CC[j,h]} D; --Write('The total distance:%d , Capacity: %d , Children: %d\n', obj, Schoolbus.C,sum{i}c); Write{h}('Length of Tour %s: %d , children: %d\n', h,L,sum{i|CC}c); Write{h}('Nodes of Tour %s : %3s\n', h, {i|CC} i); Draw.Scale(5,5); Draw.DefFont('Verdana',12); {i,j|x} Draw.Line(X[i],Y[i],X[j],Y[j],3); {i} Draw.Circle(i&'',X,Y,2,1,0); end end
Problem Statement
Modeling Description
Back to model
The solution is as follows:
The LOG-File output of LPL is as follows: