Class OntologySolverBase
- java.lang.Object
- 
- ptolemy.kernel.util.NamedObj
- 
- ptolemy.kernel.util.Attribute
- 
- ptolemy.moml.MoMLModelAttribute
- 
- ptolemy.data.ontologies.OntologySolverBase
 
 
 
 
- 
- All Implemented Interfaces:
- java.lang.Cloneable,- Changeable,- Configurable,- Debuggable,- DebugListener,- Derivable,- ModelErrorHandler,- MoMLExportable,- Moveable,- Nameable
 - Direct Known Subclasses:
- OntologySolver
 
 public abstract class OntologySolverBase extends MoMLModelAttribute The base abstract class for an ontology solver.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. - Since:
- Ptolemy II 10.0
- Version:
- $Id$
- Author:
- Man-Kit Leung
- Pt.AcceptedRating:
- Red (mankit)
- Pt.ProposedRating:
- Red (mankit)
 
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObjNamedObj.ContainedObjectsIterator
 
- 
 - 
Field SummaryFields Modifier and Type Field Description protected java.util.HashMap<java.lang.Object,OntologyAdapter>_adapterStoreThe HashMap that caches components and their PropertyAdapter objects.protected java.util.HashSet<java.lang.Object>_nonSettablesThe set of property-able objects that have non-settable property.protected OntologySolverUtilities_ontologySolverUtilitiesThe utilities shared between all solvers.protected java.util.HashMap<java.lang.Object,Concept>_resolvedPropertiesThe HashMap that caches property-able objects and their Property values.SharedParameterontologySolverUtilitiesWrapperThe shared parameter that links together every solver in the same model.- 
Fields inherited from class ptolemy.moml.MoMLModelAttribute_model, modelURL
 - 
Fields inherited from class ptolemy.kernel.util.NamedObj_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
 
- 
 - 
Constructor SummaryConstructors Constructor Description OntologySolverBase(NamedObj container, java.lang.String name)Construct an OntologySolverBase with the specified container and name.
 - 
Method SummaryAll Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method 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 voidcleanConstants()Traverse the list of constants and remove any ConceptTokens that may have been added by MonotonicyConceptFunction.voidclearResolvedConcept(java.lang.Object object)Clear the resolved property for the specified object.java.lang.Objectclone(Workspace workspace)Clone the object into the specified workspace.OntologyAdaptergetAdapter(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.SetgetAllPropertyables()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.AttributegetAttribute(ASTPtRootNode node)Get the attribute that corresponds to the specified ASTPtRootNode.ConceptgetConcept(java.lang.Object object)Return the concept value associated with the specified object.OntologygetOntology()Return the ontology for this constraint solver.OntologySolverUtilitiesgetOntologySolverUtilities()Return the shared utility object.PtParsergetParser()Return the expression parser.ASTPtRootNodegetParseTree(Attribute attribute)Return the root ASTPtRootNode associated with the specified attribute.voidinitialize()Initialize the solver.voidmarkAsNonSettable(java.lang.Object object)Mark the property of the specified object as non-settable.voidreset()Reset the solver.voidresetAll()Reset every solver in the model.abstract voidresolveConcepts()Execute the OntologySolver's algorithm to resolve which Concepts in the Ontology are assigned to each object in the model.voidsetConcept(java.lang.Object object, Concept property)Set the resolved property of the specified object.voidsetOntologySolverUtilities(OntologySolverUtilities solverUtilities)Set the shared utility object to the given object.- 
Methods inherited from class ptolemy.moml.MoMLModelAttribute_exportMoMLContents, attributeChanged, configure, getConfigureSource, getConfigureText, getContainedModel
 - 
Methods inherited from class ptolemy.kernel.util.Attribute_checkContainer, _getContainedObject, _propagateExistence, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setContainer, setName, updateContent
 - 
Methods inherited from class ptolemy.kernel.util.NamedObj_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
 
- 
 
- 
- 
- 
Field Detail- 
ontologySolverUtilitiesWrapperpublic SharedParameter ontologySolverUtilitiesWrapper The shared parameter that links together every solver in the same model.
 - 
_adapterStoreprotected java.util.HashMap<java.lang.Object,OntologyAdapter> _adapterStore The HashMap that caches components and their PropertyAdapter objects.
 - 
_nonSettablesprotected java.util.HashSet<java.lang.Object> _nonSettables The set of property-able objects that have non-settable property. A non-settable property results from setting an object with a fixed property through PropertyAdapter.setEquals().
 - 
_resolvedPropertiesprotected java.util.HashMap<java.lang.Object,Concept> _resolvedProperties The HashMap that caches property-able objects and their Property values. Each mapping is a pair of Object and Property.
 - 
_ontologySolverUtilitiesprotected OntologySolverUtilities _ontologySolverUtilities The utilities shared between all solvers.
 
- 
 - 
Constructor Detail- 
OntologySolverBasepublic OntologySolverBase(NamedObj container, java.lang.String name) throws IllegalActionException, NameDuplicationException Construct an OntologySolverBase with the specified container and name. If this is the first OntologySolver created in the model, the shared utility object will also be created.- Parameters:
- container- The specified container.
- name- The specified name.
- Throws:
- 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.
 
 
- 
 - 
Method Detail- 
clearResolvedConceptpublic void clearResolvedConcept(java.lang.Object object) Clear the resolved property for the specified object. The object is assumed to be property-able; otherwise, nothing happens.- Parameters:
- object- The specified object.
 
 - 
cleanConstantspublic static void cleanConstants() Traverse the list of constants and remove any ConceptTokens that may have been added by MonotonicyConceptFunction.- See Also:
- MonotonicityConceptFunction
 
 - 
clonepublic java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException Clone the object into the specified workspace.- Overrides:
- clonein class- MoMLModelAttribute
- Parameters:
- workspace- The workspace for the new object.
- Returns:
- A new NamedObj.
- Throws:
- java.lang.CloneNotSupportedException- If any of the attributes cannot be cloned.
- See Also:
- NamedObj.exportMoML(Writer, int, String),- NamedObj.setDeferringChangeRequests(boolean)
 
 - 
getAllAdapterspublic java.util.List<OntologyAdapter> getAllAdapters() throws IllegalActionException Return the list of all PropertyAdapters associated with this ontology solver.- Returns:
- The list of PropertyAdapters.
- Throws:
- IllegalActionException- If there is an exception from getting all the subAdapters.
 
 - 
getAllConceptableNamedObjspublic java.util.Set<NamedObj> getAllConceptableNamedObjs() throws IllegalActionException Return the subset of all concept-able objects that are NamedObjs.- Returns:
- The set of all concept-able NamedObjs.
- Throws:
- IllegalActionException- Thrown if an error occurs when getting the adapters or the concept-able objects from them.
 
 - 
getAllPropertyablespublic java.util.Set getAllPropertyables() throws IllegalActionExceptionReturn the set of all property-able objects obtained from all PropertyAdapter.- Returns:
- The set of all property-able objects.
- Throws:
- IllegalActionException- Thrown if an error occurs when getting the adapters or the property-able objects from them.
 
 - 
getAllSolverspublic static java.util.List<OntologySolver> getAllSolvers(SharedParameter sharedParameter) Return the list of all solvers that are in the same model. They are linked by the specified SharedParameter.- Parameters:
- sharedParameter- The specified SharedParameter links together the solvers.
- Returns:
- A list of PropertySolvers.
 
 - 
getAttributepublic Attribute getAttribute(ASTPtRootNode node) Get the attribute that corresponds to the specified ASTPtRootNode. This assumes that the correspondence is recorded previously through callingOntologySolverUtilities.putAttribute(ASTPtRootNode, Attribute).- Parameters:
- node- The specified ASTPtRootNode.
- Returns:
- The attribute associated with the specified ASTPtRootNode.
- Throws:
- java.lang.AssertionError- Thrown if the specified node does not have a corresponding attribute.
 
 - 
getAdapterpublic OntologyAdapter getAdapter(java.lang.Object object) throws IllegalActionException Return the property adapter for the specified component.- Parameters:
- object- The specified component.
- Returns:
- The property adapter for the component.
- Throws:
- IllegalActionException- Thrown if the adapter cannot be found or instantiated.
 
 - 
getAllContainedOntologiespublic java.util.List<Ontology> getAllContainedOntologies() Return a list of all the ontologies contained in this solver. If it contains no ontologies, then return an empty list.- Returns:
- A list containing all ontologies in this solver.
 
 - 
getOntologypublic Ontology getOntology() throws IllegalActionException Return the ontology for this constraint solver. If this solver contains more than one ontology, then return the last one added. If it contains no ontologies, then return null.- Returns:
- The ontology for this constraint solver.
- Throws:
- IllegalActionException- If the structure is not a lattice.
 
 - 
getParserpublic PtParser getParser() Return the expression parser.- Returns:
- The expression parser.
 
 - 
getParseTreepublic ASTPtRootNode getParseTree(Attribute attribute) throws IllegalActionException Return the root ASTPtRootNode associated with the specified attribute.- Parameters:
- attribute- The specified attribute.
- Returns:
- The root ASTPtRootNode associated with the specified attribute.
- Throws:
- IllegalActionException- Thrown if there is a problem getting the parse tree.
 
 - 
getConceptpublic Concept getConcept(java.lang.Object object) Return the concept value associated with the specified object.- Parameters:
- object- The specified object.
- Returns:
- The property of the specified object.
- See Also:
- setConcept(Object, Concept)
 
 - 
getOntologySolverUtilitiespublic OntologySolverUtilities getOntologySolverUtilities() Return the shared utility object.- Returns:
- The shared utility object.
- See Also:
- setOntologySolverUtilities(ptolemy.data.ontologies.OntologySolverUtilities)
 
 - 
initializepublic void initialize() throws IllegalActionExceptionInitialize the solver. In the base class, only calls reset(). Subclasses can add functionality.- Throws:
- IllegalActionException- Thrown if there is a problem initializing the solver.
 
 - 
markAsNonSettablepublic void markAsNonSettable(java.lang.Object object) Mark the property of the specified object as non-settable. The specified object has a fixed assigned property.- Parameters:
- object- The specified object.
 
 - 
resetpublic void reset() Reset the solver.
 - 
resetAllpublic void resetAll() Reset every solver in the model.
 - 
resolveConceptspublic abstract void resolveConcepts() throws IllegalActionExceptionExecute the OntologySolver's algorithm to resolve which Concepts in the Ontology are assigned to each object in the model.- Throws:
- IllegalActionException- If the ontology resolution fails.
 
 - 
setOntologySolverUtilitiespublic void setOntologySolverUtilities(OntologySolverUtilities solverUtilities) Set the shared utility object to the given object.- Parameters:
- solverUtilities- The given ontology solver utilities object.
- See Also:
- getOntologySolverUtilities()
 
 - 
setConceptpublic void setConcept(java.lang.Object object, Concept property)Set the resolved property of the specified object.- Parameters:
- object- The specified object.
- property- The specified property.
- See Also:
- getConcept(Object)
 
 - 
_getAdapterprotected static OntologyAdapter _getAdapter(java.lang.Object component, OntologySolverBase solver) throws IllegalActionException Return the PropertyAdapter for the specified component. This instantiates a new PropertyAdapter if it does not already exist for the specified component. This method is static so it can be called in any subclass of OntologySolverBase regardless of how many classes are in between in the inheritance hierarchy.- Parameters:
- component- The specified component.
- solver- The solver for which to get the adapter.
- Returns:
- The PropertyAdapter for the specified component.
- Throws:
- IllegalActionException- Thrown if the PropertyAdapter cannot be instantiated.
 
 - 
_getPackageNameprotected static java.lang.String _getPackageName(OntologySolverBase solver) throws IllegalActionException Return the package name that contains the class of this solver.- Parameters:
- solver- The ontology solver for which we get the adapter package name.
- Returns:
- The package name.
- Throws:
- IllegalActionException- Thrown if there is a problem getting the ontology package name.
 
 - 
_toplevelprotected NamedObj _toplevel() Return the top level of the model hierarchy for the model we want to analyze.- Returns:
- The top level model object as a NamedObj
 
 
- 
 
-