cityinfo.java

来自「新型模拟退火算法解决TSP优化问题。自能退火。可用于大多数情况下的优化问题。」· Java 代码 · 共 59 行

JAVA
59
字号
package test;import java.io.*;import java.util.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2005</p> * <p>Company: </p> * @author not attributable * @version 1.0 */public class CityInfo {//    int cityCount = 24978;    int cityCount = 100;//    int cityCount = 724;    double[] xcoords;    double[] ycoords;        public CityInfo() {    }    public void readCoords() {        xcoords = new double[cityCount];        ycoords = new double[cityCount];        try {            BufferedReader br = new BufferedReader(new InputStreamReader(new                FileInputStream(cityCount+".txt")));            for (int i = 0; i < cityCount; i++) {                String line = br.readLine();                if (line == null) {                    break;                }                StringTokenizer st = new StringTokenizer(line, " ");                String index =  st.nextToken();                xcoords[i] = Double.parseDouble(st.nextToken());                ycoords[i] = Double.parseDouble(st.nextToken());//		System.out.println("read coord " + index + " " + xcoords[i] + " " + ycoords[i]);            }            br.close();        }        catch (Exception ex) {            ex.printStackTrace();        }    }        }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?