Package com.semedy.reasoner.reasoning
Class ReasonerThreadedRulesPartitioning
java.lang.Object
com.semedy.reasoner.reasoning.ReasonerThreadedRulesPartitioning
- All Implemented Interfaces:
Reasoner
Threaded reasoner
- Author:
- angele
-
Constructor Summary
ConstructorsConstructorDescriptionReasonerThreadedRulesPartitioning(InterruptFlag interruptFlag, SymbolTable symboltable, BuiltinProvider builtinFactory, int reasoningthreads, boolean skipAnswers, int maxNumberOfResults, ReasoningMonitor monitor, boolean cepReasoning, boolean cepReasoningWithRetracts, String tempDir, boolean swapping, Properties builtinProperties, int pulsedTuples, boolean sorted) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the reasoner.voidcompile(IntensionalDB idb, ExtensionalDB[] edbs, ReasoningMonitor monitor, SystemMonitor smonitor, boolean topdown, int maxNumberOfResults, boolean cepReasoningWithRetracts, boolean cepReasoning) compile rules for the reasoning processevaluate()starts evaluation and returns iterators for the results of the evaluationevaluate(ReasoningMonitor monitor) voidStarts evaluation and feed the results into receiverStarts evaluation for several queries.voidIs called after reasoning process is finishedget queries after compilationReturns the reasoning symbol table used to create new symbols during reasoning
This reasoning symbol table is different to the base symbol table given by core.getSymbolTable()
To decode reasoning results always use this onevoidregister(EventResultReceiver receiver) voidregister(InterruptFlag interruptFlag, List<EventResultReceiver> receiver) voidregister(InterruptFlag interruptFlag, List<EventResultReceiver> receiver, CoreReadLock edbReadLock) Register several queries for events caused by sensors or in case of
stream reasoning db caused by added facts.
Every time events from sensors arrive there might be one or more new results.
For every result receiver.receive is called
This is used for stream reasoningvoidregister(InterruptFlag interruptFlag, List<EventResultReceiver> receiver, CoreReadLock edbReadLock, SimpleSemaphore semaphore) voidregister(InterruptFlag interruptFlag, List<EventResultReceiver> receiver, SimpleSemaphore semaphore) booleanHave results contained whole edb relations?booleantest(Reader in, SymbolTable baseTable, ExternalDataTypeProvider datatypes, ExtensionalDB edb, boolean topdown, String path, BuiltinProvider builtinProvider, RewriterProvider rewriterProvider, Configuration config, Properties prp) Testing the evaluation.
-
Constructor Details
-
ReasonerThreadedRulesPartitioning
public ReasonerThreadedRulesPartitioning(InterruptFlag interruptFlag, SymbolTable symboltable, BuiltinProvider builtinFactory, int reasoningthreads, boolean skipAnswers, int maxNumberOfResults, ReasoningMonitor monitor, boolean cepReasoning, boolean cepReasoningWithRetracts, String tempDir, boolean swapping, Properties builtinProperties, int pulsedTuples, boolean sorted)
-
-
Method Details
-
test
public boolean test(Reader in, SymbolTable baseTable, ExternalDataTypeProvider datatypes, ExtensionalDB edb, boolean topdown, String path, BuiltinProvider builtinProvider, RewriterProvider rewriterProvider, Configuration config, Properties prp) throws ReasoningException Description copied from interface:ReasonerTesting the evaluation.
The file contains rules and facts and solutions.
Solutions are given by the solutions predicate.
This method reads the file, stores the facts in an edb,
stores the rules in an idb, compiles and evaluates
the query and compares the results to the solutions- Specified by:
testin interfaceReasoner- Parameters:
in- , reader for e.g. a filebaseTable- , symbol tableedb- , extensional databasetopdown- , top down evaluation (magic sets)path- , path to edbbuiltinProvider- , provides builtinsrewriterProvider- , provides rewritersconfig- , a configurationprp- , builtin properties- Returns:
- true, if results of evaluation are the same as the solutions inside the file
- Throws:
ReasoningException
-
evaluate
public List<TupleEnumerator> evaluate(ReasoningMonitor monitor) throws InterruptedException, IOException, SemReasonerException -
evaluate
public void evaluate(Receiver receiver) throws InterruptedException, IOException, SemReasonerException Description copied from interface:ReasonerStarts evaluation and feed the results into receiver- Specified by:
evaluatein interfaceReasoner- Parameters:
receiver- , the results are sent to receiver- Throws:
InterruptedExceptionIOExceptionReasoningExceptionSemReasonerException
-
evaluate
public List<TupleEnumerator> evaluate() throws InterruptedException, IOException, SemReasonerExceptionDescription copied from interface:Reasonerstarts evaluation and returns iterators for the results of the evaluation- Specified by:
evaluatein interfaceReasoner- Returns:
- iterator for results
- Throws:
InterruptedExceptionIOExceptionReasoningExceptionSemReasonerException
-
close
Description copied from interface:ReasonerClose the reasoner. Must be called to correctly finalize the reasoner- Specified by:
closein interfaceReasoner- Throws:
ReasoningExceptionInterruptedException
-
getSymbolTable
Description copied from interface:ReasonerReturns the reasoning symbol table used to create new symbols during reasoning
This reasoning symbol table is different to the base symbol table given by core.getSymbolTable()
To decode reasoning results always use this one- Specified by:
getSymbolTablein interfaceReasoner- Returns:
-
compile
public void compile(IntensionalDB idb, ExtensionalDB[] edbs, ReasoningMonitor monitor, SystemMonitor smonitor, boolean topdown, int maxNumberOfResults, boolean cepReasoningWithRetracts, boolean cepReasoning) throws InterruptedException, IOException, SemReasonerException Description copied from interface:Reasonercompile rules for the reasoning process- Specified by:
compilein interfaceReasoner- Parameters:
idb- , intensional dbedbs- extensional dbsmonitor- , monitoring reasoning and memory consumptionsmonitor- , system monitor, used by system may be nulltopdown- , execution is done top down (magic sets)cepReasoningWithRetracts- , stream reasoning is donecepReasoning- , retracts in stream reasoning- Throws:
InterruptedExceptionIOExceptionSemReasonerException
-
register
-
evaluateSeveralQueries
public List<List<TupleEnumerator>> evaluateSeveralQueries() throws InterruptedException, ReasoningExceptionDescription copied from interface:ReasonerStarts evaluation for several queries.
For every query a list of iterators for the results is returned.- Specified by:
evaluateSeveralQueriesin interfaceReasoner- Returns:
- , list of tuple enumerators for results
- Throws:
InterruptedExceptionReasoningException
-
register
-
register
public void register(InterruptFlag interruptFlag, List<EventResultReceiver> receiver, SimpleSemaphore semaphore) -
register
public void register(InterruptFlag interruptFlag, List<EventResultReceiver> receiver, CoreReadLock edbReadLock) throws InterruptedException, ReasoningException Description copied from interface:ReasonerRegister several queries for events caused by sensors or in case of
stream reasoning db caused by added facts.
Every time events from sensors arrive there might be one or more new results.
For every result receiver.receive is called
This is used for stream reasoning- Specified by:
registerin interfaceReasoner- Parameters:
interruptFlag- , interruptedbReadLock- , the read lock for the extensional db, used during reasoning- Throws:
InterruptedExceptionReasoningException
-
register
public void register(InterruptFlag interruptFlag, List<EventResultReceiver> receiver, CoreReadLock edbReadLock, SimpleSemaphore semaphore) -
evaluationFinished
Description copied from interface:ReasonerIs called after reasoning process is finished- Specified by:
evaluationFinishedin interfaceReasoner- Throws:
ReasoningExceptionIOException
-
resultsContainedEDBRelations
public boolean resultsContainedEDBRelations()Description copied from interface:ReasonerHave results contained whole edb relations?- Specified by:
resultsContainedEDBRelationsin interfaceReasoner- Returns:
-
getQueries
Description copied from interface:Reasonerget queries after compilation- Specified by:
getQueriesin interfaceReasoner- Returns:
-