资源简介

遗传算法 tsp java遗传算法 tsp java遗传算法 tsp java遗传算法 tsp java

资源截图

代码片段和文件信息

package test;

import java.io.*;
import java.util.*;

/**
 * 

title: 


 * 

Description: 


 * 

Copyright: Copyright (c) 2005


 * 

Company: 


 * @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();
        }

    }
    

    

}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       1308  2006-02-21 07:46  遗传\CityInfo.java

     文件       2920  2006-03-24 11:19  遗传\GA.java

     文件        315  2006-03-24 11:19  遗传\GAInterface.java

     文件        215  2006-02-21 07:37  遗传\SA.java

     文件       1495  2006-02-23 02:19  遗传\SAImpl.java

     文件        304  2006-02-23 02:14  遗传\SAInterface.java

     文件       4571  2005-07-27 17:22  遗传\TSP.java

     文件       4896  2007-11-25 16:55  遗传\TSP1.java

     文件       4019  2006-02-23 02:31  遗传\TSPSolutionWithSA.java

    ..AD...         0  2008-04-02 20:02  遗传

----------- ---------  ---------- -----  ----

                20043                    10


评论

共有 条评论