|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--net.openai.ai.ga.cell.encoding.StrictPermutation
The StrictPermutation
class stores a permutation of values from
0 to (length-1). All values are represented, however it is their order
that is of interest. This class supports cross-over and mutation.
the maximum for the list in
Constructor Summary | |
StrictPermutation(StrictPermutation toClone)
Creates and returns a clone of the given StrictPermutation . |
|
StrictPermutation(java.lang.String name,
int length)
Creates a new StrictPermutation with the specified length
and given name. |
|
StrictPermutation(java.lang.String name,
int length,
int[] vals)
Creates a new StrictPermutation initialized with the
specified capacity and starting with the values in the passed integer
array so far as is possible using setListLoosely . |
Method Summary | |
static StrictPermutation |
cross(StrictPermutation first,
StrictPermutation second)
Returns a new StrictPermutation based on two other
permutations of the same length. |
int |
getElement(int element)
Returns the value of a certain element in the permutation |
int |
getLength()
Returns the length of this permutation list |
int[] |
getList()
Returns this permutation as a int[] . |
java.lang.String |
getName()
Returns the name of this permutation list |
void |
mutate(int amount)
Mutates a given number of elements in the permutation. |
void |
setLength(int size)
Sets the length of this permutation. |
void |
setList(int[] list)
Sets the permutation to the values in the given list. |
void |
setListLoosely(int[] list)
Sets the permutation to the values in the given list when possible. |
void |
setListLoosely(int[] list,
int start)
Sets the permutation to the values in the given list when possible starting from a given position. |
void |
setName(java.lang.String name)
Sets the name of this permutation |
java.lang.String |
toString()
Method declaration |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public StrictPermutation(java.lang.String name, int length)
StrictPermutation
with the specified length
and given name.
name
- a String
representing the string's namelength
- the number of elements in this listpublic StrictPermutation(java.lang.String name, int length, int[] vals)
StrictPermutation
initialized with the
specified capacity and starting with the values in the passed integer
array so far as is possible using setListLoosely
.
name
- a String
representing the string's namepublic StrictPermutation(StrictPermutation toClone)
StrictPermutation
.
Throws NullPointerException
when passed null
.
toClone
- the binary string to cloneMethod Detail |
public int getLength()
public void setLength(int size)
public java.lang.String getName()
public void setName(java.lang.String name)
name
- the String
for the new name of this listpublic int[] getList()
int[]
.
public void setList(int[] list)
list
- an int[]
value to duplicatepublic void setListLoosely(int[] list)
list
- an int[]
value to try to duplicatepublic void setListLoosely(int[] list, int start)
list
- an int[]
value to try to duplicatestart
- the position to start frompublic int getElement(int element)
element
- the element to returnpublic static StrictPermutation cross(StrictPermutation first, StrictPermutation second)
StrictPermutation
based on two other
permutations of the same length. A cross-over point is picked at
random and all elements before this point are the same as the first
parent's and all all other elements are added in the same order as they
are in the second permutation when possible. Neither parent is altered
during this call.
first
- the first StrictPermutation
second
- the second StrictPermutation
public void mutate(int amount)
amount
- the number of elements to exchange ("mutate")public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |