|
MOEA Framework 2.5 API Specification |
|||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||
java.lang.Objectorg.moeaframework.util.grammar.ContextFreeGrammar
public class ContextFreeGrammar
A context-free grammar. The rule at index 0 is the starting rule when
building derivation trees.
Rule| Constructor Summary | |
|---|---|
ContextFreeGrammar()
Constructs an empty grammar. |
|
| Method Summary | |
|---|---|
void |
add(Rule rule)
Adds a rule to this grammar. |
String |
build(int[] array)
Returns the grammar derivation using the construction rules of Grammatical Evolution on the specified codon array; or null if
the codon array failed to produce a valid derivation Whenever the
derivation encounters a rule with multiple productions, the production
used to expand the rule is chosen using this codon array. |
Rule |
get(int index)
Returns the rule at the specified index. |
Rule |
get(Symbol symbol)
Returns the rule for the specified symbol; or null if no rule
with the specified symbol exists. |
int |
getWrapLimit()
Returns the maximum number of times the builder will wrap around the codon array before failing to produce a valid derivation. |
boolean |
isValid()
Returns true if this grammar is valid; false otherwise. |
void |
remove(Rule rule)
Removes a rule from this grammar. |
void |
setWrapLimit(int wrapLimit)
Sets the maximum number of times the builder will wrap around the codon array before failing to produce a valid derivation. |
int |
size()
Returns the number of rules contained in this grammar. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ContextFreeGrammar()
| Method Detail |
|---|
public int getWrapLimit()
public void setWrapLimit(int wrapLimit)
wrapLimit - the maximum number of times the builder will wrap around
the codon array before failing to produce a valid derivationpublic void add(Rule rule)
rule - the rule to be addedpublic void remove(Rule rule)
rule - the rule to be removedpublic int size()
public Rule get(int index)
index - the index of the rule to be returned
IndexOutOfBoundsException - if index is out of range ((index
< 0) || (index >= size())public Rule get(Symbol symbol)
null if no rule
with the specified symbol exists.
symbol - the symbol of the rule to be returned
null if no rule
with the specified symbol existspublic String build(int[] array)
null if
the codon array failed to produce a valid derivation Whenever the
derivation encounters a rule with multiple productions, the production
used to expand the rule is chosen using this codon array.
array - the codon array
null if the codon array failed to produce a valid
derivation
GrammarException - if the codon array is emptypublic boolean isValid()
true if this grammar is valid; false otherwise. A
grammar is valid if it is non-empty and all non-terminal symbols are
defined by a rule in the grammar.
true if this grammar is valid; false otherwise
|
MOEA Framework 2.5 API Specification |
|||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||