201 |
|
} |
202 |
|
|
203 |
|
/** |
204 |
< |
* Perform one run with the given parameters. Each run complete |
204 |
> |
* Performs one run with the given parameters. Each run completes |
205 |
|
* when there are fewer than 2 active threads. When there is |
206 |
|
* only one remaining thread, it will have no one to exchange |
207 |
|
* with, so it is terminated (via interrupt). |
416 |
|
} |
417 |
|
|
418 |
|
/** |
419 |
< |
* Choose a breeder, exchange strand with another subpop, and |
420 |
< |
* cross them to create new chromosome to replace a chosen |
419 |
> |
* Chooses a breeder, exchanges strand with another subpop, and |
420 |
> |
* crosses them to create new chromosome to replace a chosen |
421 |
|
* dyer. |
422 |
|
*/ |
423 |
|
void update() throws InterruptedException { |
432 |
|
} |
433 |
|
|
434 |
|
/** |
435 |
< |
* Choose a breeder, with exponentially decreasing probability |
435 |
> |
* Chooses a breeder, with exponentially decreasing probability |
436 |
|
* starting at best. |
437 |
|
* @return index of selected breeder |
438 |
|
*/ |
447 |
|
} |
448 |
|
|
449 |
|
/** |
450 |
< |
* Choose a chromosome that will be replaced, with |
450 |
> |
* Chooses a chromosome that will be replaced, with |
451 |
|
* exponentially decreasing probability starting at |
452 |
< |
* worst, ignoring the excluded index |
452 |
> |
* worst, ignoring the excluded index. |
453 |
|
* @param exclude index to ignore; use -1 to not exclude any |
454 |
|
* @return index of selected dyer |
455 |
|
*/ |
484 |
|
} |
485 |
|
|
486 |
|
/** |
487 |
< |
* Copy current strand to start of c's, and then append all |
487 |
> |
* Copies current strand to start of c's, and then appends all |
488 |
|
* remaining b's that aren't in the strand. |
489 |
|
* @param breeder the breeder |
490 |
|
* @param child the child |
522 |
|
} |
523 |
|
|
524 |
|
/** |
525 |
< |
* Fix the sort order of a changed Chromosome c at position k |
525 |
> |
* Fixes the sort order of a changed Chromosome c at position k. |
526 |
|
* @param c the chromosome |
527 |
|
* @param k the index |
528 |
|
*/ |
561 |
|
int fitness; |
562 |
|
|
563 |
|
/** |
564 |
< |
* Initialize to random tour |
564 |
> |
* Initializes to random tour. |
565 |
|
*/ |
566 |
|
Chromosome(int length, RNG random) { |
567 |
|
alleles = new int[length]; |
596 |
|
} |
597 |
|
|
598 |
|
/** |
599 |
< |
* Return tour length for points scaled in [0, 1). |
599 |
> |
* Returns tour length for points scaled in [0, 1). |
600 |
|
*/ |
601 |
|
double unitTourLength() { |
602 |
|
int[] a = alleles; |
612 |
|
} |
613 |
|
|
614 |
|
/** |
615 |
< |
* Check that this tour visits each city |
615 |
> |
* Checks that this tour visits each city. |
616 |
|
*/ |
617 |
|
void validate() { |
618 |
|
int len = alleles.length; |