文档介绍:实例 1 import ; import ; import ; import ; import ; public class SA{ private int cityNum; // 城市数量,编码长度 private int N;// 每个温度迭代步长 private int T;// 降温次数 private float a;// 降温系数 private float t0;// 初始温度 private int[][] distance; // 距离矩阵 private int bestT;// 最佳出现代数 private int[] Ghh;// 初始路径编码 private int GhhEvaluation; private int[] bestGh;// 最好的路径编码 private int bestEvaluation; private int[] tempGhh;// 存放临时编码 private int tempEvaluation; private Random random; public SA() {} /** * constructor of GA ** @ * 城市数量* ***@param t* 降温次数* ***@param n* 每个温度迭代步长* ***@param tt* 初始温度* ***@param aa * 降温系数* **/ public SA(, int n, int t, float tt, float aa) { cityNum = cn; N= n;T= t; t0= tt; a= aa; } // 给编译器一条指令,告诉它对被批注的代码元素内部的某些警告保持静默***@SuppressWarnings("resource") /** * 初始化 Tabu 算法类* ***@param filename 数据文件名,该文件存储所有城市节点坐标数据* ***@throws IOException */ private void init(String filename) throws IOException { // 读取数据 int[] x; int[] y; String strbuff; BufferedReader data = new BufferedReader(new InputStreamReader( new FileInputStream(filename))); distance = new int[cityNum][cityNum]; x= new int[cityNum]; y= new int[cityNum]; for (int i= 0;i< cityNum; i++) { // 读取一行数据,数据格式 1 6734 1453 strbuff = (); // 字符分割 String[] strcol = (" "); x[i] = (strcol[1]);// x 坐标 y[i] = (