Class LsaMolecule

  • All Implemented Interfaces:
    it.unibo.alchemist.model.Dependency , it.unibo.alchemist.model.Molecule , it.unibo.alchemist.model.sapere.ILsaMolecule , java.io.Serializable , java.lang.Comparable , java.lang.Iterable

    
    public final class LsaMolecule
    extends SimpleMolecule implements ILsaMolecule
                        

    This class realizes an LsaMolecule, where arguments are of type Expression.

    • Constructor Detail

      • LsaMolecule

        LsaMolecule()
        Empty molecule, no arguments.
      • LsaMolecule

        LsaMolecule(List<IExpression> listArgs)
        Builds a new LsaMolecule by interpreting a list of IExpressions.
        Parameters:
        listArgs - the list of IExpressions
      • LsaMolecule

        LsaMolecule(LsaMolecule m)
        Very fast constructor, produces a copy of an LsaMolecule.
        Parameters:
        m - the LsaMolecule to copy
      • LsaMolecule

        LsaMolecule(String argsString)
        Builds a LsaMolecule by parsing the passed String.
        Parameters:
        argsString - the String to parse
      • LsaMolecule

        LsaMolecule(String argsString, String description)
        Builds a LsaMolecule by parsing the passed String.
        Parameters:
        argsString - the String to parse
        description - a String to append at the end of the LSA.
    • Method Detail

      • allocateVar

         List<IExpression> allocateVar(Map<HashString, ITreeNode<out Object>> matches)
        Parameters:
        matches - the map with the variable / value bindings
        Returns:

        the list of the arguments updated

      • argsNumber

         int argsNumber()
        Returns:

        the arguments number of the LSA structure.

      • getArg

         IExpression getArg(int i)
        Parameters:
        i - : position of the argument to get
        Returns:

        the Expression represent the argument i.

      • hasDuplicateVariables

         boolean hasDuplicateVariables()
        Returns:

        true if this variable makes use of variables defined within the molecule itself

      • isIdenticalTo

         boolean isIdenticalTo(ILsaMolecule mol)
        Parameters:
        mol - the molecule to compare to
        Returns:

        true if lsaMolecule is identical to mol, namely that all the arguments are equal

      • isIstance

         boolean isIstance()
        Returns:

        true if the molecule is an instance (not variable in the argouments).

      • matches

         boolean matches(ILsaMolecule mol)
        Parameters:
        mol - the LsaMolecule to try to match with.
        Returns:

        true if the two molecules match

      • matches

         boolean matches(List<out IExpression> mol, boolean duplicateVariables)
        Parameters:
        mol - the LsaMolecule to try to match with
        duplicateVariables - if true, the matching of variables reused within the same tuple is enabled
        Returns:

        true if the two molecules match

      • moreGenericOf

         boolean moreGenericOf(ILsaMolecule mol)
        Parameters:
        mol - the molecule to compare to
        Returns:

        true if the molecule is more generic than the one passed

      • size

         int size()
        Returns:

        the number of arguments

      • toHashString

         HashString toHashString()
        Returns:

        the string representing the molecule, in a faster implementation.