Пример #1
0
        /// <summary>
        /// Initialize the experiment with some optional XML configuration data.
        /// </summary>
        public void Initialize(string name, XmlElement xmlConfig)
        {
            _name                    = name;
            _populationSize          = XmlUtils.GetValueAsInt(xmlConfig, "PopulationSize");
            _specieCount             = XmlUtils.GetValueAsInt(xmlConfig, "SpecieCount");
            _activationScheme        = ExperimentUtils.CreateActivationScheme(xmlConfig, "Activation");
            _complexityRegulationStr = XmlUtils.TryGetValueAsString(xmlConfig, "ComplexityRegulationStrategy");
            _complexityThreshold     = XmlUtils.TryGetValueAsInt(xmlConfig, "ComplexityThreshold");
            _description             = XmlUtils.TryGetValueAsString(xmlConfig, "Description");
            _parallelOptions         = ExperimentUtils.ReadParallelOptions(xmlConfig);

            _eaParams                         = new NeatEvolutionAlgorithmParameters();
            _eaParams.SpecieCount             = _specieCount;
            _neatGenomeParams                 = new NeatGenomeParameters();
            _neatGenomeParams.FeedforwardOnly = _activationScheme.AcyclicNetwork;
            _neatGenomeParams.ActivationFn    = LeakyReLU.__DefaultInstance;
        }
        /// <summary>
        /// Initialize the experiment with some optional XML configutation data.
        /// </summary>
        public void Initialize(string name, XmlElement xmlConfig)
        {
            _name                    = name;
            _populationSize          = XmlUtils.GetValueAsInt(xmlConfig, "PopulationSize");
            _specieCount             = XmlUtils.GetValueAsInt(xmlConfig, "SpecieCount");
            _parasiteCount           = XmlUtils.GetValueAsInt(xmlConfig, "ParasiteCount");
            _championCount           = XmlUtils.GetValueAsInt(xmlConfig, "ChampionCount");
            _activationScheme        = ExperimentUtils.CreateActivationScheme(xmlConfig, "Activation");
            _complexityRegulationStr = XmlUtils.TryGetValueAsString(xmlConfig, "ComplexityRegulationStrategy");
            _complexityThreshold     = XmlUtils.TryGetValueAsInt(xmlConfig, "ComplexityThreshold");
            _description             = XmlUtils.TryGetValueAsString(xmlConfig, "Description");
            _parallelOptions         = ExperimentUtils.ReadParallelOptions(xmlConfig);

            _eaParams             = new NeatEvolutionAlgorithmParameters();
            _eaParams.SpecieCount = _specieCount;
            _neatGenomeParams     = new NeatGenomeParameters();
        }
Пример #3
0
        /// <summary>
        /// Initialize the experiment with some optional XML configutation data.
        /// </summary>
        public void Initialize(string name, XmlElement xmlConfig)
        {
            _name                    = name;
            _populationSize          = XmlUtils.GetValueAsInt(xmlConfig, "PopulationSize");
            _specieCount             = XmlUtils.GetValueAsInt(xmlConfig, "SpecieCount");
            _activationSchemeCppn    = ExperimentUtils.CreateActivationScheme(xmlConfig, "ActivationCppn");
            _activationScheme        = ExperimentUtils.CreateActivationScheme(xmlConfig, "Activation");
            _complexityRegulationStr = XmlUtils.TryGetValueAsString(xmlConfig, "ComplexityRegulationStrategy");
            _complexityThreshold     = XmlUtils.TryGetValueAsInt(xmlConfig, "ComplexityThreshold");
            _description             = XmlUtils.TryGetValueAsString(xmlConfig, "Description");
            _parallelOptions         = ExperimentUtils.ReadParallelOptions(xmlConfig);
            _lengthCppnInput         = XmlUtils.GetValueAsBool(xmlConfig, "LengthCppnInput");

            _eaParams                         = new NeatEvolutionAlgorithmParameters();
            _eaParams.SpecieCount             = _specieCount;
            _neatGenomeParams                 = new NeatGenomeParameters();
            _neatGenomeParams.FeedforwardOnly = _activationSchemeCppn.AcyclicNetwork;
            _neatGenomeParams.InitialInterconnectionsProportion = 0.5;
        }
Пример #4
0
        public void Initialize(string name, XmlElement xmlConfig)
        {
            // Read these from Domain XML file

            _name                    = name;
            _populationSize          = XmlUtils.GetValueAsInt(xmlConfig, "PopulationSize");
            _specieCount             = XmlUtils.GetValueAsInt(xmlConfig, "SpecieCount");
            _activationSchemeCppn    = ExperimentUtils.CreateActivationScheme(xmlConfig, "ActivationCppn");
            _activationScheme        = ExperimentUtils.CreateActivationScheme(xmlConfig, "Activation");
            _complexityRegulationStr = XmlUtils.TryGetValueAsString(xmlConfig, "ComplexityRegulationStrategy");
            _complexityThreshold     = XmlUtils.TryGetValueAsInt(xmlConfig, "ComplexityThreshold");
            _description             = XmlUtils.TryGetValueAsString(xmlConfig, "Description");
            _parallelOptions         = ExperimentUtils.ReadParallelOptions(xmlConfig);
            _parallelOptions.MaxDegreeOfParallelism = Environment.ProcessorCount / 2;


            _visualFieldResolution = XmlUtils.GetValueAsInt(xmlConfig, "Resolution");
            _visualFieldPixelCount = _visualFieldResolution * _visualFieldResolution;
            _lengthCppnInput       = XmlUtils.GetValueAsBool(xmlConfig, "LengthCppnInput");

            _eaParams             = new NeatEvolutionAlgorithmParameters();
            _eaParams.SpecieCount = _specieCount;

            // Set these manually, use a high mutator just to test the water

            _neatGenomeParams = new NeatGenomeParameters()
            {
                AddConnectionMutationProbability    = 0.10,
                DeleteConnectionMutationProbability = 0.10,
                ConnectionWeightMutationProbability = 0.90,
                AddNodeMutationProbability          = 0.05,
                InitialInterconnectionsProportion   = 0.10
            };

            // Clear OUTPUT and FITNESS directories before starting
            var directory = new DirectoryInfo(Constants.OUTPUT_DIR);

            directory.Empty();
            directory = new DirectoryInfo(Constants.FITNESS_DIR);
            directory.Empty();
            directory = new DirectoryInfo(Constants.PLOTS_DIR);
            directory.Empty();
        }
        /// <summary>
        /// Initialize the experiment with some optional XML configuration data.
        /// </summary>
        public void Initialize(string name, XmlElement xmlConfig)
        {
            _name                    = name;
            _populationSize          = XmlUtils.GetValueAsInt(xmlConfig, "PopulationSize");
            _specieCount             = XmlUtils.GetValueAsInt(xmlConfig, "SpecieCount");
            _activationSchemeCppn    = ExperimentUtils.CreateActivationScheme(xmlConfig, "ActivationCppn");
            _activationScheme        = ExperimentUtils.CreateActivationScheme(xmlConfig, "Activation");
            _complexityRegulationStr = XmlUtils.TryGetValueAsString(xmlConfig, "ComplexityRegulationStrategy");
            _complexityThreshold     = XmlUtils.TryGetValueAsInt(xmlConfig, "ComplexityThreshold");
            _description             = XmlUtils.TryGetValueAsString(xmlConfig, "Description");
            _parallelOptions         = ExperimentUtils.ReadParallelOptions(xmlConfig);

            _visualFieldResolution = XmlUtils.GetValueAsInt(xmlConfig, "Resolution");
            _visualFieldPixelCount = _visualFieldResolution * _visualFieldResolution;
            _lengthCppnInput       = XmlUtils.GetValueAsBool(xmlConfig, "LengthCppnInput");

            _eaParams             = new NeatEvolutionAlgorithmParameters();
            _eaParams.SpecieCount = _specieCount;
            _neatGenomeParams     = new NeatGenomeParameters();
        }
Пример #6
0
        public void Initialize(string name, XmlElement xmlConfig)
        {
            Name = name;
            DefaultPopulationSize    = XmlUtils.GetValueAsInt(xmlConfig, "PopulationSize");
            _specieCount             = XmlUtils.GetValueAsInt(xmlConfig, "SpecieCount");
            _activationScheme        = ExperimentUtils.CreateActivationScheme(xmlConfig, "Activation");
            _complexityRegulationStr = XmlUtils.TryGetValueAsString(xmlConfig, "ComplexityRegulationStrategy");
            _complexityThreshold     = XmlUtils.TryGetValueAsInt(xmlConfig, "ComplexityThreshold");
            Description      = XmlUtils.TryGetValueAsString(xmlConfig, "Description");
            _parallelOptions = ExperimentUtils.ReadParallelOptions(xmlConfig);

            NeatEvolutionAlgorithmParameters = new NeatEvolutionAlgorithmParameters {
                SpecieCount = _specieCount
            };
            NeatGenomeParameters = new NeatGenomeParameters {
                FeedforwardOnly = _activationScheme.AcyclicNetwork
            };
//            var figterType = XmlUtils.TryGetValueAsString(xmlConfig, "Figter");
//            var type = Type.GetType(figterType);
        }
Пример #7
0
        /// <summary>
        /// Initialize the experiment with some optional XML configutation data.
        /// </summary>
        public void Initialize(string name, XmlElement xmlConfig)
        {
            _name                    = name;
            _populationSize          = XmlUtils.GetValueAsInt(xmlConfig, "PopulationSize");
            _specieCount             = XmlUtils.GetValueAsInt(xmlConfig, "SpecieCount");
            _activationScheme        = ExperimentUtils.CreateActivationScheme(xmlConfig, "Activation");
            _complexityRegulationStr = XmlUtils.TryGetValueAsString(xmlConfig, "ComplexityRegulationStrategy");
            _complexityThreshold     = XmlUtils.TryGetValueAsInt(xmlConfig, "ComplexityThreshold");
            _description             = XmlUtils.TryGetValueAsString(xmlConfig, "Description");
            _parallelOptions         = ExperimentUtils.ReadParallelOptions(xmlConfig);
            ExperimentUtils.ReadRbfAuxArgMutationConfig(xmlConfig, out _rbfMutationSigmaCenter, out _rbfMutationSigmaRadius);

            _eaParams                         = new NeatEvolutionAlgorithmParameters();
            _eaParams.SpecieCount             = _specieCount;
            _neatGenomeParams                 = new NeatGenomeParameters();
            _neatGenomeParams.FeedforwardOnly = _activationScheme.AcyclicNetwork;
            _neatGenomeParams.ConnectionWeightMutationProbability = 0.788;
            _neatGenomeParams.AddConnectionMutationProbability    = 0.001;
            _neatGenomeParams.AddConnectionMutationProbability    = 0.01;
            _neatGenomeParams.NodeAuxStateMutationProbability     = 0.2;
            _neatGenomeParams.DeleteConnectionMutationProbability = 0.001;

            // Determine what function to regress.
            string     fnIdStr = XmlUtils.GetValueAsString(xmlConfig, "Function");
            FunctionId fnId    = (FunctionId)Enum.Parse(typeof(FunctionId), fnIdStr);

            _func = FunctionRegressionEvaluator.GetFunction(fnId);

            // Read parameter sampling scheme settings.
            int    sampleResolution = XmlUtils.GetValueAsInt(xmlConfig, "SampleResolution");
            double sampleMin        = XmlUtils.GetValueAsDouble(xmlConfig, "SampleMin");
            double sampleMax        = XmlUtils.GetValueAsDouble(xmlConfig, "SampleMax");

            int paramCount = _func.InputCount;

            _paramSamplingInfoArr = new ParameterSamplingInfo[paramCount];
            for (int i = 0; i < paramCount; i++)
            {
                _paramSamplingInfoArr[i] = new ParameterSamplingInfo(sampleMin, sampleMax, sampleResolution);
            }
        }
Пример #8
0
 public void Initialize(string name, XmlElement xmlConfig, string givenUserName)
 {
     _name           = name;
     _populationSize = XmlUtils.GetValueAsInt(xmlConfig, "PopulationSize");
     ActiveUsersList <NeatGenome> .PopulationSize = _populationSize;
     _specieCount             = XmlUtils.GetValueAsInt(xmlConfig, "SpecieCount");
     _activationScheme        = ExperimentUtils.CreateActivationScheme(xmlConfig, "Activation");
     _complexityRegulationStr = XmlUtils.TryGetValueAsString(xmlConfig, "ComplexityRegulationStrategy");
     _complexityThreshold     = XmlUtils.TryGetValueAsInt(xmlConfig, "ComplexityThreshold");
     _description             = XmlUtils.TryGetValueAsString(xmlConfig, "Description");
     ActiveUsersList <NeatGenome> .MaxNumberOfUsers =
         XmlUtils.GetValueAsInt(xmlConfig, "MaxSimultaneousUsers");
     ActiveUsersList <NeatGenome> .PortsPerUser =
         XmlUtils.GetValueAsInt(xmlConfig, "PortsPerUser");
     _parallelOptions      = ExperimentUtils.ReadParallelOptions(xmlConfig);
     _eaParams             = new NeatEvolutionAlgorithmParameters();
     _eaParams.SpecieCount = _specieCount;
     _neatGenomeParams     = new NeatGenomeParameters();
     System.Diagnostics.Debug.Assert(CheckActivationScheme(_activationScheme));
     userName = givenUserName;
 }
Пример #9
0
        /// <summary>
        /// Initialize the experiment with some optional XML configuration data.
        /// </summary>
        public void Initialize(string name, XmlElement xmlConfig)
        {
            T GetValueAsEnum <T>(string e)
            {
                string r = XmlUtils.GetValueAsString(xmlConfig, e);

                return((T)System.Enum.Parse(typeof(T), r));
            }

            _name                    = name;
            _populationSize          = XmlUtils.GetValueAsInt(xmlConfig, "PopulationSize");
            _specieCount             = XmlUtils.GetValueAsInt(xmlConfig, "SpecieCount");
            _activationScheme        = ExperimentUtils.CreateActivationScheme(xmlConfig, "Activation");
            _complexityRegulationStr = XmlUtils.TryGetValueAsString(xmlConfig, "ComplexityRegulationStrategy");
            _complexityThreshold     = XmlUtils.TryGetValueAsInt(xmlConfig, "ComplexityThreshold");

            _numberOfGames = XmlUtils.GetValueAsInt(xmlConfig, "IPDGames");
            int seed    = XmlUtils.GetValueAsInt(xmlConfig, "RandomPlayerSeed");
            int randoms = XmlUtils.GetValueAsInt(xmlConfig, "RandomPlayerCount");

            string os = XmlUtils.TryGetValueAsString(xmlConfig, "StaticOpponents");

            _opponentPool = CreatePool(seed, randoms, (os == null) ? new Opponent[0] : System.Array.ConvertAll(os.Split(','), (string o) => { return((Opponent)System.Enum.Parse(typeof(Opponent), o, true)); }));

            _evaluationLimit = (ulong)XmlUtils.GetValueAsInt(xmlConfig, "EvaluationLimit");
            _evaluationMode  = GetValueAsEnum <EvaluationMode>("EvaluationMode");
            _noveltyMetric   = GetValueAsEnum <NoveltyMetric>("NoveltyMetric");
            _noveltyK        = XmlUtils.GetValueAsInt(xmlConfig, "NoveltyK");

            _randomRobustCheck = XmlUtils.GetValueAsInt(xmlConfig, "RandomRobustCheck");
            _pastInputReach    = XmlUtils.GetValueAsInt(xmlConfig, "PastInputReach");

            _description     = XmlUtils.TryGetValueAsString(xmlConfig, "Description");
            _parallelOptions = ExperimentUtils.ReadParallelOptions(xmlConfig);

            _eaParams                         = new NeatEvolutionAlgorithmParameters();
            _eaParams.SpecieCount             = _specieCount;
            _neatGenomeParams                 = new NeatGenomeParameters();
            _neatGenomeParams.FeedforwardOnly = _activationScheme.AcyclicNetwork;
        }
Пример #10
0
        /// <summary>
        /// Initialize the experiment with some optional XML configuration data.
        /// </summary>
        public void Initialize(string name, XmlElement xmlConfig)
        {
            _name                    = name;
            _populationSize          = XmlUtils.GetValueAsInt(xmlConfig, "PopulationSize");
            _specieCount             = XmlUtils.GetValueAsInt(xmlConfig, "SpecieCount");
            _activationScheme        = ExperimentUtils.CreateActivationScheme(xmlConfig, "Activation");
            _complexityRegulationStr = XmlUtils.TryGetValueAsString(xmlConfig, "ComplexityRegulationStrategy");
            _complexityThreshold     = XmlUtils.TryGetValueAsInt(xmlConfig, "ComplexityThreshold");

            _trialsPerEvaluation = XmlUtils.GetValueAsInt(xmlConfig, "TrialsPerEvaluation");
            _gridSize            = XmlUtils.GetValueAsInt(xmlConfig, "GridSize");
            _preyInitMoves       = XmlUtils.GetValueAsInt(xmlConfig, "PreyInitMoves");
            _preySpeed           = XmlUtils.GetValueAsDouble(xmlConfig, "PreySpeed");
            _sensorRange         = XmlUtils.GetValueAsDouble(xmlConfig, "SensorRange");
            _maxTimesteps        = XmlUtils.GetValueAsInt(xmlConfig, "MaxTimesteps");
            _description         = XmlUtils.TryGetValueAsString(xmlConfig, "Description");
            _parallelOptions     = ExperimentUtils.ReadParallelOptions(xmlConfig);

            _eaParams             = new NeatEvolutionAlgorithmParameters();
            _eaParams.SpecieCount = _specieCount;
            _neatGenomeParams     = new NeatGenomeParameters();
        }
        /// <summary>
        /// Initialize the experiment with some optional XML configutation data.
        /// </summary>
        public void Initialize(string name, XmlElement xmlConfig)
        {
            _name                    = name;
            _populationSize          = XmlUtils.GetValueAsInt(xmlConfig, "PopulationSize");
            _specieCount             = XmlUtils.GetValueAsInt(xmlConfig, "SpecieCount");
            _activationScheme        = ExperimentUtils.CreateActivationScheme(xmlConfig, "Activation");
            _complexityRegulationStr = XmlUtils.TryGetValueAsString(xmlConfig, "ComplexityRegulationStrategy");
            _complexityThreshold     = XmlUtils.TryGetValueAsInt(xmlConfig, "ComplexityThreshold");
            _description             = XmlUtils.TryGetValueAsString(xmlConfig, "Description");
            _parallelOptions         = ExperimentUtils.ReadParallelOptions(xmlConfig);
            ExperimentUtils.ReadRbfAuxArgMutationConfig(xmlConfig, out _rbfMutationSigmaCenter, out _rbfMutationSigmaRadius);

            _eaParams             = new NeatEvolutionAlgorithmParameters();
            _eaParams.SpecieCount = _specieCount;
            _neatGenomeParams     = new NeatGenomeParameters();
            _neatGenomeParams.ConnectionWeightMutationProbability = 0.788;
            _neatGenomeParams.AddConnectionMutationProbability    = 0.001;
            _neatGenomeParams.AddConnectionMutationProbability    = 0.01;
            _neatGenomeParams.NodeAuxStateMutationProbability     = 0.2;
            _neatGenomeParams.DeleteConnectionMutationProbability = 0.001;
            _neatGenomeParams.FeedforwardOnly = _activationScheme.AcyclicNetwork;
        }
Пример #12
0
        /// <summary>
        /// Initialize the experiment with some optional XML configuration data.
        /// </summary>
        public void Initialize(string name, XmlElement xmlConfig)
        {
            _name                    = name;
            _populationSize          = XmlUtils.GetValueAsInt(xmlConfig, "PopulationSize");
            _specieCount             = XmlUtils.GetValueAsInt(xmlConfig, "SpecieCount");
            _activationScheme        = ExperimentUtils.CreateActivationScheme(xmlConfig, "Activation");
            _complexityRegulationStr = XmlUtils.TryGetValueAsString(xmlConfig, "ComplexityRegulationStrategy");
            _complexityThreshold     = XmlUtils.TryGetValueAsInt(xmlConfig, "ComplexityThreshold");
            _description             = XmlUtils.TryGetValueAsString(xmlConfig, "Description");
            _parallelOptions         = ExperimentUtils.ReadParallelOptions(xmlConfig);

            _eaParams                         = new NeatEvolutionAlgorithmParameters();
            _eaParams.SpecieCount             = _specieCount;
            _neatGenomeParams                 = new NeatGenomeParameters();
            _neatGenomeParams.FeedforwardOnly = _activationScheme.AcyclicNetwork;
            //_neatGenomeParams.ActivationFn = BipolarSigmoid.__DefaultInstance;
            //_neatGenomeParams.ActivationFn = LeakyReLU.__DefaultInstance; //Muy buen desempeño
            //_neatGenomeParams.ActivationFn = Linear.__DefaultInstance; //Meeh
            //_neatGenomeParams.ActivationFn = LogisticFunction.__DefaultInstance; //Estancamiento
            //_neatGenomeParams.ActivationFn = PolynomialApproximantSteep.__DefaultInstance; //Buen desempeño, permite mas complejidad
            //_neatGenomeParams.ActivationFn = SReLU.__DefaultInstance; //No ha mucha mejora respecto a los anteriores
            _neatGenomeParams.ActivationFn = PureLinear.__DefaultInstance;
        }
Пример #13
0
        /// <summary>
        /// Initialize the experiment with some optional XML configutation data.
        /// </summary>
        public void Initialize(string name, XmlElement xmlConfig)
        {
            _name                    = name;
            _populationSize          = XmlUtils.GetValueAsInt(xmlConfig, "PopulationSize");
            _specieCount             = XmlUtils.GetValueAsInt(xmlConfig, "SpecieCount");
            _activationScheme        = ExperimentUtils.CreateActivationScheme(xmlConfig, "Activation");
            _complexityRegulationStr = XmlUtils.TryGetValueAsString(xmlConfig, "ComplexityRegulationStrategy");
            _complexityThreshold     = XmlUtils.TryGetValueAsInt(xmlConfig, "ComplexityThreshold");
            _description             = XmlUtils.TryGetValueAsString(xmlConfig, "Description");
            _parallelOptions         = ExperimentUtils.ReadParallelOptions(xmlConfig);

            _eaParams                            = new NeatEvolutionAlgorithmParameters();
            _eaParams.SpecieCount                = _specieCount;
            _eaParams.SelectionProportion        = 0.4;
            _eaParams.ElitismProportion          = 0.8;
            _eaParams.OffspringAsexualProportion = 0.95;
            _eaParams.OffspringSexualProportion  = 0.05;

            _neatGenomeParams = new NeatGenomeParameters();
            _neatGenomeParams.AddConnectionMutationProbability    = 0.08;
            _neatGenomeParams.AddNodeMutationProbability          = 0.01;
            _neatGenomeParams.ConnectionWeightMutationProbability = 0.91;
            _neatGenomeParams.FitnessHistoryLength = 4;
        }
 /// <summary>
 /// Initialize the experiment with some optional XML configuration data.
 /// </summary>
 public void Initialize(string name, XmlElement xmlConfig)
 {
     _name                             = name;
     _populationSize                   = XmlUtils.GetValueAsInt(xmlConfig, "PopulationSize");
     _specieCount                      = XmlUtils.GetValueAsInt(xmlConfig, "SpecieCount");
     _activationScheme                 = ExperimentUtils.CreateActivationScheme(xmlConfig, "Activation");
     _complexityRegulationStr          = XmlUtils.TryGetValueAsString(xmlConfig, "ComplexityRegulationStrategy");
     _complexityThreshold              = XmlUtils.TryGetValueAsInt(xmlConfig, "ComplexityThreshold");
     _description                      = XmlUtils.TryGetValueAsString(xmlConfig, "Description");
     _parallelOptions                  = ExperimentUtils.ReadParallelOptions(xmlConfig);
     _seed                             = XmlUtils.GetValueAsInt(xmlConfig, "Seed");
     _datasetPath                      = XmlUtils.TryGetValueAsString(xmlConfig, "DatasetPath");
     _normalizeData                    = XmlUtils.GetValueAsBool(xmlConfig, "NormalizeData");
     _normalizeRange                   = XmlUtils.GetValueAsInt(xmlConfig, "NormalizeRange");
     _dataLoader                       = new EasyChangeDataLoader();
     _eaParams                         = new NeatEvolutionAlgorithmParameters();
     _eaParams.SpecieCount             = _specieCount;
     _neatGenomeParams                 = new NeatGenomeParameters();
     _neatGenomeParams.FeedforwardOnly = _activationScheme.AcyclicNetwork;
     _neatGenomeParams.ActivationFn    = LeakyReLU.__DefaultInstance;
     _maxGen                           = XmlUtils.GetValueAsInt(xmlConfig, "MaxGen");
     _testPorcentage                   = (XmlUtils.GetValueAsInt(xmlConfig, "TestPorcentage") * 1.0) / 100;
     _savePeriod                       = XmlUtils.GetValueAsInt(xmlConfig, "SavePeriod");
 }
Пример #15
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;
        }
Пример #16
0
        /// <summary>
        /// Initialize the experiment with some optional XML configutation data.
        /// </summary>
        public virtual void Initialize(string name, XmlElement xmlConfig)
        {
            _name             = name;
            _description      = XmlUtils.TryGetValueAsString(xmlConfig, "Description") ?? "";
            _comment          = XmlUtils.TryGetValueAsString(xmlConfig, "Comment") ?? "";
            _populationSize   = XmlUtils.TryGetValueAsInt(xmlConfig, "PopulationSize") ?? 100;
            _maxGenerations   = XmlUtils.TryGetValueAsInt(xmlConfig, "MaxGenerations") ?? 1000;
            _activationScheme = ExperimentUtils.CreateActivationScheme(xmlConfig, "Activation");
            SeedGenome        = XmlUtils.TryGetValueAsString(xmlConfig, "SeedGenome");
            try
            {
                _complexityRegulationStrategy = ExperimentUtils.CreateComplexityRegulationStrategy(xmlConfig, "ComplexityRegulation");
            }
            catch (ArgumentException e)
            {
                _logger.Warn(e.Message);
            }

            _parallelOptions = ExperimentUtils.ReadParallelOptions(xmlConfig);
            _multiThreading  = XmlUtils.TryGetValueAsBool(xmlConfig, "MultiThreading") ?? true;
            _logInterval     = XmlUtils.TryGetValueAsInt(xmlConfig, "LogInterval") ?? 10;

            // Evolutionary algorithm parameters
            _eaParams = new NeatEvolutionAlgorithmParameters();

            XmlElement xmlEAParams = xmlConfig.SelectSingleNode("EAParams") as XmlElement;

            if (xmlEAParams != null)
            {
                _eaParams.SpecieCount                  = XmlUtils.GetValueAsInt(xmlEAParams, "SpecieCount");
                _eaParams.ElitismProportion            = XmlUtils.GetValueAsDouble(xmlEAParams, "ElitismProportion");
                _eaParams.SelectionProportion          = XmlUtils.GetValueAsDouble(xmlEAParams, "SelectionProportion");
                _eaParams.OffspringAsexualProportion   = XmlUtils.GetValueAsDouble(xmlEAParams, "OffspringAsexualProportion");
                _eaParams.OffspringSexualProportion    = XmlUtils.GetValueAsDouble(xmlEAParams, "OffspringSexualProportion");
                _eaParams.InterspeciesMatingProportion = XmlUtils.GetValueAsDouble(xmlEAParams, "InterspeciesMatingProportion");
            }
            else
            {
                _logger.Info("EA parameters not found. Using default.");
            }

            // NEAT Genome parameters
            _neatGenomeParams = new NeatGenomeParameters();

            // Prevent recurrent connections if the activation scheme is acyclic
            _neatGenomeParams.FeedforwardOnly = _activationScheme.AcyclicNetwork;

            XmlElement xmlGenomeParams = xmlConfig.SelectSingleNode("GenomeParams") as XmlElement;

            if (xmlGenomeParams != null)
            {
                _neatGenomeParams.ConnectionWeightRange                    = XmlUtils.GetValueAsDouble(xmlGenomeParams, "ConnectionWeightRange");
                _neatGenomeParams.InitialInterconnectionsProportion        = XmlUtils.GetValueAsDouble(xmlGenomeParams, "InitialInterconnectionsProportion");
                _neatGenomeParams.DisjointExcessGenesRecombinedProbability = XmlUtils.GetValueAsDouble(xmlGenomeParams, "DisjointExcessGenesRecombinedProbability");
                _neatGenomeParams.ConnectionWeightMutationProbability      = XmlUtils.GetValueAsDouble(xmlGenomeParams, "ConnectionWeightMutationProbability");
                _neatGenomeParams.AddNodeMutationProbability               = XmlUtils.GetValueAsDouble(xmlGenomeParams, "AddNodeMutationProbability");
                _neatGenomeParams.AddConnectionMutationProbability         = XmlUtils.GetValueAsDouble(xmlGenomeParams, "AddConnectionMutationProbability");
                _neatGenomeParams.DeleteConnectionMutationProbability      = XmlUtils.GetValueAsDouble(xmlGenomeParams, "DeleteConnectionMutationProbability");
            }
            else
            {
                _logger.Info("Genome parameters not found. Using default.");
            }

            XmlElement xmlNoveltySearchParams = xmlConfig.SelectSingleNode("NoveltySearch") as XmlElement;

            if (xmlNoveltySearchParams != null)
            {
                _noveltySearchParams = NoveltySearchParameters.ReadXmlProperties(xmlNoveltySearchParams);
            }
            else
            {
                _logger.Info("Novelty search parameters not found");
            }

            XmlElement xmlMultiObjectiveParams = xmlConfig.SelectSingleNode("MultiObjective") as XmlElement;

            if (xmlMultiObjectiveParams != null)
            {
                _multiObjectiveParams = MultiObjectiveParameters.ReadXmlProperties(xmlMultiObjectiveParams);
            }
            else
            {
                _logger.Info("Multi objective parameters not found");
            }

            // Create IBlackBox evaluator.
            _evaluator = new TEvaluator();
            _evaluator.Initialize(xmlConfig);
            _evaluator.NoveltySearchParameters = _noveltySearchParams;
        }