Exemple #1
0
        /// <summary>
        /// The default version of Setup(...) loads requested pipelines and calls Setup(...) on them and normalizes their probabilities.
        /// If your individual prototype might need to know special things about the species (like parameters stored in it),
        /// then when you override this Setup method, you'll need to set those parameters BEFORE you call super.Setup(...),
        /// because the Setup(...) code in Species sets up the prototype.
        /// </summary>
        /// <seealso cref="IPrototype.Setup(IEvolutionState, IParameter)" />
        public virtual void Setup(IEvolutionState state, IParameter paramBase)
        {
            var def = DefaultBase;

            // load the breeding pipeline
            Pipe_Prototype = (BreedingSource)state.Parameters.GetInstanceForParameter(paramBase.Push(P_PIPE), def.Push(P_PIPE), typeof(BreedingSource));
            Pipe_Prototype.Setup(state, paramBase.Push(P_PIPE));

            // I promised over in BreedingSource.java that this method would get called.
            state.Output.ExitIfErrors();

            // load our individual prototype
            I_Prototype = (Individual)(state.Parameters.GetInstanceForParameter(paramBase.Push(P_INDIVIDUAL), def.Push(P_INDIVIDUAL), typeof(Individual)));
            // set the species to me before setting up the individual, so they know who I am
            I_Prototype.Species = this;
            I_Prototype.Setup(state, paramBase.Push(P_INDIVIDUAL));

            // load our fitness
            F_Prototype = (Fitness)state.Parameters.GetInstanceForParameter(paramBase.Push(P_FITNESS), def.Push(P_FITNESS), typeof(Fitness));
            F_Prototype.Setup(state, paramBase.Push(P_FITNESS));
        }