public abstract class InferenceAlgorithm
extends java.lang.Object
runRules(Table t) method that processes rules within a table, handles conflict set and so on,
initStackForAttributes(heart.inference.InferenceAlgorithm.AttributeParameters) that prepares initial stack for a given attribute that should be processed to obtain the attribute value,
initStackForTables(heart.inference.InferenceAlgorithm.TableParameters) that prepares initial stack for tables that should be processed.
There are also two methods onPreExecute() and onPostExecute(), which defined actions which
should be performed before and after inference.
The original implementation performs locking and unlocking time in WorkingMemory object, and thus
even while overriding this methods a super implementation should always be called first.
The intentional use of Inference algorithm is new InferenceAlgorithm(...).start(...),
which is similar to running Threads in Java.| Modifier and Type | Class and Description |
|---|---|
static class |
InferenceAlgorithm.AttributeParameters |
static class |
InferenceAlgorithm.TableParameters |
| Constructor and Description |
|---|
InferenceAlgorithm(WorkingMemory wm,
XTTModel model,
Configuration conf)
The constructor that collect all the required information for the inference process to be executed.
|
| Modifier and Type | Method and Description |
|---|---|
Configuration |
getConf() |
XTTModel |
getModel() |
java.util.Stack<Table> |
getTablesToFire() |
WorkingMemory |
getWm() |
protected abstract java.util.Stack<Table> |
initStackForAttributes(InferenceAlgorithm.AttributeParameters attributeParameters)
The method creates an initial stack of Tables that should be processed by the
runRules(Table t) method. |
protected abstract java.util.Stack<Table> |
initStackForTables(InferenceAlgorithm.TableParameters tableParameters)
The method creates an initial stack of Tables that should be processed by the
runRules(Table t) method
This is only an initial state and it can be modified during the inference. |
boolean |
isTableStackEmpty()
It checks if the table stack is empty
|
void |
onPostExecute()
This methods contains all operations that should be performed after inference process starts.
|
void |
onPreExecute()
This methods contains all operations that should be performed before inference process starts.
|
Table |
peakTable()
It returned first Table form the stack without removeing it.
|
Table |
popTable()
It removes the first Table from stack and returns it.
|
Table |
pushTable(Table t)
The method pushes Table given as a parameter to the stack.
|
protected void |
runRules(Table table)
The method that is called to perform inference.
|
void |
setConf(Configuration conf) |
void |
setModel(XTTModel model) |
void |
setTablesToFire(java.util.Stack<Table> tablesToFire) |
void |
setWm(WorkingMemory wm) |
void |
start(InferenceAlgorithm.AttributeParameters ap)
A method that executes all the inference methods in the following order:
onPreExecute(),
then initStackForAttributes(heart.inference.InferenceAlgorithm.AttributeParameters) i}
is called to create the staring point for the algorithm,
then, in a loop, runRules(Table t) until there are tables on the stack,
and after the loop is finished onPostExecute() |
void |
start(InferenceAlgorithm.TableParameters tp)
A method that executes all the inference methods in the following order:
onPreExecute(),
then initStackForTables(heart.inference.InferenceAlgorithm.TableParameters)
is called to create the staring point for the algorithm,
then, in a loop, runRules(Table t) until there are tables on the stack,
and after the loop is finished onPostExecute() |
public InferenceAlgorithm(WorkingMemory wm, XTTModel model, Configuration conf)
wm - a WorkingMemory element from HeaRT inference enginemodel - a XTTModel that will be used to infer dataconf - a Configuration object defining uncertainty handling mechanism, conflict set resolution,
initial state and others.public void onPreExecute()
public void onPostExecute()
public Table pushTable(Table t)
t - table to be pushed to the stackpublic Table popTable()
public Table peakTable()
public boolean isTableStackEmpty()
protected void runRules(Table table) throws InferenceInterruptedException, java.lang.UnsupportedOperationException
or
{@link #start(heart.inference.InferenceAlgorithm.AttributeParameters)} method should be usedtable - an XTT2 table form the model which rules should be processedInferenceInterruptedException - the exception that should be thrown in order to stop processing current table
and move to another table from the stackjava.lang.UnsupportedOperationExceptionprotected abstract java.util.Stack<Table> initStackForAttributes(InferenceAlgorithm.AttributeParameters attributeParameters)
runRules(Table t) method.
This is only an initial state and it can be modified during the inference. However for some inference modes
this initial stack will be the final.attributeParameters - attributes names which values should be obtain in the inference processrunRules(Table t) method.protected abstract java.util.Stack<Table> initStackForTables(InferenceAlgorithm.TableParameters tableParameters)
runRules(Table t) method
This is only an initial state and it can be modified during the inference. However for some inference modes
this initial stack will be the final.tableParameters - tables names that are the parameters to the inference engine.
This could mean different things in different reasoning modes.runRules(Table t) method.public final void start(InferenceAlgorithm.AttributeParameters ap)
onPreExecute(),
then initStackForAttributes(heart.inference.InferenceAlgorithm.AttributeParameters) i}
is called to create the staring point for the algorithm,
then, in a loop, runRules(Table t) until there are tables on the stack,
and after the loop is finished onPostExecute()ap - attributes names which values should be obtain in the inference processpublic final void start(InferenceAlgorithm.TableParameters tp)
onPreExecute(),
then initStackForTables(heart.inference.InferenceAlgorithm.TableParameters)
is called to create the staring point for the algorithm,
then, in a loop, runRules(Table t) until there are tables on the stack,
and after the loop is finished onPostExecute()tp - tables names that are the parameters to the inference engine.
This could mean different things in different reasoning modes.public WorkingMemory getWm()
public void setWm(WorkingMemory wm)
public XTTModel getModel()
public void setModel(XTTModel model)
public Configuration getConf()
public void setConf(Configuration conf)
public java.util.Stack<Table> getTablesToFire()
public void setTablesToFire(java.util.Stack<Table> tablesToFire)