Class AddMetric

  • All Implemented Interfaces:
    Serializable, Cloneable, Comparable, org.jgap.gp.IMutateable, org.jgap.util.ICloneable

    public class AddMetric
    extends org.jgap.gp.CommandGene
    implements org.jgap.gp.IMutateable, org.jgap.util.ICloneable
    Class to implement the ADD command for evolution of metric expressions. A ADD Command combines Similarity Measures with coefficients. E.g. "ADD(0.5*trigram(x.title,y.title)|0.9, 0.5*cosine(x.authors,y.authors)|0.7)". So LIMES recalculates the thresholds: threshold1 = (threshold - coef2) / coef1;
    Version:
    Jul 21, 2016
    Author:
    Klaus Lyko, Mohamed Sherif (sherif@informatik.uni-leipzig.de)
    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class org.jgap.gp.CommandGene

        org.jgap.gp.CommandGene.COMMAND_TYPE
    • Field Summary

      • Fields inherited from class org.jgap.gp.CommandGene

        BooleanClass, CharacterClass, DELTA, DoubleClass, FloatClass, IntegerClass, LongClass, nodeIndex, VoidClass
      • Fields inherited from interface org.jgap.util.ICloneable

        CVS_REVISION
      • Fields inherited from interface org.jgap.gp.IMutateable

        CVS_REVISION
    • Constructor Summary

      Constructors 
      Constructor Description
      AddMetric​(org.jgap.gp.impl.GPConfiguration config)
      Default Constructor.
      AddMetric​(org.jgap.gp.impl.GPConfiguration config, Class<?> a_returnType, boolean mutateable)
      Constructor to manually set return type.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.jgap.gp.CommandGene applyMutation()  
      org.jgap.gp.CommandGene applyMutation​(int a_index, double a_percentage)  
      Object clone()  
      Object execute_object​(org.jgap.gp.impl.ProgramChromosome a_chrom, int a_n, Object[] args)  
      void execute_void​(org.jgap.gp.impl.ProgramChromosome a_chrom, int a_n, Object[] args)  
      Class<?> getChildType​(org.jgap.gp.IGPProgram a_ind, int a_chromNum)
      We're expecting 2 pairs of aSimilarityCommand and a coefficient.
      static String removeThresholdFromMeasure​(String measure)
      ADD metrics only have coefficients no local thresholds.
      String toString()  
      • Methods inherited from class org.jgap.gp.CommandGene

        check, check, cleanup, compareTo, dynamizeArity, ensureUniqueness, ensureUniqueness, ensureUniqueness2, equals, execute, execute_boolean, execute_double, execute_float, execute_int, execute_long, getAllele, getApplicationData, getArity, getArityMax, getArityMin, getCommandType, getEnergy, getGPConfiguration, getInternalValue, getName, getPersistentRepresentation, getPersistentRepresentationExt, getReturnType, getSubChildType, getSubChildTypes, getSubReturnType, hashCode, init, isAffectGlobalState, isCompareApplicationData, isFloatType, isIntegerType, isValid, isValid, setAllele, setApplicationData, setArity, setArityMax, setArityMin, setCompareApplicationData, setEnergy, setNoValidation, setReturnType, setToRandomValue, setValueFromPersistentRepresentation, setValueFromString, size
    • Constructor Detail

      • AddMetric

        public AddMetric​(org.jgap.gp.impl.GPConfiguration config)
                  throws org.jgap.InvalidConfigurationException
        Default Constructor. Setting return type to String.class and making ADD no candidate for mutation.
        Parameters:
        config - A GPConfiguration
        Throws:
        org.jgap.InvalidConfigurationException - when an invalid value has been passed to a Configuration object
      • AddMetric

        public AddMetric​(org.jgap.gp.impl.GPConfiguration config,
                         Class<?> a_returnType,
                         boolean mutateable)
                  throws org.jgap.InvalidConfigurationException
        Constructor to manually set return type.
        Parameters:
        config - A GPConfiguration
        a_returnType - Class this CommandGene returns on executing.
        Throws:
        org.jgap.InvalidConfigurationException - when an invalid value has been passed to a Configuration object
    • Method Detail

      • removeThresholdFromMeasure

        public static String removeThresholdFromMeasure​(String measure)
        ADD metrics only have coefficients no local thresholds. So this function removes them.
        Parameters:
        measure - , e.g. trigrams(s.x,t.y)|0.8
        Returns:
        shortened measure, e.g. trigrams(s.x,t.y)
      • toString

        public String toString()
        Specified by:
        toString in class org.jgap.gp.CommandGene
      • getChildType

        public Class<?> getChildType​(org.jgap.gp.IGPProgram a_ind,
                                     int a_chromNum)
        We're expecting 2 pairs of aSimilarityCommand and a coefficient.
        Overrides:
        getChildType in class org.jgap.gp.CommandGene
        Parameters:
        a_ind - A GPProgram
        a_chromNum - The number of the chromosome.
        Returns:
        Class type of the child.
      • execute_object

        public Object execute_object​(org.jgap.gp.impl.ProgramChromosome a_chrom,
                                     int a_n,
                                     Object[] args)
        Overrides:
        execute_object in class org.jgap.gp.CommandGene
      • execute_void

        public void execute_void​(org.jgap.gp.impl.ProgramChromosome a_chrom,
                                 int a_n,
                                 Object[] args)
        Overrides:
        execute_void in class org.jgap.gp.CommandGene
      • applyMutation

        public org.jgap.gp.CommandGene applyMutation​(int a_index,
                                                     double a_percentage)
                                              throws org.jgap.InvalidConfigurationException
        Specified by:
        applyMutation in interface org.jgap.gp.IMutateable
        Throws:
        org.jgap.InvalidConfigurationException
      • applyMutation

        public org.jgap.gp.CommandGene applyMutation()
                                              throws org.jgap.InvalidConfigurationException
        Returns:
        CommandGene
        Throws:
        org.jgap.InvalidConfigurationException - when an invalid value has been passed to a Configuration object
      • clone

        public Object clone()
        Specified by:
        clone in interface org.jgap.util.ICloneable
        Overrides:
        clone in class Object