/// <summary>
        ///     Constructs and initializes the initialization algorithm.
        /// </summary>
        /// <param name="xmlConfig">The XML configuration for the initialization algorithm.</param>
        /// <param name="isAcyclic">Flag indicating whether the network is acyclic (i.e. does not have recurrent connections).</param>
        /// <returns>The constructed initialization algorithm.</returns>
        public virtual void SetAlgorithmParameters(XmlElement xmlConfig, bool isAcyclic)
        {
            // Read NEAT genome parameters
            // Save off genome parameters specifically for the initialization algorithm
            // (this is primarily because the initialization algorithm will quite likely have different NEAT parameters)
            NeatGenomeParameters = ExperimentUtils.ReadNeatGenomeParameters(xmlConfig);
            NeatGenomeParameters.FeedforwardOnly = isAcyclic;

            // Read NEAT evolution parameters
            EvolutionAlgorithmParameters = ExperimentUtils.ReadNeatEvolutionAlgorithmParameters(xmlConfig);

            // Get complexity constraint parameters
            ComplexityRegulationStrategyDefinition = XmlUtils.TryGetValueAsString(xmlConfig,
                                                                                  "ComplexityRegulationStrategy");
            ComplexityThreshold = XmlUtils.TryGetValueAsInt(xmlConfig, "ComplexityThreshold");
        }
コード例 #2
0
        /// <inheritdoc />
        /// <summary>
        ///     Initializes the MCC maze navigation experiment by reading in all of the configuration parameters and
        ///     setting up the bootstrapping/initialization algorithm.
        /// </summary>
        /// <param name="name">The name of the experiment.</param>
        /// <param name="xmlConfig">The reference to the XML configuration file.</param>
        /// <param name="population1EvolutionLogger">The navigator evolution data logger.</param>
        /// <param name="population1PopulationLogger">The navigator population logger.</param>
        /// <param name="population1GenomeLogger">The navigator genome logger.</param>
        /// <param name="population2EvolutionLogger">The maze evolution data logger.</param>
        /// <param name="population2PopulationLogger">The maze population logger.</param>
        /// <param name="population2GenomeLogger">The maze genome logger.</param>
        public virtual void Initialize(string name, XmlElement xmlConfig,
                                       IDataLogger population1EvolutionLogger  = null, IDataLogger population1PopulationLogger = null,
                                       IDataLogger population1GenomeLogger     = null, IDataLogger population2EvolutionLogger  = null,
                                       IDataLogger population2PopulationLogger = null, IDataLogger population2GenomeLogger     = null)
        {
            // Set boiler plate properties
            Name             = name;
            Description      = XmlUtils.GetValueAsString(xmlConfig, "Description");
            ActivationScheme = ExperimentUtils.CreateActivationScheme(xmlConfig, "Activation");
            ParallelOptions  = ExperimentUtils.ReadParallelOptions(xmlConfig);

            // Set the genome parameters
            NeatGenomeParameters = ExperimentUtils.ReadNeatGenomeParameters(xmlConfig);
            NeatGenomeParameters.FeedforwardOnly = ActivationScheme.AcyclicNetwork;
            MazeGenomeParameters = ExperimentUtils.ReadMazeGenomeParameters(xmlConfig);

            // Configure evolutionary algorithm parameters
            AgentDefaultPopulationSize      = XmlUtils.GetValueAsInt(xmlConfig, "AgentPopulationSize");
            MazeDefaultPopulationSize       = XmlUtils.GetValueAsInt(xmlConfig, "MazePopulationSize");
            AgentSeedGenomeCount            = XmlUtils.GetValueAsInt(xmlConfig, "AgentSeedGenomeCount");
            MazeSeedGenomeCount             = XmlUtils.GetValueAsInt(xmlConfig, "MazeSeedGenomeCount");
            AgentNumSpecies                 = XmlUtils.GetValueAsInt(xmlConfig, "AgentNumSpecies");
            MazeNumSpecies                  = XmlUtils.GetValueAsInt(xmlConfig, "MazeNumSpecies");
            BehaviorCharacterizationFactory = ExperimentUtils.ReadBehaviorCharacterizationFactory(xmlConfig,
                                                                                                  "BehaviorConfig");
            NavigatorBatchSize = XmlUtils.GetValueAsInt(xmlConfig, "NavigatorOffspringBatchSize");
            MazeBatchSize      = XmlUtils.GetValueAsInt(xmlConfig, "MazeOffspringBatchSize");

            // Set run-time bounding parameters
            MaxGenerations = XmlUtils.TryGetValueAsInt(xmlConfig, "MaxGenerations");
            MaxEvaluations = XmlUtils.TryGetValueAsULong(xmlConfig, "MaxEvaluations");

            // Set experiment-specific parameters
            MinSuccessDistance  = XmlUtils.GetValueAsInt(xmlConfig, "MinSuccessDistance");
            MazeHeight          = XmlUtils.GetValueAsInt(xmlConfig, "MazeHeight");
            MazeWidth           = XmlUtils.GetValueAsInt(xmlConfig, "MazeWidth");
            MazeQuadrantHeight  = XmlUtils.GetValueAsInt(xmlConfig, "MazeQuadrantHeight");
            MazeQuadrantWidth   = XmlUtils.GetValueAsInt(xmlConfig, "MazeQuadrantWidth");
            MazeScaleMultiplier = XmlUtils.GetValueAsInt(xmlConfig, "MazeScaleMultiplier");

            // Get success/failure criteria constraints
            NumMazeSuccessCriteria  = XmlUtils.GetValueAsInt(xmlConfig, "NumMazesSolvedCriteria");
            NumAgentSuccessCriteria = XmlUtils.GetValueAsInt(xmlConfig, "NumAgentsSolvedCriteria");
            NumAgentFailedCriteria  = XmlUtils.GetValueAsInt(xmlConfig, "NumAgentsFailedCriteria");

            // Read in the maximum number of initialization evaluations
            _maxInitializationEvaluations = XmlUtils.GetValueAsUInt(xmlConfig, "MaxInitializationEvaluations");

            // Initialize the initialization algorithm
            _mazeNavigationInitializer =
                ExperimentUtils.DetermineMCCInitializer(
                    xmlConfig.GetElementsByTagName("InitializationAlgorithmConfig", "")[0] as XmlElement);

            // Setup initialization algorithm
            _mazeNavigationInitializer.SetAlgorithmParameters(
                xmlConfig.GetElementsByTagName("InitializationAlgorithmConfig", "")[0] as XmlElement,
                ActivationScheme.AcyclicNetwork, NumAgentSuccessCriteria, 0);

            // Pass in maze experiment specific parameters
            // (note that a new maze structure is created here for the sole purpose of extracting the maze dimensions and calculating max distance to target)
            _mazeNavigationInitializer.SetEnvironmentParameters(MinSuccessDistance,
                                                                new MazeDecoder(MazeScaleMultiplier).Decode(
                                                                    new MazeGenomeFactory(MazeGenomeParameters, MazeHeight, MazeWidth, MazeQuadrantHeight,
                                                                                          MazeQuadrantWidth).CreateGenome(0)));

            // The size of the randomly generated agent genome pool from which to evolve agent bootstraps
            AgentInitializationGenomeCount = _mazeNavigationInitializer.PopulationSize;
        }