Class LatticeOntologyAdapter

    • Field Detail

      • _ownConstraints

        protected java.util.List<Inequality> _ownConstraints
        The list of Inequality constraints contained by this LatticeOntologyAdapter.
      • _useDefaultConstraints

        protected boolean _useDefaultConstraints
        Indicate whether this adapter uses the default actor constraints.
      • _subAdapterConstraints

        protected java.util.List<Inequality> _subAdapterConstraints
        The list of permanent property constraints.
    • Constructor Detail

      • LatticeOntologyAdapter

        public LatticeOntologyAdapter​(LatticeOntologySolver solver,
                                      java.lang.Object component)
                               throws IllegalActionException
        Construct the lattice ontology adapter associated with the given component and solver. The constructed adapter implicitly uses the default constraints set by the solver.
        Parameters:
        solver - The specified lattice-based ontology solver.
        component - The associated component.
        Throws:
        IllegalActionException - Thrown if the adapter cannot be initialized.
      • LatticeOntologyAdapter

        public LatticeOntologyAdapter​(LatticeOntologySolver solver,
                                      java.lang.Object component,
                                      boolean useDefaultConstraints)
                               throws IllegalActionException
        Construct the lattice ontology adapter for the given component and property lattice.
        Parameters:
        solver - The specified lattice-based ontology solver.
        component - The given component.
        useDefaultConstraints - Indicate whether this adapter uses the default actor constraints.
        Throws:
        IllegalActionException - Thrown if the adapter cannot be initialized.
    • Method Detail

      • constraintList

        public java.util.List<Inequality> constraintList()
                                                  throws IllegalActionException
        Return the constraints of this component. The constraints is a list of inequalities. This base class returns the union of the constraints of this component and the constraints for the subcomponents
        Returns:
        The constraints of this component.
        Throws:
        IllegalActionException - Not thrown in this base class.
      • getPropertyTerm

        public InequalityTerm getPropertyTerm​(java.lang.Object object)
        Return the InequalityTerm associated with the given model object.
        Parameters:
        object - The given model object for which to find the InequalityTerm in the OntologySolver
        Returns:
        The InequalityTerm associated with the model object
      • isConstraintSource

        public boolean isConstraintSource()
        Returns true if the interconnectConstraintType is for sources, false otherwise. It will return only true if interconnectConstraintType is set to SOURCE_GE_SINK or EQUALS.
        Returns:
        true if the interconnectConstraintType is for sources, false otherwise
      • setAtLeast

        public void setAtLeast​(java.lang.Object greater,
                               java.lang.Object lesser)
        Set an inequality constraint between the two specified objects, such that the concept value of the greater term is greater than or equal to the concept value of the lesser term.
        Parameters:
        greater - The model object on the LHS of the ≥ inequality
        lesser - The model object on the RHS of the ≥ inequality
      • setAtMost

        public void setAtMost​(java.lang.Object lesser,
                              java.lang.Object greater)
        Set an inequality constraint between the two specified objects, such that the concept value of the greater term is greater than or equal to the concept value of the lesser term.
        Parameters:
        lesser - The model object on the RHS of the ≥ inequality
        greater - The model object on the LHS of the ≥ inequality
      • setSameAs

        public void setSameAs​(java.lang.Object object1,
                              java.lang.Object object2)
        Set two inequality constraints between the specified objects, such that the Concept value of object1 is equal to the Concept value of object2.
        Parameters:
        object1 - The model object on the LHS of the equality
        object2 - The model object on the RHS of the equality
      • _addSubAdapterConstraints

        protected void _addSubAdapterConstraints()
                                          throws IllegalActionException
        Iterate through the list of sub adapters and gather the constraints for each one. Note that the adapter stores a new set of constraints each time this is invoked. Therefore, multiple invocations will generate excessive constraints and result in inefficiency during resolution.
        Throws:
        IllegalActionException - Thrown if there is any errors in getting the sub adapters and gathering the constraints for each one.
      • _annotationEvaluator

        protected ParseTreeAnnotationEvaluator _annotationEvaluator()
        Create a new ParseTreeAnnotationEvaluator that is tailored for the ontology. This class parses the user-defined ontology constraint annotations in the model containing the LatticeOntologySolver.
        Specified by:
        _annotationEvaluator in class OntologyAdapter
        Returns:
        a new ParseTreeConstraintAnnotationEvaluator object
      • _constrainAttributes

        protected void _constrainAttributes()
        Set default Inequality constraints for all attributes that can be evaluated to a Concept in the Ontology. This method parses each attribute and sets a default constraint between the root AST node and its attribute, if the attribute was parseable.
      • _constrainObject

        protected void _constrainObject​(LatticeOntologySolver.ConstraintType constraintType,
                                        java.lang.Object sink,
                                        java.util.List sourceList)
                                 throws IllegalActionException
        Set default constraints between the given object and a list of objects based on the given constraintType. The given object is the sink and the list of objects are the sources.
        Parameters:
        constraintType - The given ConstraintType to be used for the default constraints
        sink - The given object that represents the sink for the default constraints
        sourceList - The list of objects passed in as a List that represents the sources for the default constraints
        Throws:
        IllegalActionException - If an exception is thrown
        See Also:
        LatticeOntologySolver.ConstraintType
      • _constrainObjectLists

        protected void _constrainObjectLists​(LatticeOntologySolver.ConstraintType constraintType,
                                             java.util.List sourceList,
                                             java.util.List sinkList)
                                      throws IllegalActionException
        Set the default constraint between the given list of source objects and list of sink objects based on the given constraintType.
        Parameters:
        constraintType - The given ConstraintType to be used for the default constraint
        sourceList - A list of source objects
        sinkList - A list of sink objects
        Throws:
        IllegalActionException - If an exception is thrown
        See Also:
        LatticeOntologySolver.ConstraintType
      • _constrainSingleObject

        protected void _constrainSingleObject​(LatticeOntologySolver.ConstraintType constraintType,
                                              java.lang.Object source,
                                              java.lang.Object sink)
                                       throws IllegalActionException
        Set the default constraint between the given source and sink object based on the given constraintType.
        Parameters:
        constraintType - The given ConstraintType to be used for the default constraint
        source - The source object for the default constraints
        sink - The sink object for the default constraints
        Throws:
        IllegalActionException - If an exception is thrown
        See Also:
        LatticeOntologySolver.ConstraintType
      • _getConstrainedPorts

        protected java.util.List _getConstrainedPorts​(boolean constraintSource)
        Return the list of constrained ports given the flag whether source or sink ports should be constrained. If source ports are constrained, it returns the list of input ports of the associated actor; otherwise, it returns the list of output ports.
        Parameters:
        constraintSource - The flag that indicates whether source or sink ports are constrained.
        Returns:
        The list of constrained ports.
      • _getConstraintingPorts

        protected static java.util.List _getConstraintingPorts​(boolean constraintSource,
                                                               TypedIOPort port)
        Return the list of constraining ports on a given port, given whether source or sink ports should be constrained.
        Parameters:
        constraintSource - The flag that indicates whether source or sink ports are constrained.
        port - The given port.
        Returns:
        The list of constraining ports.
      • _setConnectionConstraintType

        protected void _setConnectionConstraintType​(LatticeOntologySolver.ConstraintType constraintType)
                                             throws IllegalActionException
        Set the default constraint type for connections for the model component referred to by this OntologyAdapter for the given OntologySolver, depending on what type of component it is. This method is recursive and will set the default constraints for the OntologyAdapters for all subcomponents of this model component as well.
        Parameters:
        constraintType - The default ConstraintType for generic model component connections; will be used if the model component is not one of the following types for Ptolemy expression language AST nodes; will be used it the model component is an AST node
        Throws:
        IllegalActionException - If an exception is thrown
        See Also:
        LatticeOntologySolver.ConstraintType
      • _union

        protected static java.util.List<Inequality> _union​(java.util.List<Inequality> list1,
                                                           java.util.List<Inequality> list2)
        Return the union of the two specified lists of inequality constraints by appending the second list to the end of the first list.
        Parameters:
        list1 - The first list.
        list2 - The second list.
        Returns:
        The union of the two lists.