public class ExpressionConceptFunction extends ConceptFunction
This is a class for concept functions that are used specified using an expression from a ConceptFunctionDefinitionAttribute. The expression is evaluated with the input arguments to evaluate the concept function.
An expression that represents a concept function is a boolean if-then expression
that has multiple conditional statements that specifies the output concept value
based on the input concept valuesof the arguments. Example: consider a function
that has two arguments arg1 and arg2, and each argument can be a concept from
the DimensionSystem ontology which has the possible Concept values:
{Unknown, Dimensionless, Time, Position, Velocity, Acceleration, Conflict}
A valid expression concept function could be defined like this:
f(arg1, arg2) =
arg1 == Unknown || arg2 == Unknown ? Unknown :
arg1 == Position && arg2 == Time ? Velocity :
arg1 == Velocity && arg2 == Time ? Acceleration :
Conflict
This expression function specifies that the output of the function is Unknown if either argument is Unknown, Velocity if arg1 is Position and arg2 is Time, Acceleration if arg1 is Velocity and arg2 is Time, and Conflict if arg1 and arg2 are any other combination of concept values.
_argumentDomainOntologies, _name, _numArgsIsFixed, _outputRangeOntology
Constructor and Description |
---|
ExpressionConceptFunction(java.lang.String name,
boolean numArgsIsFixed,
java.util.List<Ontology> argumentDomainOntologies,
Ontology outputRangeOntology,
java.util.List<java.lang.String> argumentNames,
java.lang.String conceptFunctionExpression,
OntologySolverModel solverModel,
NamedObj functionScopeModelElement)
Initialize the expression concept function with the number of
arguments it takes, the ontologies from which input and output
concepts can be taken, the name of the function, and the
string boolean expression that defines the function.
|
Modifier and Type | Method and Description |
---|---|
protected Concept |
_evaluateFunction(java.util.List<Concept> inputConceptValues)
Return the output of the concept function based on the concept
inputs.
|
evaluateFunction, getArgumentDomainOntologies, getName, getNumberOfArguments, getOutputRangeOntology, isMonotonic, isNumberOfArgumentsFixed, toString
public ExpressionConceptFunction(java.lang.String name, boolean numArgsIsFixed, java.util.List<Ontology> argumentDomainOntologies, Ontology outputRangeOntology, java.util.List<java.lang.String> argumentNames, java.lang.String conceptFunctionExpression, OntologySolverModel solverModel, NamedObj functionScopeModelElement) throws IllegalActionException
numArgsIsFixed
- True if the number of arguments for this function
is fixed and cannot change, false otherwise.argumentDomainOntologies
- The array of ontologies that
represent the concept domain for each input concept argument.outputRangeOntology
- The ontology that represents the
range of output concepts for this concept function.name
- The string name used to identify this concept function.argumentNames
- The list of strings that represent the
names of the arguments to be used in parsing the concept
function expression.conceptFunctionExpression
- A string representing the
boolean expression that defines the concept function.solverModel
- The ontology solver model that contains
other concept function definitions that could be called by
the function defined in this expression.functionScopeModelElement
- knk.IllegalActionException
- If the ontology inputs are null
or the length of the array of domain ontologies does not
match the number of arguments for the function.protected Concept _evaluateFunction(java.util.List<Concept> inputConceptValues) throws IllegalActionException
_evaluateFunction
in class ConceptFunction
inputConceptValues
- The array of concept inputs to the function.IllegalActionException
- If there is an error
evaluating the function.