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.
Modifier and Type | Method and Description |
---|---|
int |
compareTo(DoubleGene other) |
boolean |
equals(Object obj) |
A |
getAllele()
Return the allele of this gene.
|
A |
getMax()
Return the allowed max value.
|
A |
getMin()
Return the allowed min value.
|
int |
hashCode() |
boolean |
isValid()
Check if this object is valid.
|
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(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 . |
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
byteValue, doubleValue, floatValue, intValue, longValue, shortValue
getMax, getMin, isValid
public int compareTo(DoubleGene other)
compareTo
in interface Comparable<DoubleGene>
compareTo
in interface BoundedGene<Double,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
AbstractBoundedGene.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
AbstractBoundedGene.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
.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 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 A getAllele()
Gene
getAllele
in interface Gene<A extends Comparable<? super A>,G extends org.jenetics.AbstractBoundedGene<A,G>>
public A getMin()
BoundedGene
getMin
in interface BoundedGene<A extends Comparable<? super A>,G extends org.jenetics.AbstractBoundedGene<A,G>>
public A getMax()
BoundedGene
getMax
in interface BoundedGene<A extends Comparable<? super A>,G extends org.jenetics.AbstractBoundedGene<A,G>>
public boolean isValid()
Verifiable
isValid
in interface BoundedGene<A extends Comparable<? super A>,G extends org.jenetics.AbstractBoundedGene<A,G>>
isValid
in interface Verifiable
© 2007-2016 Franz Wilhelmstötter (2016-12-26 11:02)