Skip to content

Instantly share code, notes, and snippets.

View dlennox24's full-sized avatar

Daniel Lennox dlennox24

  • Xentity Corp
  • Thornton, Colorado
View GitHub Profile
@dlennox24
dlennox24 / 3-opt.txt
Last active April 3, 2017 00:09
3-opt sudo
do{
minChange = 0;
for(i=0;i<nodes-3;i++){
for(j=i+2;j<nodes-1;j++){
for(k=j+1;k<nodes-2;k++){
base = calcDist(i,i+1) + calcDist(j,j+1) + calcDist(k,k+1);
// 2-opt
opt2_0 = calcDist(i,i+1) + calcDist(j,k) + calcDist(j+1,k+1);
opt2_1 = calcDist(j,j+1) + calcDist(k,i) + calcDist(k+1,i+1);
opt2_2 = calcDist(k,k+1) + calcDist(i,j) + calcDist(i+1,j+1);