<s>
In	O
optimization	O
,	O
2-opt	B-Algorithm
is	O
a	O
simple	O
local	B-Algorithm
search	I-Algorithm
algorithm	I-Algorithm
for	O
solving	O
the	O
traveling	B-Algorithm
salesman	I-Algorithm
problem	I-Algorithm
.	O
</s>
<s>
The	O
2-opt	B-Algorithm
algorithm	O
was	O
first	O
proposed	O
by	O
Croes	O
in	O
1958	O
,	O
although	O
the	O
basic	O
move	O
had	O
already	O
been	O
suggested	O
by	O
Flood	O
.	O
</s>
<s>
A	O
complete	O
2-opt	B-Algorithm
local	B-Algorithm
search	I-Algorithm
will	O
compare	O
every	O
possible	O
valid	O
combination	O
of	O
the	O
swapping	O
mechanism	O
.	O
</s>
<s>
This	O
technique	O
can	O
be	O
applied	O
to	O
the	O
traveling	B-Algorithm
salesman	I-Algorithm
problem	I-Algorithm
as	O
well	O
as	O
many	O
related	O
problems	O
.	O
</s>
<s>
These	O
include	O
the	O
vehicle	B-Algorithm
routing	I-Algorithm
problem	I-Algorithm
(	O
VRP	O
)	O
as	O
well	O
as	O
the	O
capacitated	O
VRP	O
,	O
which	O
require	O
minor	O
modification	O
of	O
the	O
algorithm	O
.	O
</s>
<s>
In	O
pseudocode	O
,	O
the	O
mechanism	O
by	O
which	O
the	O
2-opt	B-Algorithm
swap	O
manipulates	O
a	O
given	O
route	O
is	O
as	O
follows	O
.	O
</s>
<s>
This	O
is	O
the	O
complete	O
2-opt	B-Algorithm
swap	O
making	O
use	O
of	O
the	O
above	O
mechanism	O
:	O
</s>
<s>
Since	O
a	O
2-opt	B-Algorithm
operation	O
involves	O
removing	O
2	O
edges	O
and	O
adding	O
2	O
different	O
edges	O
we	O
can	O
subtract	O
and	O
add	O
the	O
distances	O
of	O
only	O
those	O
edges	O
.	O
</s>
<s>
Once	O
it	O
is	O
known	O
that	O
lengthDelta	O
is	O
negative	O
,	O
then	O
we	O
perform	O
a	O
2-opt	B-Algorithm
swap	O
.	O
</s>
