|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractMap<K,V>
java.util.HashMap<java.lang.Object,java.util.HashMap<java.lang.Integer,AbstractRule>>
clarion.system.RuleCollection
public class RuleCollection
This class implements a rule collection within CLARION. It extends the HashMap class and implements the InterfaceTracksMatchStatistics and InterfaceHandlesFeedback interfaces.
Usage:
The rule collection acts as a container for rules that are used by a CLARION agent for action decision making. This class is most often used within the ACS as the container for the rule stores.
The rule collection also tracks (or generates): rule variations, child rules, and collection-wide match statistics. In addition, it has the ability to correctly place newly added rules within the collection by determining if the rule should be in the collection or within a child collection.
For all of the rules in the rule collection that are refineable (i.e. they extend from the RefineableRule class), hidden minor variations of those rules are generated automatically and tracked by this class in order to facilitate generalization and specialization.
In addition to tracking match statistics for the hidden variations, the rule collection also keeps track of collection-wide match statistics that are used to for variable level selection within the ACS as well as for performance monitoring and reporting purposes.
This class contains both global (static) and local constants. The default is to use the local constants. If you want to change any of the global constants, you need to do so before any instances of this class are initialized.
Field Summary | |
---|---|
protected HiddenRuleCollection |
Children
Contains any existent child rules for the rules in the rule collection. |
private double |
Feedback
The immediate feedback (if given). |
static double |
GLOBAL_POSITIVE_MATCH_THRESHOLD
The threshold that must be passed to meet the positive match criterion. |
protected double |
NM
The negative match counter. |
protected double |
PM
The positive match counter. |
double |
POSITIVE_MATCH_THRESHOLD
The threshold that must be passed to meet the positive match criterion. |
private static long |
serialVersionUID
|
protected HiddenRuleCollection |
Variations
Contains the hidden rule variations for all rules in the rule collection. |
Constructor Summary | |
---|---|
RuleCollection()
Initializes a rule collection. |
|
RuleCollection(java.util.Collection<? extends AbstractRule> rules)
Initializes a rule collection with the collection of rules specified. |
Method Summary | |
---|---|
boolean |
checkMatchCriterion()
This method does nothing as it is not used by the CLARION Library for this collection. |
boolean |
contains(AbstractRule rule)
Checks to see if the collection contains the specified rule. |
boolean |
containsCover(AbstractRule rule)
Checks to see if the collection contains a rule that covers the specified rule. |
void |
discountMatchStatistics(double Discount)
Discounts the positive and negative match statistics for all rules in the rule collection and all rule variations. |
private void |
generateVariations(RefineableRule R)
Generates variations for the rule r and adds any variations that are not already in the variations list to that list. |
AbstractRule |
get(GeneralizedConditionChunk cond,
AbstractAction act)
Gets a rule in the collection that matches the specified condition and action. |
java.util.Collection<AbstractRule> |
getChildren()
Gets the child rules from the rule collection. |
AbstractRule |
getCover(GeneralizedConditionChunk cond,
AbstractAction act)
Gets a rule in the collection that covers the specified condition and action. |
double |
getFeedback()
Gets the feedback. |
double |
getNM()
Gets the negative match statistic. |
double |
getPM()
Gets the positive match statistic. |
java.util.Collection<AbstractRule> |
getRules()
Gets all of the rules in the rule collection. |
java.util.Collection<AbstractRule> |
getVariations()
Gets the rule variations from the rule collection. |
void |
incrementNM()
Increments the negative match statistic. |
void |
incrementPM()
Increments the positive match statistic. |
int |
numChildren()
Gets the number of children being tracked by this collection. |
int |
numVariations()
Gets the number of variations being tracked by this collection. |
void |
put(AbstractRule R)
Puts a rule into the rule collection. |
java.util.HashMap<java.lang.Integer,AbstractRule> |
put(java.lang.Object key,
java.util.HashMap<java.lang.Integer,AbstractRule> map)
This method does nothing. |
void |
putAll(java.util.Collection<? extends AbstractRule> R)
Puts a collection of rules into the rule collection. |
void |
putAll(java.util.Map<? extends java.lang.Object,? extends java.util.HashMap<java.lang.Integer,AbstractRule>> map)
This method does nothing. |
AbstractRule |
remove(GeneralizedConditionChunk cond,
AbstractAction act)
Removes the rule from this rule collection with the specified condition and action. |
java.util.HashMap<java.lang.Integer,AbstractRule> |
remove(java.lang.Object key)
This method does nothing. |
void |
removeChild(AbstractRule CR)
Removes the specified rule from the child rule collection (if it is in the child rule collection). |
void |
removeVariations(RefineableRule R)
Removes the variations from the variations list for all variations of the specified rule that are not also a variation for another rule in the rule collection. |
void |
resetMatchStatistics()
Resets the match statistics. |
void |
setFeedback(double feedback)
Sets the feedback. |
void |
setNM(double nm)
Sets the negative match statistic. |
void |
setPM(double pm)
Sets the positive match statistic. |
int |
size()
Returns the number of rules in the rule collection. |
java.lang.String |
toString()
|
void |
updateMatchStatistics(AbstractMatchCalculator MatchCalculator)
Updates the positive or negative match statistics based on the feedback. |
Methods inherited from class java.util.HashMap |
---|
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, values |
Methods inherited from class java.util.AbstractMap |
---|
equals, hashCode |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Map |
---|
equals, hashCode |
Field Detail |
---|
private static final long serialVersionUID
protected HiddenRuleCollection Variations
protected HiddenRuleCollection Children
private double Feedback
protected double PM
protected double NM
public static double GLOBAL_POSITIVE_MATCH_THRESHOLD
public double POSITIVE_MATCH_THRESHOLD
Constructor Detail |
---|
public RuleCollection()
public RuleCollection(java.util.Collection<? extends AbstractRule> rules)
rules
- The rules for the collection.Method Detail |
---|
public AbstractRule get(GeneralizedConditionChunk cond, AbstractAction act)
cond
- The condition of the rule to get.act
- The action of the rules to get.
public AbstractRule getCover(GeneralizedConditionChunk cond, AbstractAction act)
This method does NOT guarantee that the rule returned is the only rule in the collection that covers the specified condition and action.
cond
- The condition the rule to get must cover.act
- The action of the rules to get.
public boolean contains(AbstractRule rule)
rule
- The rule object you wish to check for within this collection.
public boolean containsCover(AbstractRule rule)
rule
- The rule object you wish to check within this collection.
public java.util.HashMap<java.lang.Integer,AbstractRule> put(java.lang.Object key, java.util.HashMap<java.lang.Integer,AbstractRule> map)
put
in interface java.util.Map<java.lang.Object,java.util.HashMap<java.lang.Integer,AbstractRule>>
put
in class java.util.HashMap<java.lang.Object,java.util.HashMap<java.lang.Integer,AbstractRule>>
key
- map
-
public void putAll(java.util.Map<? extends java.lang.Object,? extends java.util.HashMap<java.lang.Integer,AbstractRule>> map)
putAll
in interface java.util.Map<java.lang.Object,java.util.HashMap<java.lang.Integer,AbstractRule>>
putAll
in class java.util.HashMap<java.lang.Object,java.util.HashMap<java.lang.Integer,AbstractRule>>
map
- public java.util.HashMap<java.lang.Integer,AbstractRule> remove(java.lang.Object key)
remove
in interface java.util.Map<java.lang.Object,java.util.HashMap<java.lang.Integer,AbstractRule>>
remove
in class java.util.HashMap<java.lang.Object,java.util.HashMap<java.lang.Integer,AbstractRule>>
key
-
public void put(AbstractRule R)
R
- The rule to add.public void putAll(java.util.Collection<? extends AbstractRule> R)
R
- The rules to put in the collection.public AbstractRule remove(GeneralizedConditionChunk cond, AbstractAction act)
If the rule collection does not contain a rule with the specified condition and action, this method returns null.
cond
- The condition of the rule you want to remove.act
- The action of the rule you want to remove.
public java.util.Collection<AbstractRule> getRules()
public void removeVariations(RefineableRule R)
R
- The rule whose variations you wish to remove.private void generateVariations(RefineableRule R)
R
- The rule from which to generate variations.public void removeChild(AbstractRule CR)
CR
- The rule to remove from the child rule collection.public void discountMatchStatistics(double Discount)
Discount
- The discount factor to be applied to the match statistics of the rules.public double getPM()
getPM
in interface InterfaceTracksMatchStatistics
public double getNM()
getNM
in interface InterfaceTracksMatchStatistics
public void setPM(double pm)
setPM
in interface InterfaceTracksMatchStatistics
pm
- The value to set as the positive match statistic.public void setNM(double nm)
setNM
in interface InterfaceTracksMatchStatistics
nm
- The value to set as the negative match statistic.public double getFeedback()
getFeedback
in interface InterfaceHandlesFeedback
public void setFeedback(double feedback)
setFeedback
in interface InterfaceHandlesFeedback
feedback
- The value of the feedback.public void updateMatchStatistics(AbstractMatchCalculator MatchCalculator)
This update is usually performed after the feedback has been set.
updateMatchStatistics
in interface InterfaceTracksMatchStatistics
MatchCalculator
- The match calculator to use to determine positivity.public void resetMatchStatistics()
resetMatchStatistics
in interface InterfaceTracksMatchStatistics
public void incrementPM()
incrementPM
in interface InterfaceTracksMatchStatistics
public void incrementNM()
incrementNM
in interface InterfaceTracksMatchStatistics
public boolean checkMatchCriterion()
checkMatchCriterion
in interface InterfaceHandlesFeedback
public int size()
size
in interface java.util.Map<java.lang.Object,java.util.HashMap<java.lang.Integer,AbstractRule>>
size
in class java.util.HashMap<java.lang.Object,java.util.HashMap<java.lang.Integer,AbstractRule>>
public int numVariations()
public int numChildren()
public java.util.Collection<AbstractRule> getVariations()
This method should NOT be used to manipulate the rule variations from outside of the CLARION library.
public java.util.Collection<AbstractRule> getChildren()
This method should NOT be used to manipulate the child rules from outside of the CLARION library.
public java.lang.String toString()
toString
in class java.util.AbstractMap<java.lang.Object,java.util.HashMap<java.lang.Integer,AbstractRule>>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |