Skip to content

Commit d8df851

Browse files
committed
moved defaults from abstract base class to interfaces
#117
1 parent 033f2aa commit d8df851

22 files changed

+65
-118
lines changed

src/org/cicirello/permutations/distance/AbstractPermutationDistanceMeasurer.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,6 @@
3030
* @version 4.2.2021
3131
*
3232
*/
33-
abstract class AbstractPermutationDistanceMeasurer implements PermutationDistanceMeasurer, NormalizedPermutationDistanceMeasurer {
33+
abstract class AbstractPermutationDistanceMeasurer implements NormalizedPermutationDistanceMeasurer {
3434

35-
/**
36-
* {@inheritDoc}
37-
*
38-
* @throws IllegalArgumentException if p1.length() is not equal to p2.length().
39-
*/
40-
@Override
41-
public final double normalizedDistance(Permutation p1, Permutation p2) {
42-
int m = max(p1.length());
43-
if (m==0) return 0;
44-
return 1.0 * distance(p1,p2) / m;
45-
}
4635
}

src/org/cicirello/permutations/distance/AcyclicEdgeDistance.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@
4242
* S. Ronald, "Distance functions for order-based encodings," in Proc. IEEE CEC. IEEE Press, 1997, pp. 49–54.</p>
4343
*
4444
* @author <a href=https://www.cicirello.org/ target=_top>Vincent A. Cicirello</a>, <a href=https://www.cicirello.org/ target=_top>https://www.cicirello.org/</a>
45-
* @version 1.28.2021
45+
* @version 4.2.2021
4646
*/
47-
public final class AcyclicEdgeDistance extends AbstractPermutationDistanceMeasurer {
47+
public final class AcyclicEdgeDistance implements NormalizedPermutationDistanceMeasurer {
4848

4949
/**
5050
* Constructs the distance measurer as specified in the class documentation.

src/org/cicirello/permutations/distance/BlockInterchangeDistance.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@
4040
* <p>Runtime: O(n), where n is the permutation length.</p>
4141
*
4242
* @author <a href=https://www.cicirello.org/ target=_top>Vincent A. Cicirello</a>, <a href=https://www.cicirello.org/ target=_top>https://www.cicirello.org/</a>
43-
* @version 1.28.2021
43+
* @version 4.2.2021
4444
*/
45-
public class BlockInterchangeDistance extends AbstractPermutationDistanceMeasurer {
45+
public class BlockInterchangeDistance implements NormalizedPermutationDistanceMeasurer {
4646

4747
/**
4848
* Constructs the distance measurer as specified in the class documentation.

src/org/cicirello/permutations/distance/CyclicEdgeDistance.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@
4242
* S. Ronald, "Distance functions for order-based encodings," in Proc. IEEE CEC. IEEE Press, 1997, pp. 49–54.</p>
4343
*
4444
* @author <a href=https://www.cicirello.org/ target=_top>Vincent A. Cicirello</a>, <a href=https://www.cicirello.org/ target=_top>https://www.cicirello.org/</a>
45-
* @version 1.28.2021
45+
* @version 4.2.2021
4646
*/
47-
public final class CyclicEdgeDistance extends AbstractPermutationDistanceMeasurer {
47+
public final class CyclicEdgeDistance implements NormalizedPermutationDistanceMeasurer {
4848

4949
/**
5050
* Constructs the distance measurer as specified in the class documentation.

src/org/cicirello/permutations/distance/CyclicIndependentDistance.java

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
* the constructor.</p>
3333
*
3434
* @author <a href=https://www.cicirello.org/ target=_top>Vincent A. Cicirello</a>, <a href=https://www.cicirello.org/ target=_top>https://www.cicirello.org/</a>
35-
* @version 1.28.2021
35+
* @version 4.2.2021
3636
*
3737
*/
3838
public final class CyclicIndependentDistance implements PermutationDistanceMeasurer {
@@ -68,19 +68,4 @@ public int distance(Permutation p1, Permutation p2) {
6868
}
6969
return result;
7070
}
71-
72-
/**
73-
* Measures the distance between two permutations, with cyclic independence:
74-
* distance = min_{i in [0,N)} distance(p1,rotate(p2,i))
75-
*
76-
* @param p1 first permutation
77-
* @param p2 second permutation
78-
* @return distance between p1 and p2
79-
* @throws IllegalArgumentException if p1.length() is not equal to p2.length().
80-
*/
81-
@Override
82-
public final double distancef(Permutation p1, Permutation p2) {
83-
return distance(p1,p2);
84-
}
85-
8671
}

src/org/cicirello/permutations/distance/CyclicRTypeDistance.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@
4444
* IEEE Transactions on Evolutionary Computation, 20(3):434-446, June 2016.</p>
4545
*
4646
* @author <a href=https://www.cicirello.org/ target=_top>Vincent A. Cicirello</a>, <a href=https://www.cicirello.org/ target=_top>https://www.cicirello.org/</a>
47-
* @version 1.28.2021
47+
* @version 4.2.2021
4848
*/
49-
public final class CyclicRTypeDistance extends AbstractPermutationDistanceMeasurer {
49+
public final class CyclicRTypeDistance implements NormalizedPermutationDistanceMeasurer {
5050

5151
/**
5252
* Constructs the distance measurer as specified in the class documentation.

src/org/cicirello/permutations/distance/CyclicReversalIndependentDistance.java

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
* the constructor.</p>
3434
*
3535
* @author <a href=https://www.cicirello.org/ target=_top>Vincent A. Cicirello</a>, <a href=https://www.cicirello.org/ target=_top>https://www.cicirello.org/</a>
36-
* @version 1.28.2021
36+
* @version 4.2.2021
3737
*
3838
*/
3939
public final class CyclicReversalIndependentDistance implements PermutationDistanceMeasurer {
@@ -83,19 +83,4 @@ public int distance(Permutation p1, Permutation p2) {
8383
}
8484
return result;
8585
}
86-
87-
/**
88-
* Measures the distance between two permutations, with cyclic and reversal independence:
89-
* distance = min_{i in [0,N)} { distance(p1,rotate(p2,i)), distance(p1,rotate(reverse(p2),i)) }
90-
*
91-
* @param p1 first permutation
92-
* @param p2 second permutation
93-
* @return distance between p1 and p2
94-
* @throws IllegalArgumentException if p1.length() is not equal to p2.length().
95-
*/
96-
@Override
97-
public final double distancef(Permutation p1, Permutation p2) {
98-
return distance(p1,p2);
99-
}
100-
10186
}

src/org/cicirello/permutations/distance/DeviationDistance.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@
4242
* S. Ronald, "More distance functions for order-based encodings," in Proc. IEEE CEC. IEEE Press, 1998, pp. 558–563.</p>
4343
*
4444
* @author <a href=https://www.cicirello.org/ target=_top>Vincent A. Cicirello</a>, <a href=https://www.cicirello.org/ target=_top>https://www.cicirello.org/</a>
45-
* @version 1.28.2021
45+
* @version 4.2.2021
4646
*
4747
*/
48-
public final class DeviationDistance extends AbstractPermutationDistanceMeasurer {
48+
public final class DeviationDistance implements NormalizedPermutationDistanceMeasurer {
4949

5050
/**
5151
* Constructs the distance measurer as specified in the class documentation.

src/org/cicirello/permutations/distance/DeviationDistanceNormalized.java

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@
4848
* Proc. IEEE CEC. IEEE Press, 1998, pp. 558–563.</p>
4949
*
5050
* @author <a href=https://www.cicirello.org/ target=_top>Vincent A. Cicirello</a>, <a href=https://www.cicirello.org/ target=_top>https://www.cicirello.org/</a>
51-
* @version 1.28.2021
51+
* @version 4.2.2021
5252
*
5353
*/
54-
public final class DeviationDistanceNormalized implements PermutationDistanceMeasurerDouble, NormalizedPermutationDistanceMeasurerDouble {
54+
public final class DeviationDistanceNormalized implements NormalizedPermutationDistanceMeasurerDouble {
5555

5656
private DeviationDistance devDistance;
5757

@@ -81,17 +81,4 @@ public double maxf(int length) {
8181
if (length <= 1) return 0;
8282
return (length * length - (length & 1)) / (2.0 * (length-1));
8383
}
84-
85-
/**
86-
* {@inheritDoc}
87-
*
88-
* @throws IllegalArgumentException if p1.length() is not equal to p2.length().
89-
*/
90-
@Override
91-
public double normalizedDistance(Permutation p1, Permutation p2) {
92-
double m = maxf(p1.length());
93-
if (m == 0.0) return 0;
94-
return distancef(p1,p2) / m;
95-
}
96-
9784
}

src/org/cicirello/permutations/distance/DeviationDistanceNormalized2005.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@
6262
* management," in Proc. of MIC2005, 2005.</p>
6363
*
6464
* @author <a href=https://www.cicirello.org/ target=_top>Vincent A. Cicirello</a>, <a href=https://www.cicirello.org/ target=_top>https://www.cicirello.org/</a>
65-
* @version 1.28.2021
65+
* @version 4.2.2021
6666
*
6767
*/
68-
public final class DeviationDistanceNormalized2005 implements PermutationDistanceMeasurerDouble, NormalizedPermutationDistanceMeasurerDouble {
68+
public final class DeviationDistanceNormalized2005 implements NormalizedPermutationDistanceMeasurerDouble {
6969

7070
private DeviationDistance devDistance;
7171

0 commit comments

Comments
 (0)