Class LatticeOntologySolver

    • Field Detail

      • solvingFixedPoint

        public StringParameter solvingFixedPoint
        Indicate whether to compute the least or greatest fixed point solution.
        • "least" Solve for least fixed point
        • "greatest" Solve for greatest fixed point
      • solverStrategy

        public StringParameter solverStrategy
        A single parameter for quickly selecting common solving strategies, plus a "custom" option to allow a user-defined strategy.
      • ADD_FUNCTION_NAME

        public static final java.lang.String ADD_FUNCTION_NAME
        The string name of the attribute that defines the arithmetic add concept function for this ontology solver.
        See Also:
        Constant Field Values
      • SUBTRACT_FUNCTION_NAME

        public static final java.lang.String SUBTRACT_FUNCTION_NAME
        The string name of the attribute that defines the arithmetic subtract concept function for this ontology solver.
        See Also:
        Constant Field Values
      • MULTIPLY_FUNCTION_NAME

        public static final java.lang.String MULTIPLY_FUNCTION_NAME
        The string name of the attribute that defines the arithmetic multiply concept function for this ontology solver.
        See Also:
        Constant Field Values
      • DIVIDE_FUNCTION_NAME

        public static final java.lang.String DIVIDE_FUNCTION_NAME
        The string name of the attribute that defines the arithmetic divide concept function for this ontology solver.
        See Also:
        Constant Field Values
      • NEGATE_FUNCTION_NAME

        public static final java.lang.String NEGATE_FUNCTION_NAME
        The string name of the attribute that defines the arithmetic negation concept function for this ontology solver.
        See Also:
        Constant Field Values
      • RECIPROCAL_FUNCTION_NAME

        public static final java.lang.String RECIPROCAL_FUNCTION_NAME
        The string name of the attribute that defines the arithmetic negation concept function for this ontology solver.
        See Also:
        Constant Field Values
      • NOT_FUNCTION_NAME

        public static final java.lang.String NOT_FUNCTION_NAME
        The string name of the attribute that defines the logical not concept function for this ontology solver.
        See Also:
        Constant Field Values
      • AND_FUNCTION_NAME

        public static final java.lang.String AND_FUNCTION_NAME
        The string name of the attribute that defines the logical and concept function for this ontology solver.
        See Also:
        Constant Field Values
      • OR_FUNCTION_NAME

        public static final java.lang.String OR_FUNCTION_NAME
        The string name of the attribute that defines the logical or concept function for this ontology solver.
        See Also:
        Constant Field Values
      • _initialConstraintList

        protected java.util.List<Inequality> _initialConstraintList
        The list of constraints collected from the model, before resolution.
      • _resolvedConstraintList

        protected java.util.List<Inequality> _resolvedConstraintList
        The list of constraints after the ontology resolution algorithm has executed.
      • _resolvedUnacceptableList

        protected java.util.List<InequalityTerm> _resolvedUnacceptableList
        The list of InequalityTerms that have resolved to an unacceptable concept value. See ConceptTermManager for a definition of unacceptable.
    • Method Detail

      • clone

        public java.lang.Object clone​(Workspace workspace)
                               throws java.lang.CloneNotSupportedException
        Clone the object into the specified workspace. The new object is not added to the directory of that workspace (you must do this yourself if you want it there). The result is an object with no container.
        Overrides:
        clone in class OntologySolver
        Parameters:
        workspace - The workspace for the cloned object.
        Returns:
        The new object.
        Throws:
        java.lang.CloneNotSupportedException - Not thrown in this base class
        See Also:
        NamedObj.exportMoML(Writer, int, String), NamedObj.setDeferringChangeRequests(boolean)
      • getAffectedTerms

        public java.util.List<InequalityTerm> getAffectedTerms​(InequalityTerm updateTerm)
                                                        throws IllegalActionException
        Get the list of affected InequalityTerms from the OntologySolver's ConceptTermManager. FIXME: 01/28/10 Charles Shelton - Not really sure what this method is used for. The call to _conceptTermManager.getAffectedTerms() appears to always return an empty ArrayList.
        Parameters:
        updateTerm - This parameter doesn't appear to be used
        Returns:
        The list of inequality terms that are affected by the OntologySolver
        Throws:
        IllegalActionException - If an exception is thrown
      • getConstraintManager

        public ConstraintManager getConstraintManager()
        Get the ConstraintManager that collects and maintains all the inequality constraints for the OntologySolver.
        Returns:
        the constraintManager
      • getInitialSolverInformation

        public java.util.Hashtable<java.lang.String,​java.lang.String> getInitialSolverInformation()
                                                                                                 throws IllegalActionException
        Initialize the solver and get the initial statistics for the Lattice OntologySolver. This will return information about the number of constraints and concept terms generated before the solver executes its algorithm.
        Returns:
        A hash table containing string representations of the solver statistics and constraints information, separated by tabs.
        Throws:
        IllegalActionException - If an exception occurs when collecting the constraints.
      • getResolvedSolverInformation

        public java.util.Hashtable<java.lang.String,​java.lang.String> getResolvedSolverInformation()
                                                                                                  throws IllegalActionException
        Get the statistics for the Lattice OntologySolver after the model has been resolved. This will return information about the number of constraints and concept terms generated after the solver executes its algorithm.
        Returns:
        A hash table containing string representations of the solver statistics and constraints information, separated by tabs.
        Throws:
        IllegalActionException - If an exception occurs when collecting the constraints.
      • getAdapter

        public OntologyAdapter getAdapter​(NamedObj component)
                                   throws IllegalActionException
        Returns the adapter that contains concept information for the given component.
        Parameters:
        component - The given component
        Returns:
        The associated concept constraint adapter.
        Throws:
        IllegalActionException - If an exception is thrown in the private _getAdapter method
      • getConceptTerm

        public InequalityTerm getConceptTerm​(java.lang.Object object)
        Return the concept term from the given object.
        Parameters:
        object - The given object.
        Returns:
        The concept term of the given object.
      • getConceptTermManager

        public ConceptTermFactory getConceptTermManager()
        Return the concept term manager that collects and maintains a hash map that maps all model objects to their the inequality terms for the OntologySolver.
        Returns:
        The concept term manager for the OntologySolver
      • hasUnacceptableTerms

        public boolean hasUnacceptableTerms()
        Returns true if one or more terms resolved to unacceptable concepts, false otherwise (if the solver has not run, or if all terms have acceptable resolved concepts.
        Returns:
        True if one or more terms resolved to unacceptable concepts, false otherwise.
      • isAnnotatedTerm

        public boolean isAnnotatedTerm​(java.lang.Object object)
        Return true if the given model object has been annotated with a manual annotation constraint.
        Parameters:
        object - The model object to be checked to see if it is annotated
        Returns:
        true if the model object is annotated, false otherwise
      • isLeastFixedPoint

        public boolean isLeastFixedPoint()
                                  throws IllegalActionException
        Return true if the solver is finding a least fixed point, and false if the solver is finding a greatest fixed point.
        Returns:
        True, if solver is solving a least fixed point, false, if it is solving a greatest fixed point.
        Throws:
        IllegalActionException - If the solvingFixedPoint parameter contains an invalid value.
      • reset

        public void reset()
        Reset the solver. This removes the internal states of the solver (e.g. previously recorded properties, statistics, etc.). Also resets the ConceptTermManager to null and clears the trained constraints.
        Overrides:
        reset in class OntologySolver
      • test

        public void test()
                  throws IllegalActionException
        Run concept inference and check the values match those trained. This simply looks through the conceptable objects and checks that their resolved concepts match the values contained in the __trainedConceptRecordArray attribute.
        Throws:
        IllegalActionException - If inference fails or the test resolves to the wrong values.
      • train

        public void train()
                   throws IllegalActionException
        Run concept inference and save the inferred concept values. For all conceptable model elements, an array of records that maps the full name of the Ptolemy element to the name of the concept to which it was resolved is generated and stored as a parameter of the ontology solver.
        Throws:
        IllegalActionException - If inference fails..
      • getUnacceptableTermsAsString

        protected java.lang.String getUnacceptableTermsAsString()
                                                         throws IllegalActionException
        Return a string representing the list of terms that resolved to unacceptable concepts. Returns an empty string if the solver has not been run, or if all terms were acceptable. See ConceptTermManager for a definition of acceptable.
        Returns:
        A string representing the list of terms that resolved to unacceptable concepts. Can be the empty string.
        Throws:
        IllegalActionException - If the string cannot be formed from the list of inequality terms
      • getUnacceptableTerms

        protected java.util.List<InequalityTerm> getUnacceptableTerms()
        Return the list of inequality terms that resolved to unacceptable concepts. Returns null if the solver has not been run first, or if all terms were acceptable. See ConceptTermManager for a definition of acceptable.
        Returns:
        The list of inequality terms that resolved to unacceptable concepts. Can be null.
      • _clearLists

        protected void _clearLists()
        Set the resolved constraint list and the list of unacceptable inequality terms to null. Implemented as a protected method so that subclasses may call it.
      • _getAdapter

        protected OntologyAdapter _getAdapter​(java.lang.Object component)
                                       throws IllegalActionException
        Return the LatticeOntologyAdapter for the specified component. This instantiates a new OntologyAdapter if it does not already exist for the specified component. This returns specific LatticeOntologyAdapters for the LatticeOntologySolver.
        Parameters:
        component - The specified component.
        Returns:
        The LatticeOntologyAdapter for the specified component.
        Throws:
        IllegalActionException - Thrown if the LatticeOntologyAdapter cannot be instantiated.
      • _getConceptTermManager

        protected ConceptTermManager _getConceptTermManager()
        Return a new concept term manager. Subclass can implements a its own manager and override this method to instantiate a instance of the new class.
        Returns:
        A concept term manager.
      • _resolveConcepts

        protected void _resolveConcepts​(NamedObj toplevel,
                                        java.util.List<Inequality> constraintList)
                                 throws OntologyResolutionException
        Resolve the concepts for the given top-level container, subject to the given constraint list.
        Parameters:
        toplevel - The top-level container
        constraintList - The constraint list that we are solving
        Throws:
        OntologyResolutionException - If constraints are unsatisfiable
      • _getConstraintType

        protected LatticeOntologySolver.ConstraintType _getConstraintType()
                                                                   throws IllegalActionException
        Return the constraint type based on the solver strategy and the type of the fixed point. Least fixed points with forward inference give constraints that the sinks be greater that the sources, bidirectional inference requires sources and sinks to be equal, etc.
        Returns:
        The enumeration from ConstraintType corresponding to the given solver strategy.
        Throws:
        IllegalActionException - If solver strategy or fixed point type cannot be understood.