public final class DoubleGene extends Object implements NumericGene<Double,DoubleGene>, Mean<DoubleGene>, Comparable<DoubleGene>, Serializable
This is a
value-based class; use of identity-sensitive operations (including
reference equality (==
), identity hash code, or synchronization) on
instances of DoubleGene
may have unpredictable results and should
be avoided.
DoubleChromosome
,
Serialized FormModifier and Type | Method and Description |
---|---|
byte |
byteValue()
Returns the value of the specified gene as an byte.
|
int |
compareTo(DoubleGene other) |
double |
doubleValue()
Returns the value of the specified gene as an double.
|
boolean |
equals(Object obj) |
float |
floatValue()
Returns the value of the specified gene as an float.
|
Double |
getAllele()
Return the allele of this gene.
|
Double |
getMax()
Return the allowed max value.
|
Double |
getMin()
Return the allowed min value.
|
int |
hashCode() |
int |
intValue()
Returns the value of the specified gene as an int.
|
boolean |
isValid()
Check if this object is valid.
|
long |
longValue()
Returns the value of the specified gene as an long.
|
DoubleGene |
mean(DoubleGene that)
Return the (usually arithmetic) mean value of
this and
that . |
DoubleGene |
newInstance()
Return a new, random gene with the same type and with the same constraints
than this gene.
|
DoubleGene |
newInstance(Double value)
Create a new gene from the given
value and the current bounds. |
DoubleGene |
newInstance(Number number)
Create a new gene from the given
value and the current bounds. |
static DoubleGene |
of(double min,
double max)
Create a new random
DoubleGene . |
static DoubleGene |
of(double value,
double min,
double max)
Create a new random
DoubleGene with the given value and the
given range. |
static DoubleGene |
of(double value,
DoubleRange range)
Create a new random
DoubleGene with the given value and the
given range. |
static DoubleGene |
of(DoubleRange range)
Create a new random
DoubleGene . |
short |
shortValue()
Returns the value of the specified gene as an short.
|
String |
toString() |
public Double getAllele()
Gene
getAllele
in interface Gene<Double,DoubleGene>
public Double getMin()
BoundedGene
getMin
in interface BoundedGene<Double,DoubleGene>
public Double getMax()
BoundedGene
getMax
in interface BoundedGene<Double,DoubleGene>
public byte byteValue()
NumericGene
byteValue
in interface NumericGene<Double,DoubleGene>
byte
.public short shortValue()
NumericGene
shortValue
in interface NumericGene<Double,DoubleGene>
short
.public int intValue()
NumericGene
intValue
in interface NumericGene<Double,DoubleGene>
int
.public long longValue()
NumericGene
longValue
in interface NumericGene<Double,DoubleGene>
long
.public float floatValue()
NumericGene
floatValue
in interface NumericGene<Double,DoubleGene>
float
.public double doubleValue()
NumericGene
doubleValue
in interface NumericGene<Double,DoubleGene>
double
.public boolean isValid()
Verifiable
isValid
in interface BoundedGene<Double,DoubleGene>
isValid
in interface Verifiable
public int compareTo(DoubleGene other)
compareTo
in interface BoundedGene<Double,DoubleGene>
compareTo
in interface Comparable<DoubleGene>
public DoubleGene mean(DoubleGene that)
Mean
this
and
that
. For NumericGene
s the mean is the
arithmetic mean.mean
in interface Mean<DoubleGene>
that
- the second value for calculating the mean.this
and that
.public DoubleGene newInstance(Double value)
BoundedGene
value
and the current bounds.newInstance
in interface BoundedGene<Double,DoubleGene>
newInstance
in interface Gene<Double,DoubleGene>
value
- the value of the new gene.public DoubleGene newInstance(Number number)
BoundedGene
value
and the current bounds.newInstance
in interface NumericGene<Double,DoubleGene>
number
- the value of the new gene.public DoubleGene newInstance()
Gene
gene.getClass() == gene.newInstance().getClass()
. Implementations
of this method has to use the Random
object which can
be fetched from the RandomRegistry
.newInstance
in interface Gene<Double,DoubleGene>
newInstance
in interface Factory<DoubleGene>
public static DoubleGene of(double value, double min, double max)
DoubleGene
with the given value and the
given range. If the value
isn't within the interval [min, max),
no exception is thrown. In this case the method
isValid()
returns false
.value
- the value of the gene.min
- the minimal valid value of this gene (inclusively).max
- the maximal valid value of this gene (exclusively).DoubleGene
with the given parameterpublic static DoubleGene of(double value, DoubleRange range)
DoubleGene
with the given value and the
given range. If the value
isn't within the interval [min, max),
no exception is thrown. In this case the method
isValid()
returns false
.value
- the value of the gene.range
- the double range to useDoubleGene
NullPointerException
- if the given range
is null
.public static DoubleGene of(double min, double max)
DoubleGene
. It is guaranteed that the value
of the DoubleGene
lies in the interval [min, max).min
- the minimal valid value of this gene (inclusively).max
- the maximal valid value of this gene (exclusively).DoubleGene
with the given parameterpublic static DoubleGene of(DoubleRange range)
DoubleGene
. It is guaranteed that the value
of the DoubleGene
lies in the interval [min, max).range
- the double range to useDoubleGene
with the given parameterNullPointerException
- if the given range
is null
.© 2007-2018 Franz Wilhelmstötter (2018-10-28 17:23)