/// <summary>
        /// Create a new instance of <see cref="INeatExperiment{T}"/>.
        /// </summary>
        /// <param name="configElem">Experiment config in json form.</param>
        /// <returns>A new instance of <see cref="INeatExperiment{T}"/>.</returns>
        public INeatExperiment <double> CreateExperiment(JsonElement configElem)
        {
            // Create an evaluation scheme object for the Single Pole Balancing task.
            var evalScheme = new CartSinglePoleEvaluationScheme();

            // Create a NeatExperiment object with the evaluation scheme,
            // and assign some default settings (these can be overridden by config).
            var experiment = new NeatExperiment <double>("Cart and Pole Balancing (Single Pole)", evalScheme)
            {
                IsAcyclic        = true,
                ActivationFnName = ActivationFunctionId.LogisticSteep.ToString()
            };

            // Read standard neat experiment json config and use it configure the experiment.
            NeatExperimentJsonReader <double> .Read(experiment, configElem);

            return(experiment);
        }
    /// <summary>
    /// Create a new instance of <see cref="INeatExperiment{T}"/>.
    /// </summary>
    /// <param name="configElem">Experiment config in json form.</param>
    /// <returns>A new instance of <see cref="INeatExperiment{T}"/>.</returns>
    public INeatExperiment <double> CreateExperiment(JsonElement configElem)
    {
        // Create an evaluation scheme object for the binary 11-multiplexer task.
        var evalScheme = new BinaryElevenMultiplexerEvaluationScheme();

        // Create a NeatExperiment object with the evaluation scheme,
        // and assign some default settings (these can be overridden by config).
        var experiment = new NeatExperiment <double>(evalScheme, this.Id)
        {
            IsAcyclic        = true,
            ActivationFnName = ActivationFunctionId.LeakyReLU.ToString()
        };

        // Read standard neat experiment json config and use it configure the experiment.
        NeatExperimentJsonReader <double> .Read(experiment, configElem);

        return(experiment);
    }
        /// <summary>
        /// Create a new instance of <see cref="INeatExperiment{T}"/>.
        /// </summary>
        /// <param name="configElem">Experiment config in json form.</param>
        /// <returns>A new instance of <see cref="INeatExperiment{T}"/>.</returns>
        public INeatExperiment <double> CreateExperiment(JsonElement configElem)
        {
            // Create an evaluation scheme object for the XOR task.
            var evalScheme = new XorEvaluationScheme();


            // Create a NeatExperiment object with the evaluation scheme,
            // and assign some default settings (these can be overridden by config).
            var experiment = new NeatExperiment <double>("XOR (Exclusive OR)", evalScheme)
            {
                IsAcyclic        = true,
                ActivationFnName = __DefaultActivationFunctionName.ToString()
            };

            // Read standard neat experiment json config and use it configure the experiment.
            NeatExperimentJsonReader <double> .Read(experiment, configElem);

            return(experiment);
        }
示例#4
0
        /// <summary>
        /// Create a new instance of <see cref="INeatExperiment{T}"/>.
        /// </summary>
        /// <param name="jsonConfig">Experiment config in json format.</param>
        /// <returns>A new instance of <see cref="INeatExperiment{T}"/>.</returns>
        public INeatExperiment <double> CreateExperiment(string jsonConfig)
        {
            // Parse the json config string.
            JObject configJobj = JsonUtils.Parse(jsonConfig);

            // Create an evaluation scheme object for the Single Pole Balancing task.
            var evalScheme = new CartDoublePoleEvaluationScheme();

            // Create a NeatExperiment object with the evaluation scheme.
            var experiment = NeatExperiment <double> .CreateAcyclic(
                "Cart and Pole Balancing (Double Pole)",
                evalScheme,
                __DefaultActivationFunctionName.ToString());

            // Read standard neat experiment json config and use it configure the experiment.
            if (configJobj != null)
            {
                NeatExperimentJsonReader <double> .Read(experiment, configJobj);
            }

            return(experiment);
        }
示例#5
0
        /// <summary>
        /// Create a new instance of <see cref="INeatExperiment{T}"/>.
        /// </summary>
        /// <param name="jsonConfig">Experiment config in json format.</param>
        /// <returns>A new instance of <see cref="INeatExperiment{T}"/>.</returns>
        public INeatExperiment <double> CreateExperiment(string jsonConfig)
        {
            // Parse the json config string.
            JObject configJobj = JsonUtils.Parse(jsonConfig);

            // Create an evaluation scheme object for the binary 11-multiplexer task.
            var evalScheme = new BinaryElevenMultiplexerEvaluationScheme();

            // Create a NeatExperiment object with the evaluation scheme.
            var experiment = NeatExperiment <double> .CreateAcyclic(
                "Binary 11-multiplexer",
                evalScheme,
                __DefaultActivationFunctionName.ToString());

            // Read standard neat experiment json config and use it configure the experiment.
            if (configJobj != null)
            {
                NeatExperimentJsonReader <double> .Read(experiment, configJobj);
            }

            return(experiment);
        }
    public void Read()
    {
        JsonDocument jdoc = JsonDocument.Parse(
            @"{
    ""description"":""bar description"",
    ""isAcyclic"":false,
    ""cyclesPerActivation"":111,
    ""activationFnName"":""bar-activation-fn"",

    ""evolutionAlgorithmSettings"":
    {
        ""speciesCount"":1111,
        ""elitismProportion"":0.11,
        ""selectionProportion"":0.22,
        ""offspringAsexualProportion"":0.39,
        ""offspringSexualProportion"":0.61,
        ""interspeciesMatingProportion"":0.55,
        ""statisticsMovingAverageHistoryLength"":2222
    },
    ""reproductionAsexualSettings"":
    {
        ""connectionWeightMutationProbability"":0.11,
        ""addNodeMutationProbability"":0.22,
        ""addConnectionMutationProbability"":0.33,
        ""deleteConnectionMutationProbability"":0.34
    },
    ""reproductionSexualSettings"":
    {
        ""secondaryParentGeneProbability"":0.11
    },

    ""populationSize"":222,
    ""initialInterconnectionsProportion"":0.33,
    ""connectionWeightScale"":4.44,

    ""complexityRegulationStrategy"":
    {
        ""strategyName"": ""absolute"",
        ""complexityCeiling"": 10,
        ""minSimplifcationGenerations"": 10
    },

    ""enableHardwareAcceleratedNeuralNets"":true,
    ""enableHardwareAcceleratedActivationFunctions"":true,
    ""degreeOfParallelism"":6
}");

        // Create a mock evaluation scheme.
        var evalScheme = new Mock <IBlackBoxEvaluationScheme <double> >();

        // Init a default settings object.
        var experiment = new NeatExperiment <double>(
            evalScheme.Object, "foo-experiment");

        // Read json properties into the experiment object.
        NeatExperimentJsonReader <double> .Read(experiment, jdoc.RootElement);

        // Assert the expected values.
        Assert.Equal("bar description", experiment.Description);
        Assert.False(experiment.IsAcyclic);
        Assert.Equal(111, experiment.CyclesPerActivation);
        Assert.Equal("bar-activation-fn", experiment.ActivationFnName);

        var eaSettings = experiment.NeatEvolutionAlgorithmSettings;

        Assert.Equal(1111, eaSettings.SpeciesCount);
        Assert.Equal(0.11, eaSettings.ElitismProportion);
        Assert.Equal(0.22, eaSettings.SelectionProportion);
        Assert.Equal(0.39, eaSettings.OffspringAsexualProportion);
        Assert.Equal(0.61, eaSettings.OffspringSexualProportion);
        Assert.Equal(0.55, eaSettings.InterspeciesMatingProportion);
        Assert.Equal(2222, eaSettings.StatisticsMovingAverageHistoryLength);

        var asexualSettings = experiment.ReproductionAsexualSettings;

        Assert.Equal(0.11, asexualSettings.ConnectionWeightMutationProbability);
        Assert.Equal(0.22, asexualSettings.AddNodeMutationProbability);
        Assert.Equal(0.33, asexualSettings.AddConnectionMutationProbability);
        Assert.Equal(0.34, asexualSettings.DeleteConnectionMutationProbability);

        var sexualSettings = experiment.ReproductionSexualSettings;

        Assert.Equal(0.11, sexualSettings.SecondaryParentGeneProbability);

        Assert.Equal(222, experiment.PopulationSize);
        Assert.Equal(0.33, experiment.InitialInterconnectionsProportion);
        Assert.Equal(4.44, experiment.ConnectionWeightScale);

        var complexityRegulationStrategy = experiment.ComplexityRegulationStrategy;

        Assert.Equal("AbsoluteComplexityRegulationStrategy", complexityRegulationStrategy.GetType().Name);

        Assert.Equal(6, experiment.DegreeOfParallelism);
        Assert.True(experiment.EnableHardwareAcceleratedNeuralNets);
        Assert.True(experiment.EnableHardwareAcceleratedActivationFunctions);
    }
        public void Read()
        {
            JObject jobj = JObject.Parse(
                @"{
    'description':'bar description',
    'isAcyclic':false,
    'cyclesPerActivation':111,
    'activationFnName':'bar-activation-fn',

    'evolutionAlgorithmSettings':
    {
        'speciesCount':1111,
        'elitismProportion':0.11,
        'selectionProportion':0.22,
        'offspringAsexualProportion':0.33,
        'offspringSexualProportion':0.44,
        'interspeciesMatingProportion':0.55,
        'statisticsMovingAverageHistoryLength':2222
    },
    'reproductionAsexualSettings':
    {
        'connectionWeightMutationProbability':0.11,
        'addNodeMutationProbability':0.22,
        'addConnectionMutationProbability':0.33,
        'deleteConnectionMutationProbability':0.44
    },
    'reproductionSexualSettings':
    {
        'secondaryParentGeneProbability':0.11
    },

    'populationSize':222,
    'initialInterconnectionsProportion':0.33,
    'connectionWeightScale':4.44,

    'complexityRegulationStrategy':
    {
        'strategyName': 'absolute',
        'complexityCeiling': 10,
        'minSimplifcationGenerations': 10
    },

    'enableHardwareAcceleratedNeuralNets':true,
    'enableHardwareAcceleratedActivationFunctions':true,
    'degreeOfParallelism':6
}");

            // Create a mock evaluation scheme.
            var evalScheme = new Mock <IBlackBoxEvaluationScheme <double> >();

            // Init a default settings object.
            var experiment = NeatExperiment <double> .CreateAcyclic(
                "foo-experiment",
                evalScheme.Object,
                "foo-activation-fn");

            // Read json properties into the experiment object.
            NeatExperimentJsonReader <double> .Read(experiment, jobj);

            // Assert the expected values.
            Assert.AreEqual("bar description", experiment.Description);
            Assert.AreEqual(false, experiment.IsAcyclic);
            Assert.AreEqual(111, experiment.CyclesPerActivation);
            Assert.AreEqual("bar-activation-fn", experiment.ActivationFnName);

            var eaSettings = experiment.NeatEvolutionAlgorithmSettings;

            Assert.AreEqual(1111, eaSettings.SpeciesCount);
            Assert.AreEqual(0.11, eaSettings.ElitismProportion);
            Assert.AreEqual(0.22, eaSettings.SelectionProportion);
            Assert.AreEqual(0.33, eaSettings.OffspringAsexualProportion);
            Assert.AreEqual(0.44, eaSettings.OffspringSexualProportion);
            Assert.AreEqual(0.55, eaSettings.InterspeciesMatingProportion);
            Assert.AreEqual(2222, eaSettings.StatisticsMovingAverageHistoryLength);

            var asexualSettings = experiment.ReproductionAsexualSettings;

            Assert.AreEqual(0.11, asexualSettings.ConnectionWeightMutationProbability);
            Assert.AreEqual(0.22, asexualSettings.AddNodeMutationProbability);
            Assert.AreEqual(0.33, asexualSettings.AddConnectionMutationProbability);
            Assert.AreEqual(0.44, asexualSettings.DeleteConnectionMutationProbability);

            var sexualSettings = experiment.ReproductionSexualSettings;

            Assert.AreEqual(0.11, sexualSettings.SecondaryParentGeneProbability);

            Assert.AreEqual(222, experiment.PopulationSize);
            Assert.AreEqual(0.33, experiment.InitialInterconnectionsProportion);
            Assert.AreEqual(4.44, experiment.ConnectionWeightScale);

            var complexityRegulationStrategy = experiment.ComplexityRegulationStrategy;

            Assert.AreEqual("AbsoluteComplexityRegulationStrategy", complexityRegulationStrategy.GetType().Name);

            Assert.AreEqual(6, experiment.DegreeOfParallelism);
            Assert.AreEqual(true, experiment.EnableHardwareAcceleratedNeuralNets);
            Assert.AreEqual(true, experiment.EnableHardwareAcceleratedActivationFunctions);
        }
示例#8
0
        public static void InitializeSharpNeat()
        {
            _neuralNetworkInputProvider = new NeuralNetworkInputProvider();

            _neatExperiment = new NeatExperiment(null);
        }