• No results found

A program for the traveling-salesman problem, according to the heuristic algorithm of Lin-Kernighan

N/A
N/A
Protected

Academic year: 2021

Share "A program for the traveling-salesman problem, according to the heuristic algorithm of Lin-Kernighan"

Copied!
14
0
0

Bezig met laden.... (Bekijk nu de volledige tekst)

Hele tekst

(1)

A program for the traveling-salesman problem, according to

the heuristic algorithm of Lin-Kernighan

Citation for published version (APA):

Keulemans, W. K. M. (1977). A program for the traveling-salesman problem, according to the heuristic algorithm of Lin-Kernighan. (Memorandum COSOR; Vol. 7712). Technische Hogeschool Eindhoven.

Document status and date: Published: 01/01/1977

Document Version:

Publisher’s PDF, also known as Version of Record (includes final page, issue and volume numbers)

Please check the document version of this publication:

• A submitted manuscript is the version of the article upon submission and before peer-review. There can be important differences between the submitted version and the official published version of record. People interested in the research are advised to contact the author for the final version of the publication, or visit the DOI to the publisher's website.

• The final author version and the galley proof are versions of the publication after peer review.

• The final published version features the final layout of the paper including the volume, issue and page numbers.

Link to publication

General rights

Copyright and moral rights for the publications made accessible in the public portal are retained by the authors and/or other copyright owners and it is a condition of accessing publications that users recognise and abide by the legal requirements associated with these rights. • Users may download and print one copy of any publication from the public portal for the purpose of private study or research. • You may not further distribute the material or use it for any profit-making activity or commercial gain

• You may freely distribute the URL identifying the publication in the public portal.

If the publication is distributed under the terms of Article 25fa of the Dutch Copyright Act, indicated by the “Taverne” license above, please follow below link for the End User Agreement:

www.tue.nl/taverne

Take down policy

If you believe that this document breaches copyright please contact us at:

openaccess@tue.nl

providing details and we will investigate your claim.

(2)

PROBABILITY THEORY, STATISTICS AND OPERARIONS RESEARCH GROUP

Hemorandum COSOR 77-12

A program for the Traveling-Salesman Problem, according to the heuristic algorithm of

Lin-Kernighan by

W.K.M. Keulemans

Eindhoven, May 1977 The Netherlands

(3)

A program for the Traveling-Salesman Problem, according to the heuristic algorithm of

Lin-Kernighan

by

W.K.M. Keulemans

1. Introduction

The program described in this memorandum has been written in Burroughs Ex-tended Algol (BEA). It is a fair transcription of the heuristic algorithm of Lin-Kernighan [2J. The terminology and notations of Lin-Kernighan will be used. The program follows the basic traveling-salesman algorithm of Lin-Kernighan conscientiously, The refinements of avoiding checkout time, look-ahead and reduction have also been implemented. The program has been writ-ten as a procedure called linkernighan. Computational results are compared with the results of Lin-Kernighan.

2. Till' procedure linkernighan (n,x,dis ,numtours,out)

The ,meaning of the formal parameters is as follows:

n

x

the number of cities minus one, minus one because the counting of the cities starts with zero

an integer variable which is used as an argument for the intrinsic random, which in its turn is used to generate a random starting-tour

dis the distance matrix with dimensions O:n,O:n numtours: the number of tours that has to be generated out an output file

The important identifiers declared ~n linkernighan are:

m

numsol posit

sol

the number of cities (m n + 1)

the number of different locally optimal tours that has been found the positions of the cities in the locally optimal tour are stored in posit

the locally optimal tour is stored in sol

pre,post: these arrays will contain the information about the links common to all locally optimal .tours that have been found in linkernighan; when the first locally optimal tour has been found the predecessors of the cities are stored in pre, the successors in post.

(4)

nb

solutions optimum

an array with the same dimensions as dis, which in every row i will contain the numbers of the cities in order of increas-ing distance to city i; the distance of city i to city i is artificially made very large

the different locally optimal tours are stored in solutions the values corresponding to the tours in solutions are stored in optimum

sortd.istances: a procedure to sort the cities in order of increasing dis

tan-kernighanlin

ces

a procedure which forms the essential part of 1 inkerni ghan , it delivers one locally optimal tour.

3. The procedure sortdistances (n,nb,dis)

The meaning of the formal parameters n,nb,dis in the same as the meaning of the corresponding actual parameters n,nb and dis. The time needed for the sortingprocess is proportional to n log n.

4. The procedure Kerni&hanlin (x,opt,posit,sol)

!

Again the meaning of the formal parameters x,posit,sol is the same as the IUl'aning of the actual parameters x,posit,sol,opt will contain the value of the locally optimal tour.

The important identifiers declared in Kernighanlin are: nodl,nod2 pos 1 ,pos2 positl,soll I startingtour findlink findlinks reverse

nodI and nod2 are used to store a sequence of the cities, this sequence is called an actual tour

posl and pos2 are used to store the positions of the cities corresponding to nod] c.q. nod2

I

each time a better tour has been found this one is stored in solI and the positions of the cities in positl. At the end of this iteration sol] and positI are copied in sol and posit. This may not be done before, because the arrays sol and posit are used to test whether a link is a x-link. a procedure to generate the random startingtour

a procedure to determine the first y-link to be considered a procedure which chooses out of a maXimum of 5 possible candidates the link which maximizes Ix.

11 -

Iy·

I,

this

pro-1+ 1

cedure takes care of the lookahead refinement

a procedure to reverse a specified part of the actual tour, by this reversion a new actual tour is formed

(5)

3

-closeup a procedure which tests whether an actual tour is a better tour than the best tour found sofar in kernighanlin

tourimprovement: this procedure takes care of the iteration process on le-vels > 3 for x-links and on levels> 2 for y-links.

5. Differences between BEA and klgol 60

BEA differs 1n some ways from Algol 60. The differences, that occur in the program, which need some explanation are:

1) In BEA specifications of formal parameters are obligatory. Specifications of arrays must be accompanied by the lowerbounds for each dimension. For reasons of efficiency these lowerbounds are preferred to be zero.

2) In BEA the conception of array-row makes it possible to treat a part of a more dimensional array, in which only the last index varies, as a one dimensional array. For instance a row of a two dimensional array can thus be an actual parameter.

3) In BEA there are not value arrays in the sense of Algol 60. This leads to tile complication that the arrays sometimes have to be copied explicitly. There is however a fast way to copy arrays, this is done by means of the write statement. When a and b are one-dimensional arrays (arrayrows) of

the same length the statement write (a,*,b) copies b in a. The write state-ment is also used to write output to an outputfile, in which case the

identifier a must be a file identifier.

4) The construction: if boolean expression then if boolean expression then is a valid construction in BEA. It can easily be adapted to Algol 60 by the corresponding construction: if boolean expression and boolean expres-sion then.

5) The intrinsics random and mod are implemented in BEA.

6. The implemented refinements

The following refinements have been implemented: a) avoiding checkout time

Each time an improved tour has been found in the procedure Kernighanlin the program checks whether this tour is one of the locally optimal tours found before. If this is the case the search for a better tour may be stopped, because this search already has been done in one of the e.arl ier calls of Kernighanlin.

(6)

b) lookahead

A restricted lookahead is added to the procedure: in aU steps Wl1Crc' ;1

y. is chosen the choice is not made on basis of minimum Iy·

I,

but on

1 1

basis of maximizing g.

=

ix.+11 - ly.1 over a maximum number of 5

POSS1-1 POSS1-1 POSS1-1

ble candidates. c) reduction

Once a number of locally optimal tours have been found by successive calls of kernighanlin, we observe that certain links are common to all of them. For reasons of efficiency the search for better tours is limited by the following reduction: links common to all locally optimal tours may be broken on a level 1.2 or 3, but not on higher levels. This means that links of the actual tour common to all locally optimal tours will not be broken in the procedure tourimprovement.

7. Computational resul ts

The following problems have been run with our program on a B7700:

*

2 3 4 Size 33 42 57 100 Source [ 3J [IJ [3J [4J Frequency of optimum Pre-re- Post-re-duction duction 0.80 0.90 1.00 }.OO 0.23 0.23 0.50 0.50

average number of distinct solutions

cpu-time/tour Pre Post 0.38 0.38 2. 14 0.99 7.3 5.3 8.2 7. 1

The corretiponding results of Lin-Kernighan on a GE635 are:

*

2 3 4 t -Size 33 '42 57 tOO Source [3J [ 1 J [3J [4J Frequency of optimum Pre-re- Post-re-duction duction 1.00 1.00 -0.27 0.43 0.56 0.63

average number of distinct solutions

cpu-time/tour Pre Post 0.8 2.6 8.2 3.8 17.0 5.5

*

2 1 6 4

*

I I 3 3.5

(7)

5

-The results achieved by our program are considerably worse than those achiev-ed hy Lin-Kernighan. By their program the optimum is found more frequently;

the difference in computing time between pre-reduction and post-reduction tours in our program can be explained by the gain achieved by avoiding check-out time, but a few of the locally optimal tours generated after .reduction are new locally optimal tours. Lin-Kernighan have apparently implemented an-other form of reduction than we have done. In our program we start for the post-reduction tours also with a random startingtour and links common to all locally optimal tours may not be broken at a level 4 or deeper. Postreduc-tion starts when either 5 distinct locally optimal tours have been found or so locally optimal tours have been generated. The program of Lin-Kernighan probably does not start with a random startingtour but with a tour in which all the links connnon to the locally optimal tours are present and in which only the links not connnon to all locally optimal tours are chosen at random. This alternative has also been implemented. To the program the procedure re-ducttour is added, which for generates the startingtours for the post-reduc-tion tours. The computing results for this alternative are:

2 3 4 Size 33 42 57 100 Source ! i [3] [ 1 ]

[3J

[4]

Frequency . Pre-re-duction " 0.33 0.71 of optimum cpu-time/tour

*

I

Post-re-duction Pre Post

0.23 8.7 2.5 5 0.92 10. 1

4.

1 4

The results fit moderately to those achieved by Lin-Kernighan, the frequency of optimum for pre-reduction tours may be biased by the fact that post-re-duction tours have been generated once three different locally optimal tours had been found.

7. References

[1] G.B. Dantzig, D.R. Fulkerson, S.M. Johnson: "Solution of a Large-Scale Traveling-Salesman Problem", Opns. Res.

l,

393-410 (1954).

[2] B.W. Kernighan, S. Kin: "An Effective Heuristic Algorithm for the Tra-veling-Salesman Problem", Opns. Res.

ll'

498-516 (1973).

(8)

[3J R.L. Karg, G.L. Thompson: "A Heuris Approach to Solving Traveling-Salesman Problems", Management Sci.

..!.Q,

225-247 (1964).

[4 I P. Krolak, W. Felts, G. Marble: "A Man-Machine Approach toward the Traveling-Salesman Problem", CACM 14, 327-334 (1971).

(9)

1000

2000

3000

4000

5000

6000

7000

8000

9000

10000

11000

12000

13000

14000

15000

16000

~7000

·18000

19000

20000

21000

22000

. 23000

24000

25000

26000

27000

28000

29000

30000

31000

32000

33000

34000

35000

.6000

~7000

38000

39000

40000

41000

42000

43000

44000

45000

46000

47000

48000

49000

50000

. 51000

52000

53000

54000

7

-PROCEDURE LINKERNIGHAN(N,X,DIS,NUMTOURS,OUT);

VALUE

N,NUMTOURS~

INTEGER N,NUMTOURS,X; FILE OUT;

REAL ARRAY DIS(O,OJ;

BEGIN INTEGER I,J,K,L,M,R,NUMSOL,TOURS; REAL OPT;

BOOLEAN OLDSOL,REDUCTION;

INTEGER ARRAY POSIT,SOL,PRE,POST,SEGCOfNJ, NBCO:N,O:NJ,

SOLUTIONSCIINUMTOURS,OfNJ;

REAL ARRAY OPTIMUMC1:NUMTOURS];

PROCEDURE SORTDISTANCES(N,A,P);

VALUE

N~

INTEGER Nf INTEGER ARRAY prO]; REAL ARRAY ACOJ;

BEGIN INTEGER ARRAY CrOtN);

PROCEDURE SORT(L,R);

VALUE L,R; INTEGER L,R;

IF R-L

:>

1

THEN BEGIN INTEGER I,K,IL,IRf

KI=(L+R)/2; SORT(L,K); IRI=K+l; SORT(IR,R); I:=IL:=L;

WHILE IL LEG K AND IR LEG R DO

IF ACPCIL1J LEG ACPCIRJJ

THEN BEGIN CCIJt=P[IlJ; IL:=IL+l; 1:=1+1 END

ELSE BEGIN CCI)t=PCIRJ; IRt=IR+l; 11=1+1 END;

IF IR :> R

THEN WHILE

I

LEG R DO

BEGIN CrIJ:=PCIL]; IL:=IL+l; 1:=1+1 END

ELSE WHILE I LEG R DO

BEGIN CCIJ!=PCIRJ; IR:=IR+l; 11=1+1 END;

II=L-l.;

WHILE 1:=1+1 LEG R DO PCIJ:=C[I)

END

ELSE IF R :::: L

THEN prRJ:=R

ELSE IF ALL)

>

ACRJ

THEN BEGIN PCLJ:=R; PCRJ:=L END

ELSE BEGIN P[Ll:=L; P[R)t=R END;

SORT(O,N)

END SORTDISTANCES;

PROCEDURE SORTSEGCN,SEO);

INTEGER N; INTEGER ARRAY SEO[O];

BEGIN INTEGER I,K,L; REAL F; INTEGER ARRAY PLACECO:NJ;

KI=SOL(NJ; L:=SOLCO);

FOR 1:=1 STEP 1 UNTIL N DO

BEGIN F:=DISCK,L); K:=L; L:=SOL[Il; F:=MAX(F,DISCK,Ll);

F:=F-DISCK,NB[K,OJ1;

PLACE[KJ:=-F

ENII;

K:=SOL(N:H

PLACE(NJ:=-MAX(DIS[K,SOLCN-IJ],DIS[K,SOL[OJ]);

PLACECNJ;=*+DIS[K,NB[K,OJJ;

SORTDISTANCES(N,PLACE,SEQ)

END SORTSEG;

(10)

56000

57000

X

58000

59000

60000

61000

62000

63000

64000

65000

66000

67000

68000

69000

70000

71000

1

000

000

74000

75000

76000

77000

78000

79000

80000

S1000

82000

83000

84000

85000

86000

87000

88000

89000

90000

_ 0 0

~OO

93000

94000

95000

96000

97000

98000

99000

100000

101000 .

102000

~03000

PROCEDURE KERNIGHANLIN(X,OPT,POSIT,SOL);

KERNIGHANLIN DETERMINES ONE LOCAL-OPTIMAL SOLUTION X

INTEGER

x;

REAL OPT; INTEGER ARRAY POSIT,SOlCOJ;

BEGIN INTEGER T1,T2,T3,T4,T5,T6,T7,T8,NT3,NT5,Il,I2,IT2,IT4,IT6,

NILL,NUM,PT,I,J,K,L,M,R,S,V,W,

PT1,PT2,PT3,PT4,PT5,PT6,PT7,PT8;

REAL G,GG,HU,F,MAXGGf

BOOLEAN FOUND,BOOLf

INTEGER ARRAY POS1,POS2,NOD1,NOD2,POSIT1,SOL1CO:NJ, N3,N5Cl:5J'

PROCEDURE STARTINGTOUR(X,POSIT,SOL,OPT);

INTEGER X; REAL OPT; INTEGER ARRAY POSIT,SOLCO];

BEGIN INTEGER I,K,L,M;

INTEGER ARRAY TOURCO:NJ;

MI=N;

FOR 1:=0 STEP 1 UNTIL N DO TOURCIl:=I;

FOR 1:=0 STEP

1

UNTIL N DO

BEGIN K:=ENTIER(RANDOM(X)*M);

END;

SOL(IJ:=TOURCKJ; POSIT[SOLCIlJ:=I;

TOUR[Kl:=TOURCMJ; MI=M-l

K:=SOLCNJ; L:=SOLCOJ; OPT:=DISCK,LJ;

FOR It=1 STEP 1 UNTIL N DO

BEGIN K:=Lf L:=SOlCIJ; OPT:=OPT+DISCK,LJ END

END STARTINGTOUR;

PROCEDURE REDUCTTOUR(X,POSIT,SOL,OPT);

INTEGER X; REAL OPT; INTEGER ARRAY POSIT,SOLCO]; .

BEGIN INTEGER I,J,K,L,M,CITY;

INTEGER ARRAY LINKSCO:NJ;

K:=-l;

FOR 1:=0 STEP

1

UNTIL N DO

IF POSTCll = -1 THEN BEGIN K:=K+l; LINKSCKJ:=I END;

M:=K; J:=O;

FOR 1:=0 STEP

1

UNTIL K DO

BEGIN L:=ENTIER(RANDOM(X)*M);

END;

CITY:=LINKSCLJ; SOLCJJ:=CITY; POSITCCITYJ:=J; J:=J+l;

LINKSCLJt=LINKSCMJ; M:=M-l;

WHILE PRE[CITY] NEG -1 DO

BEGIN CITY:=PRECCITYJ; SOL[Jl:=CITY;

POSIT[CITYJt=J; JI=J+1

END;

K:=SOLCNJ; L:=SOLCO]; OPT:=DISCK,LJ,

FOR 1:=1 STEP 1 UNTIL N DO

BEGIN K:=L; L:=SOLCI1; OPT:=OPT+DIS[K,LJ END;

END REDUCTTOUR;

(11)

9

-PROCEDURE CLOSEUP(GG,G,DIS,POS,NOD);

%

CLOSINGUP CHECKS WHETHER CLOSING UP RESULTS IN A BETTER TOUR

%

REAL GG,G,DIS; INTEGER ARRAY POS,NODCOJ;

:L64000

165000

166000

1~7000

168000

169000

170000

171000

:l72()00

173000

174000

%

175000

176000

17"7000

178000

179000

180000

181000

1~00'

1_00

184000

185000

186000

187000

198000

189000

190000

191000

192000

193000

194000

195000

196000

197000

198000

199000

200000

2WOO

2.00

203000

204000

205000

206000

207000

208000

209000

210000

211000

212000

213000

214000

215000

216000

2i7000

218000

219000

220000

BEGIN IF GG-DIS

>

G THEN

BEGIN G:=GG·-DIS;

WRITE(POSITl,*,POS); WRITECSOLl,*,NOD)

END

END CLOSEUP;

PROCEDURE TOURIMPROVEMENT(T1,T2I,G,GG,POS,NOD);

TOUR IMPROVEMENT TAKES CARE OF THE ITERATIONPROCESS ON LEVELS ) 3 FOR X

%

AND ON LEVELS ) 2 FOR Y

%

INTEGER T1,T2I; REAL G,GG; INTEGER ARRAY POS,NODCOJ;

BEGIN INTEGER I,C,D,R,S,PTC,PTD,NUMCAND,CANDIDATE;

REAL MAXGG;

CANDIDATE:::::1;

WHILE CANDIDATE

>

0 AND GG

>

G DO

BEGIN NUMCAND:=O; MAXGG:=-@50; CANDIDATE:=I:=-1;

WHILE I

<

N-l AND NUMCAND

<

5 DO

BEGIN

I:::::I+l~

D:=NBCT2I,IJ;

IF DISCT2I,DJ

<

GG-G

THEN BEGIN R:=ABS(POSITCT2IJ-POSITCDJ);

S:=ABS(POSCT2IJ-POSCDJ);

IF D NEG Tl THEN

%

R=l OR R= IMPLIES B-D IS A LINK OF THE TOUR IN SOL,

X THEREFORE B-D MAY NOT BE AN Y-LINK

IF R NEG 1 AND R NEG N THEN

%

S=1 OR S=N IMPLIES B-D IS A Y-LINK

%

IF S NEG lAND S NEG N THEN

BEGIN PTD:=POSCDJ; PTC:=(PTD+W) MOD M; C:=NODCPTCJ;

R:=ABS(POSITCCJ-POSITCDJ);

%

R=1 OR R=N IMPLIES CD IS A LINK IN SOL AND THEREFORE C-D MAY BE BROKEN

IF R = 1 OR R = N THEN

\ END

END;

END

END

ELSE I:=N

BEGIN NUMCAND:=NUHCAND+1;

END

IF NOT REDUCTION OR

(PREEDJ NEG C AND POSTCDJ NEG C) THEN

IF DISCD,C]-DISCD,T2IJ ) HAXGG THEN

BEGIN MAXGG:=DISCD,C]-DISCD,T2IJ;

CANDIDATE:=D

END

IF

CANDIDATE GEG 0 THEN

BEGIN D:=CANDIDATE; PTD:=POSEDJ;

PTC:=(PTD+W) MOD M; C:=NODEPTC];

GG:=GG+MAXGG;

END

IF GG :::- G THEN

BEGIN REVERSECPOS,NOD,PT2,PTC,V);

CLOSEUP(GG,G,DISCT1,CJ,POS,NOD);

END;

T2I:=C

END TOURIMPROVEMENT;

(12)

IF REDUCTION THEN REDUCTTOUR(X,POSIT,SOL,OPT)

ELSE STARTINGTOUR(X,POSIT,SOL,OPT);

SORTSEQ(N,SEQ);

NILL:=NUM:=PT1:=-1; M:=N+l;

WHILE NUM

<

N DO

BEGIN NUM:=NUM+l;

Tll=SEQCNUM); PT1:=POSITCTIJ;

222000

223000

224000

22S000

226000

227000

228000

229000

230000

231000

232000

233000

234000

235000

236000

237000

X V

==

1 CORRESPONDS TO AN ORIENTATION TO THE RIGHT X

X V :::: N CORRESPONDS TO AN ORIENTATION TO THE LEFT X

FOR V:=l,N DO

21

2 000

000

240000

241000

242000

243000

244000

245000

246000

247000

248000

249000

250000

251000

252000

253000

254000

25S000

256000 X

21000

2 000

259000

260000

261000

262000

263000

264000

265000

266000

267000

268000

BEGIN IT2:=NT3:=0; W:=M-V;

PT2:=(PT1+V) MOD M; T2:=SOL[PT2J;

DO BEGIN G:=O; GG:=DIS[Tl,T2];

T3:=FINDLINKS(IT2,POSIT,Tl,T2,GG,N3,NT3,SOL);

IF T3 NEQ NILL THEN

BEGIN PT4:=(POSITCT3J+W) MOD M; T4:=SOL[PT4J;

WRITECPOS1,*,POSIT); WRITECNOD1,*,SOL);

GGI=GG-DIS[T2,T3J+DIS[T3,T4J.

REVERSE(POS1,NOD1,PT2,PT4,V);

CLOSEUP(GG,G,DISCT1,T4J,POS1,NOD1);

IT4:=NTS:=0;

DO BEGIN TS:=FINDLINKSCIT4,POS1,Tl,T4,GG,N5,NTS,NOD1);

IF TS NEG NILL THEN

BEGIN PT6:=(POSICTSJ+W) MOD MI T6:=NODICPT6J;

HU:=GG-DIS[T4,T5J+DISCTS,T6];

END

END

IF HU GEG G THEN

BEGIN WRITE(POS2,*,POS1); WRITE(NOD2,*,NOD1);

REVERSE(POS2,NOD2,PT2,PT6,V);

CLOSEUP(HU,G,DISCT6,TIJ,POS2,NOD2);

TOURIMPROVEMENTCT1,T6,G,HU,POS2,NOD2);

END

UNTIL T5 = NILL OR G

>

0;

THE ALTERNATE CHOICE FOR T4

%

IF G

=

0 THEN

BEGIN PT31=POSITCT3J; PT4:=(PT3+V) MOD M; T4:=SOL[PT4J;

IT4:=NTS:=0;

DO BEGIN GG:=DISCT1,T2]-DIS[T2,T3J+DIS[T3,T4J;

TS:=FINDLINKS(IT4,POSIT,Tl,T4,GG,NS,NTS,SOL);

IF TS NEQ NILL THEN

BEGIN PTS:=POSIT[TS];

IF Tl ::: T4 THEN BOOL:= V=N ELSE

IF (PT4

<

PTI AND PTS ) PT4 AND PTS LEG PTt)

THEN BOOL:=TRUE

ELSE IF (PT4

>

PTt AND (PT5

>

PT4 OR PT5 LEG PT!»

THEN BOOL:=TRUE ELSE BOOL:=FALSE;

(13)

·

269000

270000

271000

272000

273000

274000

275000

276000

277000

278000

279000

280000

281000

282000

283000

284000

285000

21000

2 000

28S000

289000

290000

291000

2'2000

293000

294000

295000

296000

297000

298000

299000

300000

301000

302000

303000

304000

3_00

3.000

307000

30S000

309000

310000

311000

312000

313000

314000

- 11

-IF BOOl EGV V = 1

THEN BEGIN PT6:=(PT5+W) HOD H' T6t=SOL(PT6];

X T5 lIES BETWEEN Tl AND T4, DETERHINATION OF T7

GGt=GG-DIS(T4,T5J+DISCT5,T6J'

IT6:=T7:=O' FOUND:=FALSE;

WHILE NOT FOUND AND T7 NEG NILL DO

BEGIN T7t=FINDlINK(N,IT6,NBCT6,*1,DISCT6,*1,

POSIT,POSIT,T1,T6,GG);

IF T7 NEG NILL THEN

BEGIN PT7l=POSITCT7];

IF (PT2

<

PT3 AND PT7 GEG PT2 AND PT7 lEG PT3)

THEN BOOLl=TRUE

ELSE

IF (PT2:>PT3 AND (PT7 GEG PT2 OR PT7 LEG PT3»

THEN BOOL:=TRUE ELSE BOOll=FALSE;

FOUND:= BOOL EGV V = 1

END

END;

IF FOUND THEN

BEGIN Il:=SOL(PT7+V) HOD Hl;I2:=SOL[(PT7+W) HOD Hl;

XDETERHINATIONOF T8 X

END

END

IF DIS(T7,11]-DIS[T1,I11 :> DISCT7,I21-DISCT1,I21

THEN TSt=Il ELSE TS:=I2;

IF TS = Tl OR TS = T2 OR TS = T4 THEN

TSt= IF TS = 11 THEN 12 ELSE 11;

GG:=GG-DIS[T6,T7J+D1S[T7,TS1'

IF

GG

:>

0 THEN

BEGIN WRITE(POS1,*,POSIT); WRITE(NOD1,*,SOL);

IF TS

=

11

END

THEN BEGIN PTSt=(PT7+V) HOD "H;

REVERSE(POS1,NOD1,PT4,PT6,V);

REVERSE(POS1,NOD1,PT2,PT7,V),

REVERSE(POS1,NOD1,PTS,PT3,V),

REVERSE(POS1,NOD1,PT2,PT3,V);

END

ELSE BEGIN PTS:=(PT7+W) HOD H'

REVERSE(POS1,NOD1,PT2,PTS,V),

REVERSE(POS1,NOD1,PT7,PT3,V);

REVERSE(POS1,NOD1,PT4,PT6,V);

END;

CLOSEUP(GG,G,DIS(TS,T11,POS1,NOD1);

TOURIHPROVEHENT(Tl,TS,G,GG,POS1,NOD1),

(14)

375000 :376000 377000 378000 379000 380000 381000 382000 383000 384000 3850"00 386000 387000 388000 389000 390000 36>00 3~OOO 393000 394000 395000 3Y6000 397000 398000 399000 400000

M:=N+1;

FOR

1:=0

STEP 1 UNTIL N DO SORTDISTANCES(N,DISCI,*J,NBCI,*J);

OlDSOl:=REDUCTION:=FAlSE;

FOR TOURS:=1 STEP 1 UNTIL NUMTOURS DO

BEGIN KERNIGHANlIN(X,OPT,POSIT,SOl);

,./"IF NOT OlDSOl THEN

BEGIN NUMSOl:=NUMSOl+l; OPTIMUMCNUMSOlJ:=OPT;

IF NUMSOL

>

2

THEN REDUCTION:=TRUE;

WRITE(SOlUTIONSCNUMSOl,*J,*,SOL);

END

END;

IF NUMSOl = 1

THEN BEGIN K:=SOlCO]; L:=SOlCNJ;

PRECKJ:=L; POSTCLJ:=K;

FOR

1:=1

STEP 1 UNTIL N DO

BEGIN l:=SOLCIJ; PRE[LJt=K; POSTCKJ:=L; K:=L END

END

ELSE FOR 1:=1 STEP 1 UNTIL NUMSOl-l DO

FOR R:=O STEP

1

UNTIL N DO

BEGIN K:=POSITCR];

END;

J:=(K+N) MOD M; L:=(K+l) MOD M;

J:=SOL[JJ; K:=SOLCKJ; L:=SOLCLJ;

IF PRECKJ NEG J AND PRE[KJ NEG L THEN PRECKJ:=-l;

IF POSTCKJ NEG

J

AND POST[Kl NEG l THEN POST[Kl:=-l

Referenties

GERELATEERDE DOCUMENTEN

Sickness absence data of 242 employees were analyzed with respect to spells of sick- ness (frequency, incidence rate), days (length, dura- tion) and time between intervention and

After the order confirmation, a project manager must fill in a job preparation form (JPF) containing the customer information, the kind of services and tests, sample

The day-route is split up, such that all customers have two probabilities, where the first probability is used if the length up to that customer is lower than the given

The number of fines and settlements for speeding offences detected by average speed measuring systems have decreased by 59% between 2007 and 2010.. It turns out that 35% of

Finally, Chapter 8 highlights numerical results of multirate time-integration and nonlin- ear model order reduction for several circuit models.. Because the BDF Compound-Fast

We consider combined inventory control and throughput time reduction in multi-echelon, multi- indenture spare part networks for system upkeep of capital goods.. We

Copyright and moral rights for the publications made accessible in the public portal are retained by the authors and/or other copyright owners and it is a condition of

The questions we seek to answer include; if the model is fitted to the data available, can we estimate the number of drug users in a given community based on the fit (which will be