public class MealyFSM extends AbstractRepresentation
| Constructor and Description |
|---|
MealyFSM(int nInput,
int nOutput,
NESRandom random,
java.util.Hashtable<java.lang.String,XMLFieldEntry> properties) |
| Modifier and Type | Method and Description |
|---|---|
static int |
calcHammingDistance(MealyFSM fsm1,
MealyFSM fsm2)
Calculates Hamming distance between two Mealy FSMs.
|
static int |
calcMaxEqualPrefix(MealyFSM fsm1,
MealyFSM fsm2)
Calculates maximal equal prefix for two Mealy FSMs.
|
AbstractRepresentation |
cloneFunction()
Creates a full clone of this representation.
|
double |
diffTo(AbstractRepresentation representation)
Compares this representation to another one.
|
void |
exportToFile(java.io.File saveFile)
Exports the content of this representation to a file.
|
org.dom4j.Element |
exportToXmlElement(org.dom4j.Element element)
Exports this representation and all its necessary data to the provided XML element.
|
void |
exportToYEDxmlFormat(java.lang.String name)
Export FSM as a graph's edge-list into a csv (comma separated) file.
|
void |
genRandomFSM()
Generate Mealy FSM with random generation.
|
MealyFSM |
genSimaoRandomFSM()
Generates a Mealy FSM so that all of the states are reachable.
|
java.lang.String |
genStringRepr()
Generate String representation of Mealy FSM.
|
int |
getCountOfUsedStates()
Return how many states were used during evaluation of FSM.
|
int |
getCurrentState()
Return current state of the FSM.
|
java.util.Hashtable<java.lang.String,java.lang.String> |
getDetails()
Returns a table of key-value pairs that describes this representation.
|
java.util.ArrayList<java.lang.Float> |
getFloatOutputs(java.util.ArrayList<java.lang.Integer> outputs)
Return outputs associated with a transition as FREVO expects: a list of
floats.
|
java.util.ArrayList<java.lang.Integer> |
getNextStates()
Get next states associated with all transitions (part of the encoding of
state transition table).
|
int |
getNStates()
Returns the number of states of the Mealy FSM.
|
int |
getNumberofMutationFunctions()
Returns the number of implemented mutation functions.
|
int |
getNumberOfRecombinationFunctions()
Returns the number of implemented crossover functions.
|
java.util.ArrayList<java.lang.Float> |
getOutput(java.util.ArrayList<java.lang.Float> input)
Processes the given list of inputs and returns the corresponding output values.
|
java.lang.String |
getOutputsAsString(java.util.ArrayList<java.lang.Integer> outputs,
java.lang.String separator)
Returns output list as a string.
|
java.util.ArrayList<java.util.ArrayList<java.lang.Integer>> |
getOutputsList()
Get outputs associated with all transitions (part of the encoding of
state transition table).
|
int |
getPositionInSortedInputList(java.util.ArrayList<java.lang.Float> input)
Returns position of an input value combination in a sorted list, where
all input value combinations are listed.
|
int[] |
getStateHistogram()
Return state histogram as an array of integer, each item specifying how
many times was the FSM in a specific state.
|
java.lang.String |
getUniqueName()
Returns a unique name of this representation calculated by its parameters/structure.
|
java.util.ArrayList<java.lang.Integer> |
getUsedStateList()
Return list of used states.
|
AbstractRepresentation |
loadFromXML(org.dom4j.Node nd)
Reconstructs this representation from the given XML node.
|
void |
mutateThresholds(float prob)
Apply mutation to thresholds with a given probability
|
void |
mutationAddState(float prob)
Apply mutation add state with a given probability.
|
void |
mutationChangeInitState(float prob)
Apply mutation change initial state with a given probability
|
void |
mutationChangeNextStates(float prob)
Apply mutation to next states with a given probability
|
void |
mutationChangeOutputs(float prob)
Apply mutation to outputs with a given probability
|
void |
mutationRemoveState(float prob)
Remove a random state with a given probability
|
void |
onepointCrossover(MealyFSM other)
Performs one-point crossover between this Mealy FSM and another one.
|
void |
recombinationFunction(AbstractRepresentation other,
int method)
Specific implementation of the recombination function that initiates a crossover on this representation
and with the given representation with the provided function.
Use AbstractRepresentation.getNumberOfRecombinationFunctions() to obtain the number of implemented recombination functions. |
void |
reset()
Resets the representation to its base state.
|
void |
setNextState(int pos,
int nextState)
Set next state in the encoded state transition table.
|
void |
uniformCrossover(MealyFSM other)
Performes uniform-crossover between this Mealy FSM and another one.
|
clone, compareTo, getFitness, isEvaluated, mutate, setFitness, toString, xOverWithgetProperties, getPropertyValue, getTypeOfProperty, getXMLData, setProperties, setXMLDatapublic MealyFSM(int nInput,
int nOutput,
NESRandom random,
java.util.Hashtable<java.lang.String,XMLFieldEntry> properties)
public void exportToYEDxmlFormat(java.lang.String name)
name - name of the file to which to exportpublic AbstractRepresentation cloneFunction()
AbstractRepresentationpublic double diffTo(AbstractRepresentation representation)
AbstractRepresentationdiffTo in class AbstractRepresentationrepresentation - The other representation to compare to.public static int calcHammingDistance(MealyFSM fsm1, MealyFSM fsm2)
fsm1 - first Mealy FSMfsm2 - second Mealy FSMpublic static int calcMaxEqualPrefix(MealyFSM fsm1, MealyFSM fsm2)
fsm1 - first Mealy FSMfsm2 - second Mealy FSMpublic void mutationAddState(float prob)
prob - probability of applying the mutationpublic void mutationRemoveState(float prob)
prob - probability of applying the mutationpublic void mutationChangeInitState(float prob)
prob - probability of applying the mutationpublic void mutationChangeOutputs(float prob)
prob - probability of applying the mutationpublic void mutationChangeNextStates(float prob)
prob - probability of applying the mutationpublic void mutateThresholds(float prob)
prob - probability of applying the mutationpublic int getNStates()
public void uniformCrossover(MealyFSM other)
other - The other parent (Mealy FSM) used to perform crossover.public void onepointCrossover(MealyFSM other)
other - The other parent (Mealy FSM) used to perform crossover.public MealyFSM genSimaoRandomFSM()
public void genRandomFSM()
public void exportToFile(java.io.File saveFile)
AbstractRepresentationexportToFile in class AbstractRepresentationsaveFile - The file to be saved topublic org.dom4j.Element exportToXmlElement(org.dom4j.Element element)
AbstractRepresentationAbstractRepresentation.loadFromXML(Node).exportToXmlElement in class AbstractRepresentationelement - The root element to be used for saving.public java.util.Hashtable<java.lang.String,java.lang.String> getDetails()
AbstractRepresentationgetDetails in class AbstractRepresentationpublic int getNumberofMutationFunctions()
AbstractRepresentationgetNumberofMutationFunctions in class AbstractRepresentationpublic int getNumberOfRecombinationFunctions()
AbstractRepresentationgetNumberOfRecombinationFunctions in class AbstractRepresentationpublic java.lang.String getUniqueName()
AbstractRepresentationgetUniqueName in class AbstractRepresentationpublic AbstractRepresentation loadFromXML(org.dom4j.Node nd)
AbstractRepresentationloadFromXML in class AbstractRepresentationnd - The root XML node to load the data from.public void reset()
AbstractRepresentationreset in class AbstractRepresentationpublic void recombinationFunction(AbstractRepresentation other, int method)
AbstractRepresentationAbstractRepresentation.getNumberOfRecombinationFunctions() to obtain the number of implemented recombination functions.public java.lang.String genStringRepr()
A part of the Mealy FSM's string representation is the following (the FSM has 6 states, its initial state is 0 and it has two threshold values: 6 and 28):
000,06,28,1(072,020),4(053,066),3(044,067),3(040,021), ...1(063,087).
public java.lang.String getOutputsAsString(java.util.ArrayList<java.lang.Integer> outputs,
java.lang.String separator)
outputs - output list associated with a transitionseparater - String separator used to separate output valuespublic int getCountOfUsedStates()
public int[] getStateHistogram()
public java.util.ArrayList<java.lang.Integer> getUsedStateList()
public java.util.ArrayList<java.lang.Float> getFloatOutputs(java.util.ArrayList<java.lang.Integer> outputs)
public java.util.ArrayList<java.lang.Float> getOutput(java.util.ArrayList<java.lang.Float> input)
AbstractRepresentationgetOutput in class AbstractRepresentationinput - The list of input values to be processed.public java.util.ArrayList<java.util.ArrayList<java.lang.Integer>> getOutputsList()
public java.util.ArrayList<java.lang.Integer> getNextStates()
public void setNextState(int pos,
int nextState)
pos - position of the transition in the state transition tablenextState - next state to be set for a transitionpublic int getPositionInSortedInputList(java.util.ArrayList<java.lang.Float> input)
public int getCurrentState()