Skip navigation links
ec.rule

Class RuleIndividual

    • Field Detail

      • rulesets

        public RuleSet[] rulesets
        The individual's rulesets.
    • Constructor Detail

      • RuleIndividual

        public RuleIndividual()
    • Method Detail

      • defaultBase

        public Parameter defaultBase()
        Description copied from interface: Prototype
        Returns the default base for this prototype. This should generally be implemented by building off of the static base() method on the DefaultsForm object for the prototype's package. This should be callable during setup(...).
      • clone

        public java.lang.Object clone()
        Description copied from interface: Prototype
        Creates a new individual cloned from a prototype, and suitable to begin use in its own evolutionary context.

        Typically this should be a full "deep" clone. However, you may share certain elements with other objects rather than clone hem, depending on the situation:

        • If you hold objects which are shared with other instances, don't clone them.
        • If you hold objects which must be unique, clone them.
        • If you hold objects which were given to you as a gesture of kindness, and aren't owned by you, you probably shouldn't clone them.
        • DON'T attempt to clone: Singletons, Cliques, or Groups.
        • Arrays are not cloned automatically; you may need to clone an array if you're not sharing it with other instances. Arrays have the nice feature of being copyable by calling clone() on them.

        Implementations.

        • If no ancestor of yours implements clone(), and you have no need to do clone deeply, and you are abstract, then you should not declare clone().
        • If no ancestor of yours implements clone(), and you have no need to do clone deeply, and you are not abstract, then you should implement it as follows:

           public Object clone() 
               {
               try
                   { 
                   return super.clone();
                   }
               catch ((CloneNotSupportedException e)
                   { throw new InternalError(); } // never happens
               }
                  
        • If no ancestor of yours implements clone(), but you need to deep-clone some things, then you should implement it as follows:

           public Object clone() 
               {
               try
                   { 
                   MyObject myobj = (MyObject) (super.clone());
          
                   // put your deep-cloning code here...
                   }
               catch ((CloneNotSupportedException e)
                   { throw new InternalError(); } // never happens
               return myobj;
               } 
                  
        • If an ancestor has implemented clone(), and you also need to deep clone some things, then you should implement it as follows:

           public Object clone() 
               { 
               MyObject myobj = (MyObject) (super.clone());
          
               // put your deep-cloning code here...
          
               return myobj;
               } 
                  
        Specified by:
        clone in interface Prototype
        Overrides:
        clone in class Individual
      • preprocessIndividual

        public void preprocessIndividual(EvolutionState state,
                                         int thread)
        Called by pipelines before they've modified the individual and it might need to be "fixed" -- basically a hook for you to override. By default, calls validateRules on each ruleset.
      • postprocessIndividual

        public void postprocessIndividual(EvolutionState state,
                                          int thread)
        Called by pipelines after they've modified the individual and it might need to be "fixed" -- basically a hook for you to override. By default, calls validateRules on each ruleset.
      • equals

        public boolean equals(java.lang.Object ind)
        Description copied from class: Individual
        Returns true if I am genetically "equal" to ind. This should mostly be interpreted as saying that we are of the same class and that we hold the same data. It should NOT be a pointer comparison.
        Specified by:
        equals in class Individual
      • hashCode

        public int hashCode()
        Description copied from class: Individual
        Returns a hashcode for the individual, such that individuals which are equals(...) each other always return the same hash code.
        Specified by:
        hashCode in class Individual
      • printIndividualForHumans

        public void printIndividualForHumans(EvolutionState state,
                                             int log)
        Description copied from class: Individual
        Should print the individual out in a pleasing way for humans, with a verbosity of Output.V_NO_GENERAL.
        Overrides:
        printIndividualForHumans in class Individual
      • printIndividual

        public void printIndividual(EvolutionState state,
                                    int log)
        Description copied from class: Individual
        Should print the individual in a way that can be read by computer, including its fitness, with a verbosity of Output.V_NO_GENERAL.
        Overrides:
        printIndividual in class Individual
      • printIndividual

        public void printIndividual(EvolutionState state,
                                    java.io.PrintWriter writer)
        Overridden for the RuleIndividual genotype, writing each ruleset in turn.
        Overrides:
        printIndividual in class Individual
      • writeGenotype

        public void writeGenotype(EvolutionState state,
                                  java.io.DataOutput dataOutput)
                           throws java.io.IOException
        Overridden for the RuleIndividual genotype, writing each ruleset in turn.
        Overrides:
        writeGenotype in class Individual
        Throws:
        java.io.IOException
      • readGenotype

        public void readGenotype(EvolutionState state,
                                 java.io.DataInput dataInput)
                          throws java.io.IOException
        Overridden for the RuleIndividual genotype.
        Overrides:
        readGenotype in class Individual
        Throws:
        java.io.IOException
      • parseGenotype

        public void parseGenotype(EvolutionState state,
                                  java.io.LineNumberReader reader)
                           throws java.io.IOException
        Overridden for the RuleIndividual genotype.
        Overrides:
        parseGenotype in class Individual
        Throws:
        java.io.IOException
      • size

        public long size()
        Description copied from class: Individual
        Returns the "size" of the individual. This is used for things like parsimony pressure. The default form of this method returns 0 -- if you care about parsimony pressure, you'll need to override the default to provide a more descriptive measure of size.
        Overrides:
        size in class Individual
      • mutate

        public void mutate(EvolutionState state,
                           int thread)
        Mutates the Individual. The default implementation simply calls mutate(...) on each of the RuleSets.