Represents parameters specific to NEAT genomes. E.g. parameters that describe probabilities for the different types of mutation and the proportion of possible connections to instantiate between input and output neurons within the initial population.
Ejemplo n.º 1
0
 /// <summary>
 /// Constructs with the provided IActivationFunctionLibrary, NeatGenomeParameters and ID generators.
 /// </summary>
 public CppnGenomeFactory(int inputNeuronCount, int outputNeuronCount,
                          IActivationFunctionLibrary activationFnLibrary,
                          NeatGenomeParameters neatGenomeParams,
                          UInt32IdGenerator genomeIdGenerator, UInt32IdGenerator innovationIdGenerator)
     : base(inputNeuronCount, outputNeuronCount, activationFnLibrary, neatGenomeParams, genomeIdGenerator, innovationIdGenerator)
 {
 }
Ejemplo n.º 2
0
        public virtual  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,
                "DefaultComplexityRegulationStrategy");
            _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;

            DefaultComplexityRegulationStrategy = ExperimentUtils.CreateComplexityRegulationStrategy(
                _complexityRegulationStr,
                _complexityThreshold);
            DefaultSpeciationStrategy = new KMeansClusteringStrategy<NeatGenome>(new ManhattanDistanceMetric(1.0, 0.0, 10.0));
            DefaultNeatEvolutionAlgorithm = new NeatEvolutionAlgorithm<NeatGenome>(
                    NeatEvolutionAlgorithmParameters,
                    DefaultSpeciationStrategy,
                    DefaultComplexityRegulationStrategy);
        }
 public AutoencoderGenomeFactory(int inputNeuronCount, int outputNeuronCount, int hiddenNeuronCount,
     NeatGenomeParameters neatGenomeParams, UInt32IdGenerator genomeIdGenerator,
     UInt32IdGenerator innovationIdGenerator)
     : base(inputNeuronCount, outputNeuronCount, neatGenomeParams, genomeIdGenerator, innovationIdGenerator)
 {
     _hiddenNeuronCount = hiddenNeuronCount;
 }
Ejemplo n.º 4
0
        public NeatTrainer(ExperimentSettings experimentSettings, NeatEvolutionAlgorithmParameters evolutionAlgorithmParameters, TrainingGameSettings gameSettings)
        {
            var neuromonPhenomeEvaluator = new NeuromonEvaluator(gameSettings, experimentSettings);
            var neatGenomeParameters = new NeatGenomeParameters();

            _neuromonExperiment = new NeuromonExperiment(experimentSettings, evolutionAlgorithmParameters, neuromonPhenomeEvaluator, neatGenomeParameters);

            _genomeIo = new GenomeIo(_neuromonExperiment);
            _genomeFactory = _neuromonExperiment.CreateGenomeFactory();

            if (experimentSettings.LoadExistingPopulation)
            {
                _genomePopulation = _genomeIo.Read(experimentSettings.ExistingPopulationFilePath);
            }
            else
            {
                // Randomly generate a new population
                _genomePopulation = _genomeFactory.CreateGenomeList(experimentSettings.PopulationSize, 0);
            }

            _genomeIo.CacheChampion(_genomePopulation.OrderByDescending(g => g.EvaluationInfo.Fitness).First());

            _fitnessStagnationDetector = new FitnessStagnationDetector(experimentSettings.StagnationDetectionTriggerValue);

            _desiredFitness = experimentSettings.DesiredFitness;

            _previousGeneration = 0;
            _overallBestFitness = 0.0;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Creates parameters suitable for use during the simplifying mode of a NEAT search. Addition
        /// mutations are disabled, deletion and weight mutation rates are increased.
        /// </summary>
        public static NeatGenomeParameters CreateParametersForBigChanges(NeatGenomeParameters copyFrom)
        {
            NeatGenomeParameters newParams = new NeatGenomeParameters(copyFrom);

            newParams._connectionMutationInfoList = null;
            newParams._connectionMutationInfoList = CreateLargeMutationsScheme();
            newParams._connectionMutationInfoList.Initialize();
            return(newParams);
        }
Ejemplo n.º 6
0
 private void initialize()
 {
     EvoParameters = new NeatEvolutionAlgorithmParameters()
     {
         SpecieCount = Parameters.Species
     };
     NeatParameters = new NeatGenomeParameters()
     {
         ActivationFn = PlainSigmoid.__DefaultInstance
     };
 }
        /// <summary>
        /// Constructs a NeatGenomeFactory with the provided NeatGenomeParameters and ID generators initialized to zero.
        /// </summary>
        public NeatGenomeFactory(int inputNeuronCount, int outputNeuronCount,
                                 NeatGenomeParameters neatGenomeParams)
        {
            _inputNeuronCount    = inputNeuronCount;
            _outputNeuronCount   = outputNeuronCount;
            _activationFnLibrary = DefaultActivationFunctionLibrary.CreateLibraryNeat(neatGenomeParams.ActivationFn);

            _neatGenomeParamsCurrent       = neatGenomeParams;
            _neatGenomeParamsComplexifying = _neatGenomeParamsCurrent;
            _neatGenomeParamsSimplifying   = NeatGenomeParameters.CreateSimplifyingParameters(_neatGenomeParamsComplexifying);

            _genomeIdGenerator     = new UInt32IdGenerator();
            _innovationIdGenerator = new UInt32IdGenerator();
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Creates parameters suitable for use during the simplifying mode of a NEAT search. Addition
        /// mutations are disabled, deletion and weight mutation rates are increased.
        /// </summary>
        public static NeatGenomeParameters CreateSimplifyingParameters(NeatGenomeParameters copyFrom)
        {
            NeatGenomeParameters newParams = new NeatGenomeParameters(copyFrom);

            newParams._connectionWeightMutationProbability = 0.6;
            newParams._addNodeMutationProbability          = 0.0;
            newParams._addConnectionMutationProbability    = 0.0;
            newParams._nodeAuxStateMutationProbability     = copyFrom._nodeAuxStateMutationProbability;
            newParams._deleteConnectionMutationProbability = 0.4;
            newParams._rouletteWheelLayout = newParams.CreateRouletteWheelLayout();
            newParams._rouletteWheelLayoutNonDestructive = newParams.CreateRouletteWheelLayout_NonDestructive();

            newParams._connectionMutationInfoList = new ConnectionMutationInfoList(copyFrom._connectionMutationInfoList);
            newParams._connectionMutationInfoList.Initialize();
            return(newParams);
        }
        /// <summary>
        /// Constructs with the provided IActivationFunctionLibrary, NeatGenomeParameters and
        /// ID Generators.
        /// This overload required for CPPN support.
        /// </summary>
        public NeatGenomeFactory(int inputNeuronCount, int outputNeuronCount,
                                 IActivationFunctionLibrary activationFnLibrary,
                                 NeatGenomeParameters neatGenomeParams,
                                 UInt32IdGenerator genomeIdGenerator,
                                 UInt32IdGenerator innovationIdGenerator)
        {
            _inputNeuronCount    = inputNeuronCount;
            _outputNeuronCount   = outputNeuronCount;
            _activationFnLibrary = activationFnLibrary;

            _neatGenomeParamsCurrent       = neatGenomeParams;
            _neatGenomeParamsComplexifying = _neatGenomeParamsCurrent;
            _neatGenomeParamsSimplifying   = NeatGenomeParameters.CreateSimplifyingParameters(_neatGenomeParamsComplexifying);

            _genomeIdGenerator     = genomeIdGenerator;
            _innovationIdGenerator = innovationIdGenerator;
        }
        /// <summary>
        ///     Initialize the experiment with configuration file parameters.
        /// </summary>
        /// <param name="name">The name of the experiment</param>
        /// <param name="xmlConfig">The parent XML configuration element</param>
        public void Initialize(string name, XmlElement xmlConfig)
        {
            // Set all properties
            Name = name;
            DefaultPopulationSize = XmlUtils.GetValueAsInt(xmlConfig, "PopulationSize");
            Description = XmlUtils.GetValueAsString(xmlConfig, "Description");

            // Set all internal class variables
            _activationScheme = ExperimentUtils.CreateActivationScheme(xmlConfig, "Activation");
            _complexityRegulationStrategy = XmlUtils.TryGetValueAsString(xmlConfig, "ComplexityRegulationStrategy");
            _complexitythreshold = XmlUtils.TryGetValueAsInt(xmlConfig, "ComplexityThreshold");
            _parallOptions = ExperimentUtils.ReadParallelOptions(xmlConfig);

            // Set evolution/genome parameters
            NeatEvolutionAlgorithmParameters = new NeatEvolutionAlgorithmParameters();
            NeatEvolutionAlgorithmParameters.SpecieCount = XmlUtils.GetValueAsInt(xmlConfig, "SpecieCount");
            NeatGenomeParameters = new NeatGenomeParameters();
        }
Ejemplo n.º 11
0
        public NeuromonExperiment(ExperimentSettings experimentSettings, NeatEvolutionAlgorithmParameters evolutionAlgorithmParameters, IPhenomeEvaluator<IBlackBox> neuromonPhenomeEvaluator, NeatGenomeParameters genomeParameters)
        {
            Name = experimentSettings.ExperimentName;
            Description = experimentSettings.Description;
            InputCount = experimentSettings.InputCount;
            OutputCount = experimentSettings.OutputCount;
            DefaultPopulationSize = experimentSettings.PopulationSize;

            _neuromonPhenomeEvaluator = neuromonPhenomeEvaluator;
            _complexityRegulationStrategy = experimentSettings.ComplexityRegulationStrategy;
            _complexityThreshold = experimentSettings.ComplexityThreshold;

            // Removed from .xml configuration. TODO: Possibly make configurable via json config
            _networkActivationScheme = NetworkActivationScheme.CreateCyclicFixedTimestepsScheme(1);

            NeatEvolutionAlgorithmParameters = evolutionAlgorithmParameters;
            NeatGenomeParameters = genomeParameters;
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Copy constructor.
        /// </summary>
        public NeatGenomeParameters(NeatGenomeParameters copyFrom)
        {
            _feedforwardOnly                         = copyFrom._feedforwardOnly;
            _activationFn                            = copyFrom._activationFn;
            _connectionWeightRange                   = copyFrom._connectionWeightRange;
            _initialInterconnectionsProportion       = copyFrom._initialInterconnectionsProportion;
            _disjointExcessGenesRecombineProbability = copyFrom._disjointExcessGenesRecombineProbability;
            _connectionWeightMutationProbability     = copyFrom._connectionWeightMutationProbability;
            _addNodeMutationProbability              = copyFrom._addNodeMutationProbability;
            _addConnectionMutationProbability        = copyFrom._addConnectionMutationProbability;
            _nodeAuxStateMutationProbability         = copyFrom._nodeAuxStateMutationProbability;
            _deleteConnectionMutationProbability     = copyFrom._deleteConnectionMutationProbability;

            _rouletteWheelLayout = new RouletteWheelLayout(copyFrom._rouletteWheelLayout);
            _rouletteWheelLayoutNonDestructive = new RouletteWheelLayout(copyFrom._rouletteWheelLayoutNonDestructive);

            _connectionMutationInfoList = new ConnectionMutationInfoList(copyFrom._connectionMutationInfoList);
            _connectionMutationInfoList.Initialize();
            _fitnessHistoryLength = copyFrom._fitnessHistoryLength;
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Creates parameters suitable for use during the simplifying mode of a NEAT search. Addition
        /// mutations are disabled, deletion and weight mutation rates are increased.
        /// </summary>
        public static NeatGenomeParameters CreateSimplifyingParameters(NeatGenomeParameters copyFrom)
        {
            NeatGenomeParameters newParams = new NeatGenomeParameters(copyFrom);

            newParams._connectionWeightMutationProbability = 0.6;
            newParams._addNodeMutationProbability          = 0.0;
            newParams._addConnectionMutationProbability    = 0.0;
            // TODO: better method for automatically generating simplifying parameters?
            newParams._nodeAuxStateMutationProbability     = copyFrom._nodeAuxStateMutationProbability;
            newParams._deleteConnectionMutationProbability = 0.4;
            newParams._rouletteWheelLayout = newParams.CreateRouletteWheelLayout();
            newParams._rouletteWheelLayoutNonDestructive = newParams.CreateRouletteWheelLayout_NonDestructive();

            newParams._connectionMutationInfoList = new ConnectionMutationInfoList(copyFrom._connectionMutationInfoList);

            // SharpNEAT version 1.x used this scheme.
            // newParams._connectionMutationInfoList.Add(new ConnectionMutationInfo(0.333, ConnectionPerturbanceType.JiggleUniform, ConnectionSelectionType.Proportional, 0.3, 0, 0.05, 0.0));
            // newParams._connectionMutationInfoList.Add(new ConnectionMutationInfo(0.333, ConnectionPerturbanceType.JiggleUniform, ConnectionSelectionType.Proportional, 0.1, 0, 0.05, 0.0));
            // newParams._connectionMutationInfoList.Add(new ConnectionMutationInfo(0.333, ConnectionPerturbanceType.JiggleUniform, ConnectionSelectionType.Proportional, 0.01, 0, 0.05, 0.0));
            newParams._connectionMutationInfoList.Initialize();
            return(newParams);
        }
 private CppnGenomeFactory CreateGenomeFactory()
 {
     var neatGenomeParams = new NeatGenomeParameters();
     neatGenomeParams.FeedforwardOnly = true;
     return new CppnGenomeFactory(InputCount, OutputCount, DefaultActivationFunctionLibrary.CreateLibraryCppn(), neatGenomeParams);
 }
        /// <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;

            // 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);
            }
        }
        /// <summary>
        ///     Initialize the experiment with configuration file parameters.
        /// </summary>
        /// <param name="name">The name of the experiment</param>
        /// <param name="xmlConfig">The parent XML configuration element</param>
        public virtual void Initialize(string name, XmlElement xmlConfig)
        {
            // Set all properties
            Name = name;
            DefaultPopulationSize = XmlUtils.GetValueAsInt(xmlConfig, "PopulationSize");
            Description = XmlUtils.GetValueAsString(xmlConfig, "Description");

            // Set all internal class variables
            _activationScheme = ExperimentUtils.CreateActivationScheme(xmlConfig, "Activation");
            ComplexityRegulationStrategy = XmlUtils.TryGetValueAsString(xmlConfig, "ComplexityRegulationStrategy");
            Complexitythreshold = XmlUtils.TryGetValueAsInt(xmlConfig, "ComplexityThreshold");
            ParallelOptions = ExperimentUtils.ReadParallelOptions(xmlConfig);

            // Set evolution/genome parameters
            NeatEvolutionAlgorithmParameters = new NeatEvolutionAlgorithmParameters
            {
                SpecieCount = XmlUtils.GetValueAsInt(xmlConfig, "SpecieCount"),
                InterspeciesMatingProportion = XmlUtils.GetValueAsDouble(xmlConfig,
                    "InterspeciesMatingProbability"),
                MinTimeAlive = XmlUtils.GetValueAsInt(xmlConfig, "MinTimeAlive")
            };
            NeatGenomeParameters = ExperimentUtils.ReadNeatGenomeParameters(xmlConfig);

            // Set experiment-specific parameters
            MaxTimesteps = XmlUtils.TryGetValueAsInt(xmlConfig, "MaxTimesteps");
            MinSuccessDistance = XmlUtils.TryGetValueAsInt(xmlConfig, "MinSuccessDistance");
            MaxDistanceToTarget = XmlUtils.TryGetValueAsInt(xmlConfig, "MaxDistanceToTarget");
            MazeVariant =
                MazeVariantUtl.convertStringToMazeVariant(XmlUtils.TryGetValueAsString(xmlConfig, "MazeVariant"));         
        }
Ejemplo n.º 17
0
 /// <summary>
 /// Constructs with the provided IActivationFunctionLibrary and NeatGenomeParameters.
 /// </summary>
 public CppnGenomeFactory(int inputNeuronCount, int outputNeuronCount,
                          IActivationFunctionLibrary activationFnLibrary,
                          NeatGenomeParameters neatGenomeParams)
     : base(inputNeuronCount,outputNeuronCount, activationFnLibrary, neatGenomeParams)
 {
 }
        /// <summary>
        /// Creates parameters suitable for use during the simplifying mode of a NEAT search. Addition 
        /// mutations are disabled, deletion and weight mutation rates are increased.
        /// </summary>
        public static NeatGenomeParameters CreateSimplifyingParameters(NeatGenomeParameters copyFrom)
        {
            NeatGenomeParameters newParams = new NeatGenomeParameters(copyFrom);
            newParams._connectionWeightMutationProbability = 0.6;
            newParams._addNodeMutationProbability = 0.0;
            newParams._addConnectionMutationProbability = 0.0;
            // TODO: better method for automatically generating simplifying parameters?
            newParams._nodeAuxStateMutationProbability = copyFrom._nodeAuxStateMutationProbability;
            newParams._deleteConnectionMutationProbability = 0.4;
            newParams._rouletteWheelLayout = newParams.CreateRouletteWheelLayout();
            newParams._rouletteWheelLayoutNonDestructive = newParams.CreateRouletteWheelLayout_NonDestructive();

            newParams._connectionMutationInfoList = new ConnectionMutationInfoList(copyFrom._connectionMutationInfoList);

            // SharpNEAT version 1.x used this scheme.
            // newParams._connectionMutationInfoList.Add(new ConnectionMutationInfo(0.333, ConnectionPerturbanceType.JiggleUniform, ConnectionSelectionType.Proportional, 0.3, 0, 0.05, 0.0));
            // newParams._connectionMutationInfoList.Add(new ConnectionMutationInfo(0.333, ConnectionPerturbanceType.JiggleUniform, ConnectionSelectionType.Proportional, 0.1, 0, 0.05, 0.0));
            // newParams._connectionMutationInfoList.Add(new ConnectionMutationInfo(0.333, ConnectionPerturbanceType.JiggleUniform, ConnectionSelectionType.Proportional, 0.01, 0, 0.05, 0.0));
            newParams._connectionMutationInfoList.Initialize();
            return newParams;
        }
        /// <summary>
        /// Copy constructor.
        /// </summary>
        public NeatGenomeParameters(NeatGenomeParameters copyFrom)
        {
            _feedforwardOnly                            = copyFrom._feedforwardOnly;
            _activationFn                               = copyFrom._activationFn;
            _connectionWeightRange                      = copyFrom._connectionWeightRange;
            _initialInterconnectionsProportion          = copyFrom._initialInterconnectionsProportion;
            _disjointExcessGenesRecombineProbability    = copyFrom._disjointExcessGenesRecombineProbability;
            _connectionWeightMutationProbability        = copyFrom._connectionWeightMutationProbability;
            _addNodeMutationProbability                 = copyFrom._addNodeMutationProbability;
            _addConnectionMutationProbability           = copyFrom._addConnectionMutationProbability;
            _nodeAuxStateMutationProbability            = copyFrom._nodeAuxStateMutationProbability;
            _deleteConnectionMutationProbability        = copyFrom._deleteConnectionMutationProbability;

            _rouletteWheelLayout = new RouletteWheelLayout(copyFrom._rouletteWheelLayout);
            _rouletteWheelLayoutNonDestructive = new RouletteWheelLayout(copyFrom._rouletteWheelLayoutNonDestructive);
            
            _connectionMutationInfoList = new ConnectionMutationInfoList(copyFrom._connectionMutationInfoList);
            _connectionMutationInfoList.Initialize();
            _fitnessHistoryLength = copyFrom._fitnessHistoryLength;
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Initialize the experiment with some optional XML configutation data.
        /// </summary>
        public void Initialize(string name, XmlElement xmlConfig)
        {
            _name = name;
            var outputs = XmlUtils.TryGetValueAsInt(xmlConfig, "Outputs");
            _outputs = outputs.HasValue ? outputs.Value : 2;
            _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");
            _timeStepsPerGeneration = (ulong)XmlUtils.GetValueAsInt(xmlConfig, "TimeStepsPerGeneration");
            
            
            _eaParams = new NeatEvolutionAlgorithmParameters();
            _eaParams.SpecieCount = _specieCount;
            _neatGenomeParams = new NeatGenomeParameters()
            {
                ActivationFn = PlainSigmoid.__DefaultInstance,
                InitialInterconnectionsProportion = 1,

            };
        }
Ejemplo n.º 21
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;
            _eaParams.SelectionProportion = 0.5;
            _eaParams.ElitismProportion = 0.5;
            _eaParams.OffspringAsexualProportion = 0.95;
            _eaParams.OffspringSexualProportion = 0.05;
            _eaParams.InterspeciesMatingProportion = 0.00;

            _neatGenomeParams = new NeatGenomeParameters();
            _neatGenomeParams.AddConnectionMutationProbability = 0.1;
            _neatGenomeParams.AddNodeMutationProbability = 0.01;
            _neatGenomeParams.ConnectionWeightMutationProbability = 0.89;
            _neatGenomeParams.InitialInterconnectionsProportion = 0.05;
        }
        /// <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");

            _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;
            _description = "Just a test experiment class";

            // Dont use xml, just hard code the values for now
            _populationSize = 50;
            _specieCount = 5;

            // PicBreeder appears to use acyclic networks, so we will do the same.
            // Cyclic ("recurrent") networks seem better for realtime reactive controllers, e.g. predator-prey, where the recurrent connections allow for memory of past events
            _activationScheme = NetworkActivationScheme.CreateAcyclicScheme();

            // Next two values just seem to be commen.
            // Relative just means that limit of complexification is relative to the last simplification process (so it can continue to grow)
            // Alternative is "Absolute", which means, with a threshold of 10, network wont ever be more complex than 10 connections
            _complexityRegulationStr = "Absolute";
            _complexityThreshold = 50;

            //_parallelOptions = new ParallelOptions();

            // Param constructors set defaul param values, a lot of experiments just leave them as default
            _eaParams = new NeatEvolutionAlgorithmParameters();
            _eaParams.SpecieCount = _specieCount;
            _neatGenomeParams = new NeatGenomeParameters();
            _neatGenomeParams.FeedforwardOnly = _activationScheme.AcyclicNetwork;
    }
Ejemplo n.º 24
0
        /// <summary>
        ///     Initialize the experiment with some optional XML configutation data.
        /// </summary>
        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);
            _generationalLogFile = XmlUtils.TryGetValueAsString(xmlConfig, "GenerationalLogFile");

            NeatEvolutionAlgorithmParameters = new NeatEvolutionAlgorithmParameters();
            NeatEvolutionAlgorithmParameters.SpecieCount = _specieCount;
            NeatGenomeParameters = new NeatGenomeParameters();
            NeatGenomeParameters.FeedforwardOnly = _activationScheme.AcyclicNetwork;
            NeatGenomeParameters.ActivationFn = PlainSigmoid.__DefaultInstance;
        }
Ejemplo n.º 25
0
 public void Initialize(string name, XmlElement xmlConfig)
 {
     NeatEvolutionAlgorithmParameters = new NeatEvolutionAlgorithmParameters();
     NeatEvolutionAlgorithmParameters.SpecieCount = 10;
     // The NeatGenomeParameters object is passed to the NeatGenomeFactory.
     // The NeatGenomeFactory creates a NeatGenome (which is an INetworkDefinition).
     // The NeatGenome is constructed using the NeatGenomeParameters.
     // For example, the NeatGenomeParameters define what activation function to use.
     NeatGenomeParameters = new NeatGenomeParameters();
     // Create fast cyclic activation scheme with 3 evaluations for convergence
     _activationScheme = NetworkActivationScheme.CreateCyclicFixedTimestepsScheme(3,true);
 }
        /// <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");
            _complexityThreshold = XmlUtils.TryGetValueAsInt(xmlConfig, "ComplexityThreshold");
            _description = XmlUtils.TryGetValueAsString(xmlConfig, "Description");
            _parallelOptions = ExperimentUtils.ReadParallelOptions(xmlConfig);

            _guesses = XmlUtils.GetValueAsInt(xmlConfig, "Guesses");
            Hashed = XmlUtils.TryGetValueAsBool(xmlConfig, "Hashed").HasValue ? XmlUtils.GetValueAsBool(xmlConfig, "Hashed") : false;
            ValidationGuesses = XmlUtils.GetValueAsInt(xmlConfig, "ValidationGuesses");

            // Load the passwords from file
            string pwdfile = XmlUtils.TryGetValueAsString(xmlConfig, "ValidationPasswordFile");
            if (pwdfile != null)
            {
                Console.Write("Loading passwords from [{0}]...", pwdfile);
                if (_passwords == null || _passwords.Count == 0)
                {
                    int? pwLength = XmlUtils.TryGetValueAsInt(xmlConfig, "PasswordLength");
                    if (pwLength.HasValue)
                        Console.Write("Filtering to {0}-character passwords...", pwLength.Value);
                    _passwords = PasswordUtil.LoadPasswords(pwdfile, pwLength);
                }
                else
                    Console.WriteLine("WARNING: Not loading passwords for experiment (already set)");
            }
            else
                Console.WriteLine("WARNING: Not loading passwords for experiment (not provided in config file)");
            _eaParams = new NeatEvolutionAlgorithmParameters();
            _eaParams.SpecieCount = _specieCount;
            _neatGenomeParams = new NeatGenomeParameters();
            _neatGenomeParams.FeedforwardOnly = false;
            _neatGenomeParams.AddNodeMutationProbability = 0.03;
            _neatGenomeParams.AddConnectionMutationProbability = 0.05;

            // TODO: Load states from XML config file
            // Generates all the valid states in the MC using all viable ASCII characters
            var stateList = new List<string>();
            for (uint i = 32; i < 127; i++)
                stateList.Add(((char)i).ToString());
            stateList.Add(null);
            _states = stateList.ToArray();
            _activationFnLibrary = MarkovActivationFunctionLibrary.CreateLibraryMc(_states);
        }
        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>
        ///     Initializes the experiment with some optional XML configutation data.
        /// </summary>
        /// <param name="name">The name of the experiment.</param>
        /// <param name="xmlConfig">The reference to the top-level configuration element for the experiment.</param>
        public void Initialize(string name, XmlElement xmlConfig)
        {
            // Read in boiler plate configuration settings
            Name = name;
            Description = XmlUtils.TryGetValueAsString(xmlConfig, "Description");
            DefaultPopulationSize = XmlUtils.GetValueAsInt(xmlConfig, "PopulationSize");
            InputCount = OutputCount = XmlUtils.GetValueAsInt(xmlConfig, "AutoencoderSize");
            _numInitialHiddenNodes = XmlUtils.GetValueAsInt(xmlConfig, "NumInitialHiddenNodes");

            // Read in algorithm/logging configuration
            _activationScheme = ExperimentUtils.CreateActivationScheme(xmlConfig, "Activation");
            _complexityRegulationStr = XmlUtils.TryGetValueAsString(xmlConfig, "ComplexityRegulationStrategy");
            _complexityThreshold = XmlUtils.TryGetValueAsInt(xmlConfig, "ComplexityThreshold");
            _parallelOptions = ExperimentUtils.ReadParallelOptions(xmlConfig);
            _generationalLogFile = XmlUtils.TryGetValueAsString(xmlConfig, "GenerationalLogFile");

            // Construct NEAT EA parameters
            NeatEvolutionAlgorithmParameters = new NeatEvolutionAlgorithmParameters();
            NeatEvolutionAlgorithmParameters.SpecieCount = XmlUtils.GetValueAsInt(xmlConfig, "SpecieCount");

            // Construct NEAT genome parameters
            NeatGenomeParameters = ExperimentUtils.ReadNeatGenomeParameters(xmlConfig);
            NeatGenomeParameters.FeedforwardOnly = _activationScheme.AcyclicNetwork;
            NeatGenomeParameters.ActivationFn = PlainSigmoid.__DefaultInstance;            

            // Read in experiment domain-specific parameters
            _trainingImagesFilename = XmlUtils.TryGetValueAsString(xmlConfig, "TrainingImages");
            _numImageSamples = XmlUtils.GetValueAsInt(xmlConfig, "NumImageSamples");
            _learningRate = XmlUtils.GetValueAsDouble(xmlConfig, "LearningRate");
            _numBackpropIterations = XmlUtils.GetValueAsInt(xmlConfig, "NumBackpropagationIterations");
            _trainingSampleProportion = XmlUtils.GetValueAsDouble(xmlConfig, "TrainingSampleProportion");
        }
        /// <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;
        }
Ejemplo n.º 30
0
 public LearningRateExperiment()
 {
     _neatGenomeParams = new NeatGenomeParameters()
     {
         ActivationFn = PlainSigmoid.__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");
            _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;
        }
Ejemplo n.º 32
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");
            _timeStepsPerGeneration = (ulong)XmlUtils.GetValueAsInt(xmlConfig, "TimeStepsPerGeneration");
            _stepReward = XmlUtils.GetValueAsInt(xmlConfig, "StepReward");
            _agentType =(AgentTypes) Enum.Parse(typeof(AgentTypes), XmlUtils.TryGetValueAsString(xmlConfig, "AgentType"));
            _plantLayout = (PlantLayoutStrategies)Enum.Parse(typeof(PlantLayoutStrategies), XmlUtils.TryGetValueAsString(xmlConfig, "PlantLayout"));
            _paradigm = (EvolutionParadigm)Enum.Parse(typeof(EvolutionParadigm), XmlUtils.TryGetValueAsString(xmlConfig, "EvolutionParadigm"));
            bool? diverse = XmlUtils.TryGetValueAsBool(xmlConfig, "LogDiversity");
            if (diverse.HasValue && diverse.Value)
                _logDiversity = true;
            if (_agentType == AgentTypes.Social)
            {
                var memSection = xmlConfig.GetElementsByTagName("Memory")[0] as XmlElement;
                _memory = (MemoryParadigm)Enum.Parse(typeof(MemoryParadigm), XmlUtils.TryGetValueAsString(memSection, "Paradigm"));
                SocialAgent.DEFAULT_MEMORY_SIZE = XmlUtils.GetValueAsInt(memSection, "Size");
                if (_memory == MemoryParadigm.IncrementalGrowth)
                {
                    _memGens = XmlUtils.GetValueAsInt(memSection, "GrowthGenerations");
                    _maxMemorySize = XmlUtils.GetValueAsInt(memSection, "MaxSize");
                }
                _teaching = (TeachingParadigm)Enum.Parse(typeof(TeachingParadigm), XmlUtils.TryGetValueAsString(xmlConfig, "TeachingParadigm"));
            }
            var species = new List<PlantSpecies>();

            var plants = xmlConfig.GetElementsByTagName("Plant");
            for (int i = 0; i < plants.Count; i++)
            {
                var plant = plants[i] as XmlElement;
                species.Add(new PlantSpecies(i)
                {
                    Name = XmlUtils.GetValueAsString(plant, "Name"),
                    Radius = XmlUtils.GetValueAsInt(plant, "Radius"),
                    Reward = XmlUtils.GetValueAsInt(plant, "Reward"),
                    Count = XmlUtils.GetValueAsInt(plant, "Count")
                });
            }
           
            Random random = new Random();
            var agents = new List<ForagingAgent>();
            const int NUM_AGENTS = 10;
            for (int i = 0; i < NUM_AGENTS; i++)
            {
                agents.Add(new SpinningAgent(i) { X = random.Next(500), Y = random.Next(500), Orientation = random.Next(360) });
            }

            List<Predator> predators = new List<Predator>();
            _predCount = XmlUtils.GetValueAsInt(xmlConfig, "Predators");
            var predStr = XmlUtils.TryGetValueAsString(xmlConfig, "PredatorDistribution");
            if (predStr != null)
                PredatorDistribution = (PredatorDistributionTypes)Enum.Parse(typeof(PredatorDistributionTypes), predStr, true);
            _predTypes = XmlUtils.GetValueAsInt(xmlConfig, "PredatorTypes");
            if (PredatorDistribution == PredatorDistributionTypes.Alternating)
                _predGens = XmlUtils.GetValueAsDouble(xmlConfig, "PredatorGenerations");
            _distinguishPreds = XmlUtils.GetValueAsBool(xmlConfig, "DistinguishPredators");

            _world = new World(agents, XmlUtils.GetValueAsInt(xmlConfig, "WorldHeight"), XmlUtils.GetValueAsInt(xmlConfig, "WorldHeight"), species, predators)
            {
                AgentHorizon = XmlUtils.GetValueAsInt(xmlConfig, "AgentHorizon"),
                PlantLayoutStrategy = _plantLayout,
                StepReward = _stepReward,
                PredatorTypes = _predTypes
            };

            var outputs = XmlUtils.TryGetValueAsInt(xmlConfig, "Outputs");
            var navigation = XmlUtils.TryGetValueAsBool(xmlConfig, "AgentsNavigate");
            var hiding = XmlUtils.TryGetValueAsBool(xmlConfig, "AgentsHide");
            _navigationEnabled = navigation.HasValue ? navigation.Value : false;
            _hidingEnabled = hiding.HasValue ? hiding.Value : false;
            if (!outputs.HasValue)
            {
                if (_navigationEnabled || _hidingEnabled)
                    _outputs = (_navigationEnabled ? 2 : 0) + (_hidingEnabled ? _predTypes + 1 : 0);
                else
                    _outputs = outputs.HasValue ? outputs.Value : 2;
            }
            else
                _outputs = outputs.Value;
            var inputs = XmlUtils.TryGetValueAsInt(xmlConfig, "Inputs");
            _inputs = inputs.HasValue ? inputs.Value : _world.PlantTypes.Count() * World.SENSORS_PER_OBJECT_TYPE + (_distinguishPreds ? _predTypes : 1) * World.SENSORS_PER_OBJECT_TYPE + 1;

            _eaParams = new NeatEvolutionAlgorithmParameters();
            _eaParams.SpecieCount = _specieCount;
            _neatGenomeParams = new NeatGenomeParameters()
            {
                ActivationFn = PlainSigmoid.__DefaultInstance
            };
            if (_teaching != TeachingParadigm.EgalitarianEvolvedAcceptability)
                _neatGenomeParams.InitialInterconnectionsProportion = 0.1;
        }
        /// <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);

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

            _eaParams = new NeatEvolutionAlgorithmParameters();
            _eaParams.SpecieCount = _specieCount;
            _neatGenomeParams = new NeatGenomeParameters();
            //_neatGenomeParams = ExperimentUtils.ReadNeatGenomeParameters(xmlConfig);

            _resolutionReductionPerSide = XmlUtils.GetValueAsInt(xmlConfig, "ResolutionReductionPerSide");
            // Read in experiment domain-specific parameters
            _trainingImagesFilename = XmlUtils.TryGetValueAsString(xmlConfig, "TrainingImages");
            _numImageSamples = XmlUtils.GetValueAsInt(xmlConfig, "NumImageSamples");
            _learningRate = XmlUtils.GetValueAsDouble(xmlConfig, "LearningRate");
            _numBackpropIterations = XmlUtils.GetValueAsInt(xmlConfig, "NumBackpropagationIterations");
            _trainingSampleProportion = XmlUtils.GetValueAsDouble(xmlConfig, "TrainingSampleProportion");
        }
Ejemplo n.º 34
0
        /// <summary>
        ///     Read NEAT genome parameter settings from the configuration file.
        /// </summary>
        /// <param name="xmlConfig">The reference to the XML configuration file.</param>
        /// <returns>An initialized NEAT genome parameters object.</returns>
        public static NeatGenomeParameters ReadNeatGenomeParameters(XmlElement xmlConfig)
        {
            // Create new NEAT genome parameters with default values
            var genomeParameters = new NeatGenomeParameters();

            // Get root of neat genome configuration section
            var nodeList = xmlConfig.GetElementsByTagName("GenomeConfig", "");

            if (nodeList.Count == 1)
            {
                // Convert to an XML element
                var xmlNeatGenomeConfig = nodeList[0] as XmlElement;

                // Read all of the applicable parameters in
                var initialConnectionProportion = XmlUtils.TryGetValueAsDouble(xmlNeatGenomeConfig,
                    "InitialConnectionProportion");
                var weightMutationProbability = XmlUtils.TryGetValueAsDouble(xmlNeatGenomeConfig,
                    "WeightMutationProbability");
                var addConnectionProbability = XmlUtils.TryGetValueAsDouble(xmlNeatGenomeConfig,
                    "AddConnnectionProbability");
                var addNodeProbability = XmlUtils.TryGetValueAsDouble(xmlNeatGenomeConfig, "AddNodeProbability");
                var interspeciesMatingProbability = XmlUtils.TryGetValueAsDouble(xmlNeatGenomeConfig,
                    "InterspeciesMatingProbability");

                // Set each if it's specified in the configuration (otherwise, accept the default)
                if (initialConnectionProportion != null)
                {
                    genomeParameters.InitialInterconnectionsProportion = initialConnectionProportion ?? default(double);
                }
                if (weightMutationProbability != null)
                {
                    genomeParameters.ConnectionWeightMutationProbability = weightMutationProbability ?? default(double);
                }
                if (addConnectionProbability != null)
                {
                    genomeParameters.AddConnectionMutationProbability = addConnectionProbability ?? default(double);
                }
                if (addNodeProbability != null)
                {
                    genomeParameters.AddNodeMutationProbability = addNodeProbability ?? default(double);
                }
            }

            return genomeParameters;
        }
        /// <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;
            _neatGenomeParams = new NeatGenomeParameters();
        }
Ejemplo n.º 36
0
    public void Initialize(string name, XmlElement xmlConfig, int input, int output)
    {
        _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");

        _eaParams = new NeatEvolutionAlgorithmParameters();
        _eaParams.SpecieCount = _specieCount;
        _neatGenomeParams = new NeatGenomeParameters();
        _neatGenomeParams.FeedforwardOnly = _activationScheme.AcyclicNetwork;

        _inputCount = input;
        _outputCount = output;
    }