Exemple #1
0
        /// <summary>
        /// Reads in the individual from a form printed by PrintIndividual(), erasing the previous
        /// information stored in this Individual.  If you are trying to <i>create</i> an Individual
        /// from information read in from a stream or BinaryReader,
        /// see the various NewIndividual() methods in Species. The default form of this method
        /// simply reads in evaluation information, then fitness information, and then
        /// calls ParseGenotype() (which you should implement).  The Species is not changed or
        /// attached, so you may need to do that elsewhere.  Feel free to override
        /// this method to produce more sophisticated behavior,
        /// though it is rare to need to -- instead you could just override ParseGenotype().
        /// </summary>
        public virtual void ReadIndividual(IEvolutionState state, StreamReader reader)
        {
            Evaluated = Code.ReadBooleanWithPreamble(EVALUATED_PREAMBLE, state, reader);

            // Next, what's my fitness?
            Fitness.ReadFitness(state, reader);

            // next, read me in
            ParseGenotype(state, reader);
        }
Exemple #2
0
 /// <summary>
 /// Reads the binary form of an individual from a BinaryReader, erasing the previous
 /// information stored in this Individual.  This is not for serialization:
 /// the object should only read in the data written out via PrintIndividual(state,writer).
 /// If you are trying to <i>create</i> an Individual
 /// from information read in from a stream or BinaryReader,
 /// see the various NewIndividual() methods in Species. The default form of this method
 /// simply reads in evaluation information, then fitness information, and then
 /// calls ReadGenotype() (which you will need to override -- its default form simply throws an error).
 /// The Species is not changed or attached, so you may need to do that elsewhere.  Feel free to override
 /// this method to produce more sophisticated behavior, though it is rare to need to -- instead you could
 /// just override ReadGenotype().
 /// </summary>
 public virtual void ReadIndividual(IEvolutionState state, BinaryReader reader)
 {
     Evaluated = reader.ReadBoolean();
     Fitness.ReadFitness(state, reader);
     ReadGenotype(state, reader);
 }