|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectcern.colt.PersistentObject
cern.colt.bitvector.BitVector
jas.ai.ga.GARule
public class GARule
A genetic element of population. It is based on cern.colt.bitvector.BitVector from COLT library.
Title: JAS
Description: Java Agent-based Simulation library
Copyright (C) 2002 Michele Sonnessa
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
| Constructor Summary | |
|---|---|
GARule(int stringLength)
Create a new rule with given number of bits and id = 0. |
|
GARule(int id,
int stringLength)
Create a new rule with given number of bits and id. |
|
| Method Summary | |
|---|---|
void |
addCopy()
Increase the number of copies. |
void |
clear()
Empty the bit string and put each parameter to its default value. |
void |
clear(int id)
Empty the bit string and put each parameter to its default value. |
void |
clear(int id,
int stringLength)
Empty the bit string and put each parameter to its default value. |
java.lang.Object |
clone()
Create a bitwise copy of the object. |
int |
compareTo(java.lang.Object o)
Compare the fitness value of two rules returning an ordered signed value. |
void |
copyFromGenoma(GARule sourceRule)
Replace current genoma with the one of the given rule. |
void |
copyFromRule(GARule sourceRule)
Replace current rule with the given one. |
void |
crossWithRule(GARule sourceRule,
int crossPoint)
WARNING: To be tested. |
void |
decreaseFitness(double decrement)
Decrease the current fitness value. |
void |
flip(int bitIndex)
Flip the state of a bit. |
int |
getCopies()
Return the number of copies. |
double |
getFitness()
Return the current fitness. |
java.lang.String |
getGenomaString()
Return the bit string in the format 010101010001 |
int |
getID()
Return the rule id. |
int |
hashCode()
The hashCode depends only on the content of the bit string. |
void |
increaseFitness(double increment)
Increase the current fitness value. |
void |
randomInitialize()
Initialize the bit string to a uniform random initial state. |
void |
set(int bitIndex,
boolean value)
Change the state of the given bit to the given value. |
void |
setCopies(int copies)
Set the number of copies for this rule. |
void |
setFitness(double fitness)
Set the current fitness value. |
void |
setWillDie(boolean willDie)
Set the willDie parameter. |
void |
setWillGenerate(boolean willGenerate)
Set the willGenerate parameter. |
java.lang.String |
toString()
Return a string in the format id [Fitness: # [willGenerate] [willDie] copies #] 0101.0101.0001 |
boolean |
willDie()
Return if the rule will die at next evolution. |
boolean |
willGenerate()
Return if the rule will be regenerated at next evolution. |
| Methods inherited from class cern.colt.bitvector.BitVector |
|---|
and, andNot, cardinality, copy, elements, elements, equals, forEachIndexFromToInState, get, getLongFromTo, getQuick, indexOfFromTo, not, or, partFromTo, put, putLongFromTo, putQuick, replaceFromToWith, replaceFromToWith, set, setSize, size, xor |
| Methods inherited from class java.lang.Object |
|---|
getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public GARule(int stringLength)
stringLength - The fixed length of the bit string.
public GARule(int id,
int stringLength)
stringLength - The fixed length of the bit string.id - An integer used to identify the rule.| Method Detail |
|---|
public void addCopy()
public void clear()
clear in class cern.colt.bitvector.BitVectorpublic void clear(int id)
clear in class cern.colt.bitvector.BitVectorid - Change the id of the rule.
public void clear(int id,
int stringLength)
id - Changes the id of the rule.stringLength - Changes the length of the bit string.public java.lang.Object clone()
clone in class cern.colt.bitvector.BitVectorpublic int compareTo(java.lang.Object o)
compareTo in interface java.lang.Comparableo - The object to be compared. It must be a Rule.
java.lang.ClassCastException - if o is not an instance of Rule class.public void copyFromGenoma(GARule sourceRule)
sourceRule - The rule from which to copy the genoma.public void copyFromRule(GARule sourceRule)
sourceRule - The rule overwriting this.
public void crossWithRule(GARule sourceRule,
int crossPoint)
sourceRule - The rule to be crossed with this.crossPoint - The bitIndex of the cross point.
java.lang.UnsupportedOperationException - if the rules are not of the same size.
java.lang.IndexOutOfBoundsException - if crossPoint < 0 || crossPoint >= size().public void decreaseFitness(double decrement)
decrement - The value to be subtracted to the fitness value.public void flip(int bitIndex)
bitIndex - The bit to be flipped.
java.lang.IndexOutOfBoundsException - - if bitIndex<0 || bitIndex>=size().public int getCopies()
public double getFitness()
public java.lang.String getGenomaString()
public int getID()
public int hashCode()
hashCode in class cern.colt.bitvector.BitVectorpublic void increaseFitness(double increment)
increment - The value to be added to the fitness value.public void randomInitialize()
public void set(int bitIndex,
boolean value)
bitIndex - The 0 based index of the bit to change.value - The new value of the selected bit.
java.lang.IndexOutOfBoundsException - - if bitIndex<0 || bitIndex>=size().public void setCopies(int copies)
copies - The number of copies.public void setFitness(double fitness)
fitness - The fitness value for this rule.public void setWillDie(boolean willDie)
willDie - It decides if the rule will die at next evolution.public void setWillGenerate(boolean willGenerate)
willGenerate - It decides if the rule will reproduced at next evolution.public java.lang.String toString()
toString in class cern.colt.bitvector.BitVectorpublic boolean willDie()
public boolean willGenerate()
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||