|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjmetal.core.Variable
jmetal.encodings.variable.Binary
public class Binary
This class implements a generic binary string encodings.variable.It can be used as a base class other binary string based classes (e.g., binary coded integer or real variables).
Field Summary | |
---|---|
java.util.BitSet |
bits_
Stores the bits constituting the binary string. |
protected int |
numberOfBits_
Store the length of the binary string |
Constructor Summary | |
---|---|
Binary()
Default constructor. |
|
Binary(Binary variable)
Copy constructor. |
|
Binary(int numberOfBits)
Constructor |
Method Summary | |
---|---|
void |
decode()
This method is intended to be used in subclass of Binary ,
for examples the classes, BinaryReal and BinaryInt |
Variable |
deepCopy()
Creates an exact copy of a Binary object |
boolean |
getIth(int bit)
Returns the value of the ith bit. |
int |
getNumberOfBits()
Returns the length of the binary string. |
int |
hammingDistance(Binary other)
Obtain the hamming distance between two binary strings |
void |
setIth(int bit,
boolean value)
Sets the value of the ith bit. |
java.lang.String |
toString()
|
Methods inherited from class jmetal.core.Variable |
---|
getLowerBound, getUpperBound, getValue, getVariableType, setLowerBound, setUpperBound, setValue |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public java.util.BitSet bits_
protected int numberOfBits_
Constructor Detail |
---|
public Binary()
public Binary(int numberOfBits)
numberOfBits
- Length of the bit stringpublic Binary(Binary variable)
variable
- The Binary encodings.variable to copy.Method Detail |
---|
public void decode()
Binary
,
for examples the classes, BinaryReal
and BinaryInt.
In this classes, the method allows to decode the
value enconded in the binary string. As generic variables do not encode any
value, this method do noting
deepCopy
public Variable deepCopy()
- Creates an exact copy of a Binary object
- Specified by:
deepCopy
in class Variable
- Returns:
- An exact copy of the object.
getNumberOfBits
public int getNumberOfBits()
- Returns the length of the binary string.
- Returns:
- The length
getIth
public boolean getIth(int bit)
- Returns the value of the ith bit.
- Parameters:
bit
- The bit to retrieve
- Returns:
- The ith bit
setIth
public void setIth(int bit,
boolean value)
- Sets the value of the ith bit.
- Parameters:
bit
- The bit to set
hammingDistance
public int hammingDistance(Binary other)
- Obtain the hamming distance between two binary strings
- Parameters:
other
- The binary string to compare
- Returns:
- The hamming distance
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object
Overview
Package
Class
Use
Tree
Deprecated
Index
Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD