Ejemplo n.º 1
0
        public override void BuildWithFallbackUsesFallbacks()
        {
            // Set all values in builder and build a configuration.
            var fallback = this._builder
                           .SetMaximumNumberGenerations(12)
                           .SetMinimumDomainSize(23)
                           .SetFixInstances(true)
                           .SetInitialStepSize(0.34)
                           .SetReplacementRate(0.96)
                           .SetFocusOnIncumbent(true)
                           .BuildWithFallback(null);

            // Create a new builder based on it and let it build a configuration.
            var config = new CovarianceMatrixAdaptationStrategyConfiguration.CovarianceMatrixAdaptationStrategyConfigurationBuilder()
                         .BuildWithFallback(fallback);

            // Check all values.
            Assert.Equal(
                fallback.MaximumNumberGenerations,
                config.MaximumNumberGenerations);
            Assert.Equal(
                fallback.MinimumDomainSize,
                config.MinimumDomainSize);
            Assert.Equal(
                fallback.ReplacementRate,
                config.ReplacementRate);
            Assert.Equal(
                fallback.InitialStepSize,
                config.InitialStepSize);
            Assert.True(config.FixInstances, "Fix instances flag was not copied over.");
            Assert.Equal(
                fallback.FocusOnIncumbent,
                config.FocusOnIncumbent);
        }
Ejemplo n.º 2
0
        public void IsTechnicallyCompatibleReturnsFalseForIncumbentFocusWithDifferentMinimumDomainSize()
        {
            var focusedConfig = this._builder.SetFocusOnIncumbent(true).BuildWithFallback(null);
            var otherConfig   = new CovarianceMatrixAdaptationStrategyConfiguration.CovarianceMatrixAdaptationStrategyConfigurationBuilder()
                                .SetMinimumDomainSize(focusedConfig.MinimumDomainSize + 1)
                                .BuildWithFallback(focusedConfig);

            ConfigurationBaseTest.CheckTechnicalIncompatibility(focusedConfig, otherConfig);
        }
Ejemplo n.º 3
0
        public void IsTechnicallyCompatibleReturnsFalseForDifferentIncumbentFocus()
        {
            var defaultConfig = this._builder.BuildWithFallback(null);
            var otherConfig   = new CovarianceMatrixAdaptationStrategyConfiguration.CovarianceMatrixAdaptationStrategyConfigurationBuilder()
                                .SetFocusOnIncumbent(!defaultConfig.FocusOnIncumbent)
                                .BuildWithFallback(defaultConfig);

            ConfigurationBaseTest.CheckTechnicalIncompatibility(defaultConfig, otherConfig);
        }
Ejemplo n.º 4
0
        public void IsCompatibleReturnsFalseForDifferentInitialStepSize()
        {
            var defaultConfig = this._builder.BuildWithFallback(null);
            var otherConfig   = new CovarianceMatrixAdaptationStrategyConfiguration.CovarianceMatrixAdaptationStrategyConfigurationBuilder()
                                .SetInitialStepSize(defaultConfig.InitialStepSize + 0.02)
                                .BuildWithFallback(defaultConfig);

            ConfigurationBaseTest.CheckIncompatibility(defaultConfig, otherConfig);
        }
Ejemplo n.º 5
0
        public void IsCompatibleReturnsFalseForDifferentFixInstancesFlags()
        {
            var defaultConfig = this._builder.BuildWithFallback(null);
            var otherConfig   = new CovarianceMatrixAdaptationStrategyConfiguration.CovarianceMatrixAdaptationStrategyConfigurationBuilder()
                                .SetFixInstances(!defaultConfig.FixInstances)
                                .BuildWithFallback(defaultConfig);

            ConfigurationBaseTest.CheckIncompatibility(defaultConfig, otherConfig);
        }
Ejemplo n.º 6
0
        public void IsCompatibleReturnsFalseForIncumbentFocusWithDifferentReplacementRate()
        {
            var focusedConfig = this._builder.SetFocusOnIncumbent(true).BuildWithFallback(null);
            var otherConfig   = new CovarianceMatrixAdaptationStrategyConfiguration.CovarianceMatrixAdaptationStrategyConfigurationBuilder()
                                .SetReplacementRate(focusedConfig.ReplacementRate + 0.1)
                                .BuildWithFallback(focusedConfig);

            ConfigurationBaseTest.CheckIncompatibility(focusedConfig, otherConfig);
        }
Ejemplo n.º 7
0
        public void IsCompatibleReturnsFalseForDifferentMaximumNumberGenerations()
        {
            var defaultConfig = this._builder.BuildWithFallback(null);
            var otherConfig   = new CovarianceMatrixAdaptationStrategyConfiguration.CovarianceMatrixAdaptationStrategyConfigurationBuilder()
                                .SetMaximumNumberGenerations(defaultConfig.MaximumNumberGenerations - 1)
                                .BuildWithFallback(defaultConfig);

            ConfigurationBaseTest.CheckIncompatibility(defaultConfig, otherConfig);
        }
Ejemplo n.º 8
0
        public void IsCompatibleReturnsTrueForSameParameters()
        {
            var defaultConfig = this._builder.BuildWithFallback(null);
            var otherConfig   = new CovarianceMatrixAdaptationStrategyConfiguration.CovarianceMatrixAdaptationStrategyConfigurationBuilder()
                                .BuildWithFallback(defaultConfig);

            Assert.True(
                defaultConfig.IsCompatible(otherConfig),
                "Configurations should be compatible.");
            Assert.Equal(
                defaultConfig.IsCompatible(otherConfig),
                otherConfig.IsCompatible(defaultConfig));
        }
Ejemplo n.º 9
0
        public void IsCompatibleReturnsTrueForIrrelevantParameterChanges()
        {
            var globalConfig = this._builder.SetFocusOnIncumbent(false).BuildWithFallback(null);
            var otherConfig  = new CovarianceMatrixAdaptationStrategyConfiguration.CovarianceMatrixAdaptationStrategyConfigurationBuilder()
                               .SetReplacementRate(globalConfig.ReplacementRate + 0.01)
                               .SetMinimumDomainSize(globalConfig.MinimumDomainSize + 1)
                               .BuildWithFallback(globalConfig);

            Assert.True(
                globalConfig.IsCompatible(otherConfig),
                "Configurations should be compatible.");
            Assert.Equal(
                globalConfig.IsCompatible(otherConfig),
                otherConfig.IsCompatible(globalConfig));
        }
Ejemplo n.º 10
0
        public void IsTechnicallyCompatibleReturnsTrueForOtherChanges()
        {
            var defaultConfig = this._builder.SetFocusOnIncumbent(true).BuildWithFallback(null);
            var otherConfig   = new CovarianceMatrixAdaptationStrategyConfiguration.CovarianceMatrixAdaptationStrategyConfigurationBuilder()
                                .SetMaximumNumberGenerations(defaultConfig.MaximumNumberGenerations - 1)
                                .SetInitialStepSize(defaultConfig.InitialStepSize + 0.01)
                                .SetFixInstances(!defaultConfig.FixInstances)
                                .SetReplacementRate(defaultConfig.ReplacementRate + 0.1)
                                .BuildWithFallback(defaultConfig);

            // Check those two configuration are compatible.
            Assert.True(
                defaultConfig.IsTechnicallyCompatible(otherConfig),
                "Configurations should be technically compatible.");
            Assert.Equal(
                defaultConfig.IsTechnicallyCompatible(otherConfig),
                otherConfig.IsTechnicallyCompatible(defaultConfig));
        }
Ejemplo n.º 11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CovarianceMatrixAdaptationStrategyConfigurationTest"/> class.
 /// </summary>
 public CovarianceMatrixAdaptationStrategyConfigurationTest()
 {
     this._builder =
         new CovarianceMatrixAdaptationStrategyConfiguration.CovarianceMatrixAdaptationStrategyConfigurationBuilder();
 }