public final class Ruler extends java.lang.Object implements Solution<io.vavr.collection.Array<java.lang.Integer>>
Modifier and Type | Field and Description |
---|---|
static boolean |
DIRECT_REPRESENTATION_FORMAT |
private int[] |
directRepresentation |
private double |
fitness |
private int[] |
indirectRepresentation |
private static long |
serialVersionUID |
Constructor and Description |
---|
Ruler(int[] marks) |
Ruler(int[] marks,
boolean isDirectRepresentation) |
Ruler(java.util.List<java.lang.Integer> marks,
boolean isDirectRepresentation) |
Modifier and Type | Method and Description |
---|---|
int[] |
directRepresentation() |
double |
fitnessValue()
Returns the fitness of this solution.
|
int[] |
indirectRepresentation() |
int |
length()
This method returns Golumb Ruler length.
|
int |
marksCount()
This method returns marks count on the direct representation of a ruler.
|
java.lang.String |
toString() |
private java.lang.String |
toString(int[] array) |
io.vavr.collection.Array<java.lang.Integer> |
unwrap()
Returns the real value of this solution.
|
Ruler |
withFitness(double fitnessValue)
Updates the fitness of this solution.
|
public static final boolean DIRECT_REPRESENTATION_FORMAT
private static final long serialVersionUID
private final int[] directRepresentation
private final int[] indirectRepresentation
private double fitness
public Ruler(java.util.List<java.lang.Integer> marks, boolean isDirectRepresentation)
public Ruler(int[] marks)
public Ruler(int[] marks, boolean isDirectRepresentation)
public int[] directRepresentation()
public int[] indirectRepresentation()
public int length()
This method returns Golumb Ruler length. One should bear in mind, that this value has nothing to do with marks count on the ruler. If you want to obtain marks count value, use marksCount()
method instead.
public int marksCount()
This method returns marks count on the direct representation of a ruler.
public double fitnessValue()
Solution
Returns the fitness of this solution. If the fitness was not computed, the returned value will be Double#NaN
.
fitnessValue
in interface Solution<io.vavr.collection.Array<java.lang.Integer>>
public Ruler withFitness(double fitnessValue)
Solution
Updates the fitness of this solution.
This function returns a new instance.
withFitness
in interface Solution<io.vavr.collection.Array<java.lang.Integer>>
fitnessValue
- new fitness valuepublic java.lang.String toString()
toString
in class java.lang.Object
private java.lang.String toString(int[] array)