public class Gene
extends java.lang.Object
This class represents a gene (i.e. a relation for a set of attribute values). The real values are stored in normalized form, and the nominal values are stored in a list form.
Constructor and Description |
---|
Gene(Attribute a,
int rel)
Parameterized constructor
|
Gene(Gene g)
Deep-copy constructor
|
Modifier and Type | Method and Description |
---|---|
void |
addNominalValues(java.util.ArrayList<java.lang.String> values)
add a set of nominal values, so their status are now active
|
Attribute |
getAttribute()
Gets the attribute associated to this gene
|
double |
getRealValue()
Retrieves the real value of this gene
|
void |
mutate()
Mutates this gene.
|
void |
removeNominalValues(java.util.ArrayList<java.lang.String> values)
removes a set of nominal values from the active list (if active)
|
boolean |
same(Gene g)
Test if two genes are the same, comparing all their values.
|
void |
setNominalValue(int index,
boolean activation)
sets the activation for a nominal value, represented by its index in the
nominal values list of the attribute
|
void |
setRealmaxBound(double _value)
Sets the maximum bound of this gene for the real values (for interval-based relations)
|
void |
setRealminBound(double _value)
Sets the minimum bound of this gene for the real values (for interval-based relations)
|
void |
setRealValue(double _value)
Sets the real value of this gene (for one value relations, i.e.
|
boolean |
test(double input)
Test a value from an instance (of the data set), to see if it is covered.
|
public Gene(Attribute a, int rel)
Parameterized constructor
a
- the attribute of this generel
- the type of relation for the values of this genepublic Gene(Gene g)
Deep-copy constructor
g
- the original genepublic void setRealValue(double _value)
Sets the real value of this gene (for one value relations, i.e. "greater than", "less or equal than", etc.)
_value
- the new real valuepublic void setRealminBound(double _value)
Sets the minimum bound of this gene for the real values (for interval-based relations)
_value
- the new minimum boundpublic void setRealmaxBound(double _value)
Sets the maximum bound of this gene for the real values (for interval-based relations)
_value
- the new maximum boundpublic double getRealValue()
Retrieves the real value of this gene
public void setNominalValue(int index, boolean activation)
sets the activation for a nominal value, represented by its index in the nominal values list of the attribute
index
- the index of the nominal valueactivation
- the new activation statuspublic void addNominalValues(java.util.ArrayList<java.lang.String> values)
add a set of nominal values, so their status are now active
values
- the arraylist with the nominal values to be addedpublic void removeNominalValues(java.util.ArrayList<java.lang.String> values)
removes a set of nominal values from the active list (if active)
values
- arraylist with the proper nominal valuespublic Attribute getAttribute()
Gets the attribute associated to this gene
public void mutate()
Mutates this gene. If nominal, swaps its activation status with 0.5 probability. If real valued, generates a random new value or new bounds.
public boolean same(Gene g)
Test if two genes are the same, comparing all their values.
g
- the reference gene to be compared withpublic boolean test(double input)
Test a value from an instance (of the data set), to see if it is covered.
input
- the input value (of the same attribute as this Gene!)