Package com.semedy.reasoner.exercises
Class Mean
java.lang.Object
com.semedy.reasoner.exercises.Mean
- All Implemented Interfaces:
Aggregation,Builtin
An example for a built-in (aggregation) which computes the mean value out of the input values
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()frees up allocated resourcesclone the builtinbooleanaggregation delivers only one result at argument position.voidevaluate(BuiltinReceiver receiver) Evaluate the aggregation.voidcall back function.String[]get descriptions for the different argumentsintgetArity()get the arity of the builtinget a description for the builtingetName()get the name of the builtingetType()get the type of the builtinlongthe weight of the builtin.voidinitialize the builtinvoidinput(long[] input) feed aggregation with input tuplebooleanisEvaluable(BitSet grounds, BitSet variableInstantiations, Object[] args) is builtin evaluable with a certain instantiation of variablesbooleanis it a builtin for internal use onlyobjectGeneratingArguments(BitSet grounds, BitSet variableInstantiations, Object[] args) In which argument position are new objects createdbooleandoes the builtin read the symbol tablevoidsetProperties(Properties prp) set the sytem propertiesvoidsetSymbolTable(SymbolTable symbolTable) set the symbol tablevoidstart feeding the aggregation with input.voidstop()stop feeding the aggregation with inputbooleandoes the builtin write into the symbol table
-
Constructor Details
-
Mean
public Mean()
-
-
Method Details
-
isEvaluable
public boolean isEvaluable(BitSet grounds, BitSet variableInstantiations, Object[] args) throws BuiltinException Description copied from interface:Builtinis builtin evaluable with a certain instantiation of variables- Specified by:
isEvaluablein interfaceBuiltin- Parameters:
grounds- , which arguments are groundvariableInstantiations- , which variables are instantiatedargs- , the arguments- Returns:
- was it evaluable
- Throws:
BuiltinException
-
init
Description copied from interface:Builtininitialize the builtin- Specified by:
initin interfaceBuiltin- Parameters:
args- , the builtin arguments- Throws:
InterruptedExceptionBuiltinException
-
evaluationFinished
Description copied from interface:Builtincall back function. Is called when the whole evaluation has been finished- Specified by:
evaluationFinishedin interfaceBuiltin- Throws:
BuiltinExceptionInterruptedException
-
setSymbolTable
Description copied from interface:Builtinset the symbol table- Specified by:
setSymbolTablein interfaceBuiltin- Parameters:
symbolTable- , the symbol table
-
getWeight
Description copied from interface:Builtinthe weight of the builtin. Determines when the builtin is executed in a rule -
objectGeneratingArguments
public BitSet objectGeneratingArguments(BitSet grounds, BitSet variableInstantiations, Object[] args) throws BuiltinException Description copied from interface:BuiltinIn which argument position are new objects created- Specified by:
objectGeneratingArgumentsin interfaceBuiltin- Parameters:
grounds- , ground argument positionsvariableInstantiations- , instantiated variablesargs- , arguments of the literal- Returns:
- each bit indicates the argument position where new objects are created
- Throws:
BuiltinException
-
getName
Description copied from interface:Builtinget the name of the builtin -
getArity
public int getArity()Description copied from interface:Builtinget the arity of the builtin -
getType
Description copied from interface:Builtinget the type of the builtin -
isInternal
public boolean isInternal()Description copied from interface:Builtinis it a builtin for internal use only- Specified by:
isInternalin interfaceBuiltin- Returns:
-
getArgumentDescriptions
Description copied from interface:Builtinget descriptions for the different arguments- Specified by:
getArgumentDescriptionsin interfaceBuiltin- Returns:
- a description of the arguments of the built-in
-
getDescription
Description copied from interface:Builtinget a description for the builtin- Specified by:
getDescriptionin interfaceBuiltin- Returns:
- a description of the built-in
-
readsSymbolTable
public boolean readsSymbolTable()Description copied from interface:Builtindoes the builtin read the symbol table- Specified by:
readsSymbolTablein interfaceBuiltin- Returns:
- true if it reads the symbol table
-
writesSymbolTable
public boolean writesSymbolTable()Description copied from interface:Builtindoes the builtin write into the symbol table- Specified by:
writesSymbolTablein interfaceBuiltin- Returns:
- true if it writes to the symbol table
-
start
Description copied from interface:Aggregationstart feeding the aggregation with input. Grounds indicates which arguments are ground- Specified by:
startin interfaceAggregation- Parameters:
grounds- , which arguments must be instantiated- Throws:
InterruptedExceptionReasoningException
-
input
Description copied from interface:Aggregationfeed aggregation with input tuple- Specified by:
inputin interfaceAggregation- Parameters:
input- , the coded input tuple- Throws:
InterruptedExceptionIOExceptionSemReasonerException
-
stop
Description copied from interface:Aggregationstop feeding the aggregation with input- Specified by:
stopin interfaceAggregation- Throws:
InterruptedExceptionReasoningException
-
evaluate
public void evaluate(BuiltinReceiver receiver) throws InterruptedException, IOException, EDBException, SemReasonerException Description copied from interface:AggregationEvaluate the aggregation.
For every result tuple the method "send" in receiver is called- Specified by:
evaluatein interfaceAggregation- Parameters:
receiver- , the receiver getting the results- Throws:
InterruptedExceptionIOExceptionSemReasonerExceptionEDBException
-
cloneBuiltin
Description copied from interface:Builtinclone the builtin- Specified by:
cloneBuiltinin interfaceBuiltin- Returns:
- the cloned built-in
-
deliversOneResultOnly
public boolean deliversOneResultOnly()Description copied from interface:Aggregationaggregation delivers only one result at argument position.
For instance count delivers one result at argument position 1.- Specified by:
deliversOneResultOnlyin interfaceAggregation- Returns:
- true if it delivers one result only
-
setProperties
Description copied from interface:Builtinset the sytem properties- Specified by:
setPropertiesin interfaceBuiltin- Parameters:
prp- , properties
-
clear
public void clear()Description copied from interface:Builtinfrees up allocated resources
-