myswapmove.java
来自「TabuSearch的一个小程序。用禁忌搜索解决TSP问题」· Java 代码 · 共 43 行
JAVA
43 行
import org.coinor.opents.*;public class MySwapMove implements Move { public int customer; public int movement; public MySwapMove( int customer, int movement ) { this.customer = customer; this.movement = movement; } // end constructor public void operateOn( Solution soln ) { int[] tour = ((MySolution)soln).tour; int pos1 = -1; int pos2 = -1; // Find positions for( int i = 0; i < tour.length && pos1 < 0; i++ ) if( tour[i] == customer ) pos1 = i; pos2 = pos1 + movement; // Swap int cust2 = tour[pos2]; tour[pos1] = cust2; tour[pos2] = customer; } // end operateOn /** Identify a move for SimpleTabuList */ public int hashCode() { return customer; } // end hashCode } // end class MySwapMove
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?