--- jsr166/src/test/loops/TSPExchangerTest.java 2011/03/15 19:47:06 1.12
+++ jsr166/src/test/loops/TSPExchangerTest.java 2015/09/13 16:28:14 1.19
@@ -18,13 +18,13 @@ import java.util.concurrent.locks.*;
* A set of worker threads perform updates on subpops. The basic
* update step is:
*
- * - Select a breeder b from the subpop
- *
- Create a strand of its tour with a random starting point and length
- *
- Offer the strand to the exchanger, receiving a strand from
- * another subpop
- *
- Combine b and the received strand using crossing function to
- * create new chromosome c.
- *
- Replace a chromosome in the subpop with c.
+ *
- Select a breeder b from the subpop
+ *
- Create a strand of its tour with a random starting point and length
+ *
- Offer the strand to the exchanger, receiving a strand from
+ * another subpop
+ *
- Combine b and the received strand using crossing function to
+ * create new chromosome c.
+ *
- Replace a chromosome in the subpop with c.
*
*
* This continues for a given number of generations per subpop.
@@ -39,7 +39,7 @@ public class TSPExchangerTest {
static final int NCPUS = Runtime.getRuntime().availableProcessors();
/** Runs start with two threads, increasing by two through max */
- static final int DEFAULT_MAX_THREADS = Math.max(4, NCPUS + NCPUS/2);
+ static final int DEFAULT_MAX_THREADS = Math.max(4, NCPUS + NCPUS/2);
/** The number of replication runs per thread value */
static final int DEFAULT_REPLICATIONS = 3;
@@ -201,7 +201,7 @@ public class TSPExchangerTest {
}
/**
- * Perform one run with the given parameters. Each run complete
+ * Performs one run with the given parameters. Each run completes
* when there are fewer than 2 active threads. When there is
* only one remaining thread, it will have no one to exchange
* with, so it is terminated (via interrupt).
@@ -229,7 +229,6 @@ public class TSPExchangerTest {
p.printSnapshot(secs);
}
-
/**
* A Population creates the subpops, subpops, and threads for a run
* and has control methods to start, stop, and report progress.
@@ -362,7 +361,7 @@ public class TSPExchangerTest {
}
/**
- * A Subpop maintains a set of chromosomes..
+ * A Subpop maintains a set of chromosomes.
*/
static final class Subpop {
/** The chromosomes, kept in sorted order */
@@ -406,7 +405,7 @@ public class TSPExchangerTest {
* other. It is hardwired because small variations of it
* don't matter much.
*
- * @param g the first generation to run.
+ * @param g the first generation to run
*/
int runUpdates() throws InterruptedException {
int n = 1 + (rng.next() & ((subpopSize << 1) - 1));
@@ -416,8 +415,8 @@ public class TSPExchangerTest {
}
/**
- * Choose a breeder, exchange strand with another subpop, and
- * cross them to create new chromosome to replace a chosen
+ * Chooses a breeder, exchanges strand with another subpop, and
+ * crosses them to create new chromosome to replace a chosen
* dyer.
*/
void update() throws InterruptedException {
@@ -432,7 +431,7 @@ public class TSPExchangerTest {
}
/**
- * Choose a breeder, with exponentially decreasing probability
+ * Chooses a breeder, with exponentially decreasing probability
* starting at best.
* @return index of selected breeder
*/
@@ -447,9 +446,9 @@ public class TSPExchangerTest {
}
/**
- * Choose a chromosome that will be replaced, with
+ * Chooses a chromosome that will be replaced, with
* exponentially decreasing probability starting at
- * worst, ignoring the excluded index
+ * worst, ignoring the excluded index.
* @param exclude index to ignore; use -1 to not exclude any
* @return index of selected dyer
*/
@@ -484,7 +483,7 @@ public class TSPExchangerTest {
}
/**
- * Copy current strand to start of c's, and then append all
+ * Copies current strand to start of c's, and then appends all
* remaining b's that aren't in the strand.
* @param breeder the breeder
* @param child the child
@@ -522,7 +521,7 @@ public class TSPExchangerTest {
}
/**
- * Fix the sort order of a changed Chromosome c at position k
+ * Fixes the sort order of a changed Chromosome c at position k.
* @param c the chromosome
* @param k the index
*/
@@ -561,7 +560,7 @@ public class TSPExchangerTest {
int fitness;
/**
- * Initialize to random tour
+ * Initializes to random tour.
*/
Chromosome(int length, RNG random) {
alleles = new int[length];
@@ -596,7 +595,7 @@ public class TSPExchangerTest {
}
/**
- * Return tour length for points scaled in [0, 1).
+ * Returns tour length for points scaled in [0, 1).
*/
double unitTourLength() {
int[] a = alleles;
@@ -612,7 +611,7 @@ public class TSPExchangerTest {
}
/**
- * Check that this tour visits each city
+ * Checks that this tour visits each city.
*/
void validate() {
int len = alleles.length;
@@ -705,7 +704,7 @@ public class TSPExchangerTest {
int seed;
RNG(int seed) { this.seed = seed; }
- RNG() { this.seed = seedGenerator.nextInt() | 1; }
+ RNG() { this.seed = seedGenerator.nextInt() | 1; }
int next() {
int x = seed;