Mathematical Modeling with LPL : Explain and run a Model
Problem Statement
Modeling Description
||
Back to MatMod
model Icosian "Hamiltonian's Game"; set i,j "set of vertices"; e{i,j} "set of edges"; parameter d{i,j} "distances"; binary variable x{i,j|i<>j}; constraint A{i}: sum{j} x = 1; B{j}: sum{i} x = 1; F{i,j|j>i}: x[i,j] + x[j,i] <= 1; G: x[14,7] "This is enough to make a single tour"; minimize obj: sum{i,j} d*x "minimize a round trip"; if obj then Write('No tour length of zero exists\n'); else Write('An Icosian tour exists, see graph.\n'); end; draw; model data "The Icosian Game Instance"; i:=[1..20]; e{i,j}:= [(1,2) (2,3) (3,4) (4,5) (5,1) (1,6) (2,7) (3,8) (4,9) (5,10) (6,14) (14,7) (7,15) (15,8) (8,11) (11,9) (9,12) (12,10) (10,13) (13,6) (14,19) (15,20) (11,16) (12,17) (13,18) (16,17) (17,18) (18,19) (19,20) (20,16)]; d{i,j}:= if(e[i,j] or e[j,i],0,1); end model draw; parameter r:=6; PI:=4*Arctan(1); X{i}:=if(i<6,1,i<11,0.75,i<16,0.5,0.3)*r* Cos(3*PI/if(i<11,2,6)+(i-1)*2*PI/5)+r+.3; Y{i}:=if(i<6,1,i<11,0.75,i<16,0.5,0.3)*r* Sin(3*PI/if(i<11,2,6)+(i-1)*2*PI/5)+r+.3; Draw.Scale(50,50); for{i,j|e} do Draw.Line(X[i],Y[i],X[j],Y[j]); end; for{i,j|x} do Draw.Line(X[i],Y[i],X[j],Y[j],3,5); end; --for{i,j|x} do Draw.CLine(X[i],Y[i],X[j],Y[j],1,3,5); end; for{i} do Draw.Circle(i&'',X,Y,.35,1,0) ; end; end; end
Problem Statement
Modeling Description
Back to model
The solution is as follows:
The LOG-File output of LPL is as follows: