public abstract class OntologySolverBase extends MoMLModelAttribute
The base class provides the core functionality for ontology solver resolution. It provides a method to create an OntologyAdapter for any given model component. The model component can be an object of any Ptolemy class (e.g. ASTPtRootNode, Sink, Entity, and FSMActor). A model component, in turn, may have one or multiple objects to which ontology concepts can be attached.
Subclasses needs to implement resolveConcepts()
to specify exactly how to perform the ontology concept resolution. For example,
one may gather all the constraints from the OntologyAdapters and feed them
into a constraint solver.
Every OntologySolver is linked together by the SharedParameter called "ontologySolverUtilitiesWrapper", which contains the shared utility object. This allows every OntologySolver to find other solvers in the model.
Red (mankit) |
Red (mankit) |
NamedObj.ContainedObjectsIterator
Modifier and Type | Field and Description |
---|---|
protected java.util.HashMap<java.lang.Object,OntologyAdapter> |
_adapterStore
The HashMap that caches components and their PropertyAdapter objects.
|
protected java.util.HashSet<java.lang.Object> |
_nonSettables
The set of property-able objects that have non-settable property.
|
protected OntologySolverUtilities |
_ontologySolverUtilities
The utilities shared between all solvers.
|
protected java.util.HashMap<java.lang.Object,Concept> |
_resolvedProperties
The HashMap that caches property-able objects and their
Property values.
|
SharedParameter |
ontologySolverUtilitiesWrapper
The shared parameter that links together every solver in the
same model.
|
_model, modelURL
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
Constructor and Description |
---|
OntologySolverBase(NamedObj container,
java.lang.String name)
Construct an OntologySolverBase with the specified container and
name.
|
Modifier and Type | Method and Description |
---|---|
protected static OntologyAdapter |
_getAdapter(java.lang.Object component,
OntologySolverBase solver)
Return the PropertyAdapter for the specified component.
|
protected static java.lang.String |
_getPackageName(OntologySolverBase solver)
Return the package name that contains the class of this solver.
|
protected NamedObj |
_toplevel()
Return the top level of the model hierarchy for the model
we want to analyze.
|
static void |
cleanConstants()
Traverse the list of constants and remove any ConceptTokens
that may have been added by MonotonicyConceptFunction.
|
void |
clearResolvedConcept(java.lang.Object object)
Clear the resolved property for the specified object.
|
java.lang.Object |
clone(Workspace workspace)
Clone the object into the specified workspace.
|
OntologyAdapter |
getAdapter(java.lang.Object object)
Return the property adapter for the specified component.
|
java.util.List<OntologyAdapter> |
getAllAdapters()
Return the list of all PropertyAdapters associated with this
ontology solver.
|
java.util.Set<NamedObj> |
getAllConceptableNamedObjs()
Return the subset of all concept-able objects that are NamedObjs.
|
java.util.List<Ontology> |
getAllContainedOntologies()
Return a list of all the ontologies contained in this solver.
|
java.util.Set |
getAllPropertyables()
Return the set of all property-able objects obtained from
all PropertyAdapter.
|
static java.util.List<OntologySolver> |
getAllSolvers(SharedParameter sharedParameter)
Return the list of all solvers that are in the same model.
|
Attribute |
getAttribute(ASTPtRootNode node)
Get the attribute that corresponds to the specified
ASTPtRootNode.
|
Concept |
getConcept(java.lang.Object object)
Return the concept value associated with the specified object.
|
Ontology |
getOntology()
Return the ontology for this constraint solver.
|
OntologySolverUtilities |
getOntologySolverUtilities()
Return the shared utility object.
|
PtParser |
getParser()
Return the expression parser.
|
ASTPtRootNode |
getParseTree(Attribute attribute)
Return the root ASTPtRootNode associated with the specified
attribute.
|
void |
initialize()
Initialize the solver.
|
void |
markAsNonSettable(java.lang.Object object)
Mark the property of the specified object as non-settable.
|
void |
reset()
Reset the solver.
|
void |
resetAll()
Reset every solver in the model.
|
abstract void |
resolveConcepts()
Execute the OntologySolver's algorithm to resolve
which Concepts in the Ontology are assigned to each object in the
model.
|
void |
setConcept(java.lang.Object object,
Concept property)
Set the resolved property of the specified object.
|
void |
setOntologySolverUtilities(OntologySolverUtilities solverUtilities)
Set the shared utility object to the given object.
|
_exportMoMLContents, attributeChanged, configure, getConfigureSource, getConfigureText, getContainedModel
_checkContainer, _getContainedObject, _propagateExistence, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setContainer, setName, updateContent
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _description, _executeChangeRequests, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getElementName, getFullName, getModelErrorHandler, getName, getName, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateExistence, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, uniqueName, validateSettables, workspace
public SharedParameter ontologySolverUtilitiesWrapper
protected java.util.HashMap<java.lang.Object,OntologyAdapter> _adapterStore
protected java.util.HashSet<java.lang.Object> _nonSettables
protected java.util.HashMap<java.lang.Object,Concept> _resolvedProperties
protected OntologySolverUtilities _ontologySolverUtilities
public OntologySolverBase(NamedObj container, java.lang.String name) throws IllegalActionException, NameDuplicationException
container
- The specified container.name
- The specified name.IllegalActionException
- If the OntologySolverBase is
not of an acceptable attribute for the container.NameDuplicationException
- If the name coincides with an
attribute already in the container.public void clearResolvedConcept(java.lang.Object object)
object
- The specified object.public static void cleanConstants()
MonotonicityConceptFunction
public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
clone
in class MoMLModelAttribute
workspace
- The workspace for the new object.java.lang.CloneNotSupportedException
- If any of the attributes
cannot be cloned.NamedObj.exportMoML(Writer, int, String)
,
NamedObj.setDeferringChangeRequests(boolean)
public java.util.List<OntologyAdapter> getAllAdapters() throws IllegalActionException
IllegalActionException
- If there is an exception from getting
all the subAdapters.public java.util.Set<NamedObj> getAllConceptableNamedObjs() throws IllegalActionException
IllegalActionException
- Thrown if
an error occurs when getting the adapters or the concept-able
objects from them.public java.util.Set getAllPropertyables() throws IllegalActionException
IllegalActionException
- Thrown if
an error occurs when getting the adapters or the property-able
objects from them.public static java.util.List<OntologySolver> getAllSolvers(SharedParameter sharedParameter)
sharedParameter
- The specified SharedParameter links
together the solvers.public Attribute getAttribute(ASTPtRootNode node)
OntologySolverUtilities.putAttribute(ASTPtRootNode, Attribute)
.node
- The specified ASTPtRootNode.java.lang.AssertionError
- Thrown if the specified node does not
have a corresponding attribute.public OntologyAdapter getAdapter(java.lang.Object object) throws IllegalActionException
object
- The specified component.IllegalActionException
- Thrown if the adapter cannot
be found or instantiated.public java.util.List<Ontology> getAllContainedOntologies()
public Ontology getOntology() throws IllegalActionException
IllegalActionException
- If the structure is not a lattice.public PtParser getParser()
public ASTPtRootNode getParseTree(Attribute attribute) throws IllegalActionException
attribute
- The specified attribute.IllegalActionException
- Thrown if there is a problem getting
the parse tree.public Concept getConcept(java.lang.Object object)
object
- The specified object.setConcept(Object, Concept)
public OntologySolverUtilities getOntologySolverUtilities()
setOntologySolverUtilities(ptolemy.data.ontologies.OntologySolverUtilities)
public void initialize() throws IllegalActionException
IllegalActionException
- Thrown if there is a problem
initializing the solver.public void markAsNonSettable(java.lang.Object object)
object
- The specified object.public void reset()
public void resetAll()
public abstract void resolveConcepts() throws IllegalActionException
IllegalActionException
- If the ontology resolution fails.public void setOntologySolverUtilities(OntologySolverUtilities solverUtilities)
solverUtilities
- The given ontology solver utilities object.getOntologySolverUtilities()
public void setConcept(java.lang.Object object, Concept property)
object
- The specified object.property
- The specified property.getConcept(Object)
protected static OntologyAdapter _getAdapter(java.lang.Object component, OntologySolverBase solver) throws IllegalActionException
component
- The specified component.solver
- The solver for which to get the adapter.IllegalActionException
- Thrown if the PropertyAdapter
cannot be instantiated.protected static java.lang.String _getPackageName(OntologySolverBase solver) throws IllegalActionException
solver
- The ontology solver for which we get the adapter package name.IllegalActionException
- Thrown if there is a problem
getting the ontology package name.protected NamedObj _toplevel()