ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/loops/TSPExchangerTest.java
(Generate patch)

Comparing jsr166/src/test/loops/TSPExchangerTest.java (file contents):
Revision 1.9 by jsr166, Mon Nov 2 23:51:32 2009 UTC vs.
Revision 1.10 by jsr166, Tue Nov 3 01:04:02 2009 UTC

# Line 225 | Line 225 | public class TSPExchangerTest {
225          //        Thread.sleep(100);
226  
227          long elapsed = stopTime - startTime;
228 <        double secs = (double)elapsed / 1000000000.0;
228 >        double secs = (double) elapsed / 1000000000.0;
229          p.printSnapshot(secs);
230      }
231  
# Line 300 | Line 300 | public class TSPExchangerTest {
300           */
301          void printSnapshot(double secs) {
302              int xs = totalExchanges();
303 <            long rate = (xs == 0) ? 0L : (long)((secs * 1000000000.0) / xs);
303 >            long rate = (xs == 0) ? 0L : (long) ((secs * 1000000000.0) / xs);
304              Chromosome bestc = subpops[0].chromosomes[0];
305              Chromosome worstc = bestc;
306              for (int k = 0; k < subpops.length; ++k) {
# Line 592 | Line 592 | public class TSPExchangerTest {
592                  f += cities.distanceBetween(p, n);
593                  p = n;
594              }
595 <            fitness = (int)(f / len);
595 >            fitness = (int) (f / len);
596          }
597  
598          /**
# Line 661 | Line 661 | public class TSPExchangerTest {
661  
662              for (int i = 0; i < n; i++) {
663                  for (int j = 0; j < n; j++) {
664 <                    double dx = (double)xPts[i] - (double)xPts[j];
665 <                    double dy = (double)yPts[i] - (double)yPts[j];
664 >                    double dx = (double) xPts[i] - (double) xPts[j];
665 >                    double dy = (double) yPts[i] - (double) yPts[j];
666                      double dd = Math.hypot(dx, dy) / 2.0;
667                      long ld = Math.round(dd);
668                      distances[i][j] = (ld >= Integer.MAX_VALUE) ?
669 <                        Integer.MAX_VALUE : (int)ld;
669 >                        Integer.MAX_VALUE : (int) ld;
670                  }
671              }
672          }
# Line 679 | Line 679 | public class TSPExchangerTest {
679          }
680  
681          // Scale ints to doubles in [0,1)
682 <        static final double PSCALE = (double)0x80000000L;
682 >        static final double PSCALE = (double) 0x80000000L;
683  
684          /**
685           * Return distance for points scaled in [0,1). This simplifies
# Line 689 | Line 689 | public class TSPExchangerTest {
689           * http://www.densis.fee.unicamp.br/~moscato/TSPBIB_home.html
690           */
691          double unitDistanceBetween(int i, int j) {
692 <            double dx = ((double)xPts[i] - (double)xPts[j]) / PSCALE;
693 <            double dy = ((double)yPts[i] - (double)yPts[j]) / PSCALE;
692 >            double dx = ((double) xPts[i] - (double) xPts[j]) / PSCALE;
693 >            double dy = ((double) yPts[i] - (double) yPts[j]) / PSCALE;
694              return Math.hypot(dx, dy);
695          }
696  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines