public class Thresholds
extends java.lang.Object
ThresholdSource
and relates to an association with one other
source only. This class stores the references to all related sources in all of the different
linking levels. It also updates these references when a new group of source references
is presented.
This class only represents the final or leaf node structures that contain the link values
for each source. Any path associated with a group of linked sources is stored in the
Link
, Link_M
, or related linking service classes. Each evaluation is now passed
through an activation function that can be defined by its class name. This defaults to
the linear type that simply returns the same value that is passed in. Other types can make
the link value evaluation less linear, but there is no check on any correctness, as any
relevant function can be added. The only exception is a check for the value of <= 0
,
which is done using the link value only, without any activation function.
Modifier and Type | Field and Description |
---|---|
protected float |
decWeight
The amount to weight decrement values by
|
protected org.ai_heuristic.functs.FunctionActivate |
functionActive
The activation function to use.
|
protected float |
increment
The amount to increment source values by
|
protected float |
incWeight
The amount to weight increment values by
|
protected java.lang.String |
linkMethod
The linking method used
|
protected int |
linkNumber
The number of links to store
|
protected LinkSpec |
linkSpec
The original threshold config values
|
protected float |
linkThreshold
The threshold to add a link
|
protected java.util.HashMap<java.lang.String,ThresholdSource> |
linkValues
The actual values at the link level.
|
protected int |
maxNegative
The maximum number of allowed negative entries for each link
|
protected int |
monitorNumber
The number of monitors to store
|
protected float |
monitorThreshold
The threshold to monitor the source
|
protected java.util.HashMap<java.lang.String,ThresholdSource> |
monitorValues
The actual values at the monitor level.
|
protected Link |
parent
The parent component
|
protected int |
possibleNumber
The number of possible sources to store
|
protected java.util.HashMap<java.lang.String,ThresholdSource> |
possibleValues
A source for possible values that may later be monitored.
|
protected ThresholdSource |
reserve
The reserve source that may be added
|
protected java.util.HashMap<java.lang.String,java.lang.Long> |
timeStamps
The times the sources were last incremented
|
protected int |
totalMovedDown
The number of sources moved down because they fell below the threshold
|
protected int |
totalMovedUp
The number of sources moved up / swapped next level up
|
protected java.util.ArrayList<java.lang.Object> |
updatedSources
A list of sources that have already been updated
|
Constructor and Description |
---|
Thresholds(int thisMaxNegative,
LinkSpec thisLinkSpec)
Creates a new instance of Thresholds.
|
Thresholds(int thisMaxNegative,
LinkSpec thisLinkSpec,
Link thisParent)
Creates a new instance of Thresholds.
|
Thresholds(LinkSpec thisLinkSpec)
Creates a new instance of Thresholds.
|
Modifier and Type | Method and Description |
---|---|
protected float |
activationValue(float sourceWeight)
Return the activation value for the specified source weight value.
|
void |
changeLinkNumber(int changeNumber)
Change the number of link sources to store.
|
void |
changeMonitorNumber(int changeNumber)
Change the number of monitor sources to store.
|
void |
changePossibleNumber(int changeNumber)
Change the number of possible sources to store.
|
org.ai_heuristic.functs.FunctionActivate |
cloneFunction()
Return a new instance of the activation function stored in this Thresholds structure.
|
protected boolean |
contains(java.util.ArrayList<java.lang.Object> sources,
java.lang.Object key)
Return true if the sources contain a source with the key specified.
|
protected void |
createActivationFunction()
Create the activation function, from the spec description.
|
void |
decrementReserve(java.util.ArrayList<java.lang.Object> sources)
If the reserve source is not the same name then decrement its value.
|
org.ai_heuristic.functs.FunctionActivate |
getActivationFunction()
Get the activation function.
|
protected float |
getDecrement()
Get the value to decrement sources by.
|
float |
getDecWeight()
Get the decrement weight value.
|
float |
getIncrement()
Get the increment value.
|
float |
getIncWeight()
Get the increment weight value.
|
int |
getLinkCount()
Get the number of sources stored as links.
|
java.lang.String |
getLinkMethod()
Get the linking method used.
|
int |
getLinkNumber()
Get the number of links to store.
|
java.util.ArrayList<java.lang.Object> |
getLinkSources()
Get the link sources.
|
java.util.ArrayList<java.lang.Object> |
getLinkSources(java.util.ArrayList<java.lang.Object> negativeSources)
Get the link sources, where the negative concepts do not apply.
|
LinkSpec |
getLinkSpec()
Get the original linking configuration.
|
float |
getLinkThreshold()
Get the link threshold value.
|
ThresholdSource |
getMinSource(int thresholdType)
Return the minimum source name for the specified threshold type:
link, monitor or possible.
|
int |
getMonitorCount()
Get the number of sources stored as monitors.
|
int |
getMonitorNumber()
Get the number of monitors to store.
|
float |
getMonitorThreshold()
Get the monitor threshold value.
|
java.util.HashMap<java.lang.String,ThresholdSource> |
getMonitorValues()
Get the monitor values.
|
int |
getPossibleCount()
Get the number of sources stored as possible links.
|
int |
getPossibleNumber()
Get the number of possible sources to store.
|
java.util.HashMap<java.lang.String,ThresholdSource> |
getPossibleValues()
Get the possible values.
|
ThresholdSource |
getReserve()
Get the reserve source value.
|
int |
getSourceCount()
Return the current total number of source references in the structure.
|
int |
getSourceLevel(java.lang.Object source)
Return the level at which the source is stored at or no level if not stored.
|
int |
getTotalMovedDown()
Get the total number of sources last moved down a level.
|
int |
getTotalMovedUp()
Get the total number of sources last moved up a level.
|
void |
incAndMoveSourceUp(java.lang.Object source,
long timeStamp)
Add a new source or increment its weight value and move it up the linking
structure if necessary.
|
void |
incrementReserve(long timeStamp)
Increment the reserve source value.
|
protected float |
incrementSource(int thresholdType,
java.lang.Object source)
Increment the source value stored at the specified level.
|
float |
incrementSource(int thresholdType,
java.lang.Object source,
long timeStamp)
Increment the source value stored at the specified level.
|
void |
linksToString(java.util.HashMap<java.lang.String,java.lang.String> linkStrings,
boolean allLevels)
Serialize the link sources into strings and return.
|
org.licas_xml.abs.Element |
linksToXml(boolean allLevels,
boolean includeValues)
Serialize the link values into XML and return.
|
boolean |
moveSourceDown(int thresholdType,
java.lang.Object source)
Move the specified source from the specified level down to the next level.
|
boolean |
moveSourceDown(java.lang.Object source)
Move the specified source from the level it is at, down to the next level.
|
void |
moveSourceUp(int thresholdType,
java.lang.Object source,
long timeStamp)
Automatically move the specified source from the specified level up to the next level.
|
void |
removeSource(int thresholdType,
java.lang.Object source)
Remove the specified source from the specified level.
|
void |
resetRelated()
Reset the related values structures.
|
void |
resetUpdatedSources()
Reset values to indicate no sources have currently been updated.
|
void |
resetValues()
Reset the thresholds to initial values.
|
void |
setActivationFunction(org.ai_heuristic.functs.FunctionActivate thisFunctionActive)
Set the activation function.
|
void |
setLinkSpec(LinkSpec thisLinkSpec)
Set the linking configuration.
|
void |
setLinkValues(java.util.HashMap<java.lang.String,ThresholdSource> thisLinkValues)
Set the link values.
|
void |
setMonitorValues(java.util.HashMap<java.lang.String,ThresholdSource> thisMonitorValues)
Set the monitor values.
|
void |
setPossibleValues(java.util.HashMap<java.lang.String,ThresholdSource> thisPossibleValues)
Set the possible values.
|
void |
setReserve(ThresholdSource thisReserve)
Set the reserve source value.
|
protected java.util.ArrayList<java.lang.Object> |
sourcesToMoveDown(java.util.ArrayList<java.lang.Object> sources)
Decrement the sources in any of the structures if not the source type
and return any sources that now fall below the related threshold.
|
protected java.util.ArrayList<java.lang.Object> |
sourcesToMoveDown(int thresholdType,
java.util.ArrayList<java.lang.Object> sources)
Decrement the sources in the specified structure if not the source type
and return any sources that now fall below the threshold.
|
void |
storeNegatives(java.lang.Object source,
java.util.ArrayList<java.lang.Object> theSources)
Store the negative comparisons for the specified source reference.
|
void |
swapSources(int thresholdType,
java.lang.Object source1,
java.lang.Object source2)
Swap the specified sources from the specified level and level below.
|
void |
xmlToLinks(org.licas_xml.abs.Element linksElem)
Parse the xml-based description back into links for this structure.
|
protected LinkSpec linkSpec
protected float monitorThreshold
protected float linkThreshold
protected int possibleNumber
protected int monitorNumber
protected int linkNumber
protected int totalMovedUp
protected int totalMovedDown
protected int maxNegative
protected float increment
protected float incWeight
protected float decWeight
protected java.lang.String linkMethod
protected java.util.HashMap<java.lang.String,ThresholdSource> possibleValues
protected java.util.HashMap<java.lang.String,ThresholdSource> monitorValues
protected java.util.HashMap<java.lang.String,ThresholdSource> linkValues
protected java.util.HashMap<java.lang.String,java.lang.Long> timeStamps
protected java.util.ArrayList<java.lang.Object> updatedSources
protected ThresholdSource reserve
protected org.ai_heuristic.functs.FunctionActivate functionActive
protected Link parent
public Thresholds(LinkSpec thisLinkSpec) throws java.lang.Exception
Const
.DEFAULTMAXNEGATIVE
. The activation function is assumed to
be a FunctionLinear
type.thisLinkSpec
- the initial config specification.java.lang.Exception
- any error.public Thresholds(int thisMaxNegative, LinkSpec thisLinkSpec) throws java.lang.Exception
FunctionLinear
type.thisMaxNegative
- the maximum number of allowed negative entries.thisLinkSpec
- the initial config specification.java.lang.Exception
- any error.public Thresholds(int thisMaxNegative, LinkSpec thisLinkSpec, Link thisParent) throws java.lang.Exception
FunctionLinear
type.thisMaxNegative
- the maximum number of allowed negative entries.thisLinkSpec
- the initial config specification.thisParent
- the parent component.java.lang.Exception
- any error.protected void createActivationFunction() throws java.lang.Exception
java.lang.Exception
- any error.public void resetValues() throws java.lang.Exception
java.lang.Exception
- any error.public void resetRelated() throws java.lang.Exception
java.lang.Exception
- any error.public void resetUpdatedSources() throws java.lang.Exception
java.lang.Exception
- any error.public void storeNegatives(java.lang.Object source, java.util.ArrayList<java.lang.Object> theSources) throws java.lang.Exception
source
- the source key.theSources
- the negative sources to add.java.lang.Exception
- any error.public float incrementSource(int thresholdType, java.lang.Object source, long timeStamp) throws java.lang.Exception
thresholdType
- the level the source is stored at.source
- the source representation.timeStamp
- the current time.java.lang.Exception
- any error.protected float incrementSource(int thresholdType, java.lang.Object source) throws java.lang.Exception
thresholdType
- the level the source is stored at.source
- the source representation.java.lang.Exception
- any error.protected float activationValue(float sourceWeight) throws java.lang.Exception
sourceWeight
- the current value associated with the source.java.lang.Exception
- any error.public void incAndMoveSourceUp(java.lang.Object source, long timeStamp) throws java.lang.Exception
source
- the source representation.timeStamp
- the current time.java.lang.Exception
- any error.public void moveSourceUp(int thresholdType, java.lang.Object source, long timeStamp) throws java.lang.Exception
thresholdType
- the threshold level.source
- the source representation.timeStamp
- the time for a source move.java.lang.Exception
- any error.protected java.util.ArrayList<java.lang.Object> sourcesToMoveDown(java.util.ArrayList<java.lang.Object> sources) throws java.lang.Exception
sources
- the representations of the sources to add.java.lang.Exception
- any error.protected java.util.ArrayList<java.lang.Object> sourcesToMoveDown(int thresholdType, java.util.ArrayList<java.lang.Object> sources) throws java.lang.Exception
thresholdType
- the threshold type: link, monitor or possible.sources
- the representations of the sources to add.java.lang.Exception
- any error.public boolean moveSourceDown(java.lang.Object source) throws java.lang.Exception
source
- the source representation.java.lang.Exception
- any error.public boolean moveSourceDown(int thresholdType, java.lang.Object source) throws java.lang.Exception
thresholdType
- the threshold level.source
- the source representation.java.lang.Exception
- any error.public void swapSources(int thresholdType, java.lang.Object source1, java.lang.Object source2) throws java.lang.Exception
thresholdType
- the threshold level of the upper source.source1
- the source representation for the source at the upper level.source2
- the source representation for the source at the lower level.java.lang.Exception
- any error.public void removeSource(int thresholdType, java.lang.Object source) throws java.lang.Exception
thresholdType
- the threshold level.source
- the source representation.java.lang.Exception
- any error.public ThresholdSource getMinSource(int thresholdType) throws java.lang.Exception
thresholdType
- the threshold type.java.lang.Exception
- any error.public int getSourceLevel(java.lang.Object source) throws java.lang.Exception
source
- the source representation. An attempt is automatically made to
try to extract the source key or ID if it is a known source type. This is the
key value that it would be registered under in any linking structure. If a single
increment value is larger than a particular level, the level that the value
would place the link at is returned instead.java.lang.Exception
- any error.public int getSourceCount()
protected boolean contains(java.util.ArrayList<java.lang.Object> sources, java.lang.Object key) throws java.lang.Exception
sources
- the source representations.key
- the key value to match.java.lang.Exception
- any error.public void incrementReserve(long timeStamp) throws java.lang.Exception
timeStamp
- the current time.java.lang.Exception
- any error.public void decrementReserve(java.util.ArrayList<java.lang.Object> sources) throws java.lang.Exception
sources
- the source representations.java.lang.Exception
- any error.public void setReserve(ThresholdSource thisReserve) throws java.lang.Exception
thisReserve
- the value of reserve.java.lang.Exception
- any error.public ThresholdSource getReserve()
public void setLinkValues(java.util.HashMap<java.lang.String,ThresholdSource> thisLinkValues)
thisLinkValues
- the link values.public java.util.ArrayList<java.lang.Object> getLinkSources()
public java.util.ArrayList<java.lang.Object> getLinkSources(java.util.ArrayList<java.lang.Object> negativeSources) throws java.lang.Exception
negativeSources
- the list of negative sources, representing concept(parts). Can be null
.java.lang.Exception
- any error.public org.licas_xml.abs.Element linksToXml(boolean allLevels, boolean includeValues) throws java.lang.Exception
allLevels
- if true, return all 3 levels, if false only return the top link level
references.includeValues
- if true, return the weight and timestamp as well, if false,
return just the source references.java.lang.Exception
- any error.public void linksToString(java.util.HashMap<java.lang.String,java.lang.String> linkStrings, boolean allLevels) throws java.lang.Exception
linkStrings
- list of strings to add to.allLevels
- if true, return all 3 levels, if false only return the top link level
references.java.lang.Exception
- any error.public void xmlToLinks(org.licas_xml.abs.Element linksElem) throws java.lang.Exception
linksElem
- the links element that contains all link references.java.lang.Exception
- any error.public void setActivationFunction(org.ai_heuristic.functs.FunctionActivate thisFunctionActive)
thisFunctionActive
- the activation function.public org.ai_heuristic.functs.FunctionActivate getActivationFunction()
public void setLinkSpec(LinkSpec thisLinkSpec)
thisLinkSpec
- the config specification.public LinkSpec getLinkSpec()
protected float getDecrement()
public float getIncWeight()
public float getDecWeight()
public int getTotalMovedUp()
public int getTotalMovedDown()
public int getLinkCount()
public int getMonitorCount()
public int getPossibleCount()
public float getLinkThreshold()
public void changeLinkNumber(int changeNumber)
changeNumber
- the number to change by. Can be positive or negative.public int getLinkNumber()
public float getMonitorThreshold()
public void changeMonitorNumber(int changeNumber)
changeNumber
- the number to change by. Can be positive or negative.public int getMonitorNumber()
public void setMonitorValues(java.util.HashMap<java.lang.String,ThresholdSource> thisMonitorValues)
thisMonitorValues
- the monitor values.public java.util.HashMap<java.lang.String,ThresholdSource> getMonitorValues()
public void changePossibleNumber(int changeNumber)
changeNumber
- the number to change by. Can be positive or negative.public int getPossibleNumber()
public void setPossibleValues(java.util.HashMap<java.lang.String,ThresholdSource> thisPossibleValues)
thisPossibleValues
- the possible values.public java.util.HashMap<java.lang.String,ThresholdSource> getPossibleValues()
public float getIncrement()
public java.lang.String getLinkMethod()
public org.ai_heuristic.functs.FunctionActivate cloneFunction() throws java.lang.Exception
newInstance
method, or null is none exists.java.lang.Exception
- any error.