public static void main(String args[]) { /* test graph below in adjacency matrix format with 4 'cities' */ Double[][] C = new Double[4][4]; C[0][0] = 0.0; C[0][1] = 10.0; C[0][2] = 15.0; C[0][3] = 20.0; C[1][0] = 5.0; C[1][1] = 0.0; C[1][2] = 9.0; C[1][3] = 10.0; C[2][0] = 6.0; C[2][1] = 13.0; C[2][2] = 0.0; C[2][3] = 12.0; C[3][0] = 8.0; C[3][1] = 8.0; C[3][2] = 9.0; C[3][3] = 0.0; /* declare a new object of class TSP*/ TSP optimum_tour = new TSP(); /* print out the optimum tour length for this graph (default starting point = 1) */ optimum_tour.optimum_tour_length(4, 4, 1, C); }
@Override public void actionPerformed(ActionEvent arg0) { // TODO Auto-generated method stub String expNum = JOptionPane.showInputDialog(this, "50"); String input = JOptionPane.showInputDialog(this, "10000"); nExpTimes = Integer.parseInt(expNum); nRunningTimes = Integer.parseInt(input); for (AlgorithmName n : AlgorithmName.values()) { if (tspParent.charger != null) tspParent.charger = null; tspParent.charger = new Charger(tspParent, tspParent.nodeGrouper, n.name); tspParent.charger.dCoverageData = new double[nExpTimes][nRunningTimes]; // tspParent.charger.dDueTimeData=new double[nExpTimes][nRunningTimes]; tspParent.charger.dTravelTimeData = new double[nRunningTimes]; tspParent.charger.dGroupCoverage = new double[nExpTimes][tspParent.charger.nNumGroup][nRunningTimes]; for (int i = 0; i < nExpTimes; i++) { energyConsumer = new EnergyConsumer(tspParent, false); // tspParent.charger.dCoverageData[i]=new double[nRunningTimes];////////Doing the memory // assignment for the record array // tspParent.charger.dDueTimeData[i]=new double[nRunningTimes]; for (int j = 0; j < nRunningTimes; j++) { energyConsumer.actionPerformed(arg0); tspParent.charger.dCoverageData[i][j] = tspParent.charger.dCoverage; // tspParent.charger.dDueTimeData[i][j]=energyConsumer.dDueTime; if (i < 1) { tspParent.charger.dTravelTimeData[j] = 100; } // compute_group_coverage(i,j); if (tspParent.charger.nTotalLife > nRunningTimes) break; if (null != tspParent.charger.nInsertIndex) { for (int k = 0; k < tspParent.charger.nInsertIndex.length; k++) { j++; tspParent.charger.dCoverageData[i][j] = tspParent.charger.dCoverage; // tspParent.charger.dDueTimeData[i][j]=energyConsumer.dDueTime; if (i < 1) { tspParent.charger.dTravelTimeData[j] = 100; } } } } refresh_node(); energyConsumer = null; // tspParent.charger.dVelocity+=18; } compute_statistics(n.name); } tspParent.gui.createCityMap(false); export_string(CoverageOutput); }