Exemple #1
0
        private void AfterDeserialization()
        {
            // BackwardsCompatibility3.3
            #region Backwards compatible code, remove with 3.4
            if (successfulOffspringAnalyzer == null)
            {
                successfulOffspringAnalyzer = new SuccessfulOffspringAnalyzer();
            }
            if (!Parameters.ContainsKey("ReevaluateElites"))
            {
                Parameters.Add(new FixedValueParameter <BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)", (BoolValue) new BoolValue(false).AsReadOnly())
                {
                    Hidden = true
                });
            }
            if (!Parameters.ContainsKey("FillPopulationWithParents"))
            {
                Parameters.Add(new FixedValueParameter <BoolValue>("FillPopulationWithParents", "True if the population should be filled with parent individual or false if worse children should be used when the maximum selection pressure is exceeded.", new BoolValue(false))
                {
                    Hidden = true
                });
            }
            #endregion

            Initialize();
        }
 private OffspringSelectionGeneticAlgorithm(OffspringSelectionGeneticAlgorithm original, Cloner cloner)
     : base(original, cloner)
 {
     qualityAnalyzer             = cloner.Clone(original.qualityAnalyzer);
     selectionPressureAnalyzer   = cloner.Clone(original.selectionPressureAnalyzer);
     successfulOffspringAnalyzer = cloner.Clone(original.successfulOffspringAnalyzer);
     Initialize();
 }
Exemple #3
0
 private SASEGASA(SASEGASA original, Cloner cloner)
     : base(original, cloner)
 {
     qualityAnalyzer                  = cloner.Clone(original.qualityAnalyzer);
     villageQualityAnalyzer           = cloner.Clone(original.villageQualityAnalyzer);
     selectionPressureAnalyzer        = cloner.Clone(original.selectionPressureAnalyzer);
     villageSelectionPressureAnalyzer = cloner.Clone(original.villageSelectionPressureAnalyzer);
     successfulOffspringAnalyzer      = cloner.Clone(original.successfulOffspringAnalyzer);
     Initialize();
 }
Exemple #4
0
        private void AfterDeserialization()
        {
            // BackwardsCompatibility3.3
            #region Backwards compatible code, remove with 3.4
            if (successfulOffspringAnalyzer == null)
            {
                successfulOffspringAnalyzer = new SuccessfulOffspringAnalyzer();
            }
            if (!Parameters.ContainsKey("ReevaluateElites"))
            {
                Parameters.Add(new FixedValueParameter <BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)", (BoolValue) new BoolValue(false).AsReadOnly())
                {
                    Hidden = true
                });
            }
            if (!Parameters.ContainsKey("FillPopulationWithParents"))
            {
                Parameters.Add(new FixedValueParameter <BoolValue>("FillPopulationWithParents", "True if the population should be filled with parent individual or false if worse children should be used when the maximum selection pressure is exceeded.", new BoolValue(false))
                {
                    Hidden = true
                });
            }

            var optionalMutatorParameter = MutatorParameter as OptionalConstrainedValueParameter <IManipulator>;
            if (optionalMutatorParameter != null)
            {
                Parameters.Remove(optionalMutatorParameter);
                Parameters.Add(new ConstrainedValueParameter <IManipulator>("Mutator", "The operator used to mutate solutions."));
                foreach (var m in optionalMutatorParameter.ValidValues)
                {
                    MutatorParameter.ValidValues.Add(m);
                }
                if (optionalMutatorParameter.Value == null)
                {
                    MutationProbability.Value = 0;                                 // to guarantee that the old configuration results in the same behavior
                }
                else
                {
                    Mutator = optionalMutatorParameter.Value;
                }
                optionalMutatorParameter.ValidValues.Clear(); // to avoid dangling references to the old parameter its valid values are cleared
            }
            #endregion

            Initialize();
        }
Exemple #5
0
        public SASEGASA()
            : base()
        {
            Parameters.Add(new ValueParameter <IntValue>("Seed", "The random seed used to initialize the new pseudo random number generator.", new IntValue(0)));
            Parameters.Add(new ValueParameter <BoolValue>("SetSeedRandomly", "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true)));
            Parameters.Add(new ValueParameter <IntValue>("NumberOfVillages", "The initial number of villages.", new IntValue(10)));
            Parameters.Add(new ValueParameter <IntValue>("PopulationSize", "The size of the population of solutions.", new IntValue(100)));
            Parameters.Add(new ValueParameter <IntValue>("MaximumGenerations", "The maximum number of generations that should be processed.", new IntValue(1000)));
            Parameters.Add(new ConstrainedValueParameter <ISelector>("Selector", "The operator used to select solutions for reproduction."));
            Parameters.Add(new ConstrainedValueParameter <ICrossover>("Crossover", "The operator used to cross solutions."));
            Parameters.Add(new ValueParameter <PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution.", new PercentValue(0.05)));
            Parameters.Add(new OptionalConstrainedValueParameter <IManipulator>("Mutator", "The operator used to mutate solutions."));
            Parameters.Add(new ValueParameter <IntValue>("Elites", "The numer of elite solutions which are kept in each generation.", new IntValue(1)));
            Parameters.Add(new FixedValueParameter <BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)", new BoolValue(false))
            {
                Hidden = true
            });
            Parameters.Add(new ValueLookupParameter <DoubleValue>("SuccessRatio", "The ratio of successful to total children that should be achieved.", new DoubleValue(1)));
            Parameters.Add(new ValueLookupParameter <DoubleValue>("ComparisonFactorLowerBound", "The lower bound of the comparison factor (start).", new DoubleValue(0.3)));
            Parameters.Add(new ValueLookupParameter <DoubleValue>("ComparisonFactorUpperBound", "The upper bound of the comparison factor (end).", new DoubleValue(0.7)));
            Parameters.Add(new OptionalConstrainedValueParameter <IDiscreteDoubleValueModifier>("ComparisonFactorModifier", "The operator used to modify the comparison factor.", new ItemSet <IDiscreteDoubleValueModifier>(new IDiscreteDoubleValueModifier[] { new LinearDiscreteDoubleValueModifier() }), new LinearDiscreteDoubleValueModifier()));
            Parameters.Add(new ValueLookupParameter <DoubleValue>("MaximumSelectionPressure", "The maximum selection pressure that terminates the algorithm.", new DoubleValue(100)));
            Parameters.Add(new ValueLookupParameter <DoubleValue>("FinalMaximumSelectionPressure", "The maximum selection pressure used when there is only one village left.", new DoubleValue(100)));
            Parameters.Add(new ValueLookupParameter <BoolValue>("OffspringSelectionBeforeMutation", "True if the offspring selection step should be applied before mutation, false if it should be applied after mutation.", new BoolValue(false)));
            Parameters.Add(new ValueLookupParameter <IntValue>("SelectedParents", "How much parents should be selected each time the offspring selection step is performed until the population is filled. This parameter should be about the same or twice the size of PopulationSize for smaller problems, and less for large problems.", new IntValue(200)));
            Parameters.Add(new ValueParameter <MultiAnalyzer>("Analyzer", "The operator used to analyze the villages.", new MultiAnalyzer()));
            Parameters.Add(new ValueParameter <MultiAnalyzer>("VillageAnalyzer", "The operator used to analyze each village.", new MultiAnalyzer()));
            Parameters.Add(new ValueParameter <IntValue>("MaximumEvaluatedSolutions", "The maximum number of evaluated solutions (approximately).", new IntValue(int.MaxValue)));
            Parameters.Add(new FixedValueParameter <BoolValue>("FillPopulationWithParents", "True if the population should be filled with parent individual or false if worse children should be used when the maximum selection pressure is exceeded.", new BoolValue(true))
            {
                Hidden = true
            });

            RandomCreator             randomCreator     = new RandomCreator();
            SubScopesCreator          populationCreator = new SubScopesCreator();
            UniformSubScopesProcessor ussp1             = new UniformSubScopesProcessor();
            SolutionsCreator          solutionsCreator  = new SolutionsCreator();
            VariableCreator           variableCreator   = new VariableCreator();
            UniformSubScopesProcessor ussp2             = new UniformSubScopesProcessor();
            SubScopesCounter          subScopesCounter  = new SubScopesCounter();
            ResultsCollector          resultsCollector  = new ResultsCollector();
            SASEGASAMainLoop          mainLoop          = new SASEGASAMainLoop();

            OperatorGraph.InitialOperator = randomCreator;

            randomCreator.RandomParameter.ActualName          = "Random";
            randomCreator.SeedParameter.ActualName            = SeedParameter.Name;
            randomCreator.SeedParameter.Value                 = null;
            randomCreator.SetSeedRandomlyParameter.ActualName = SetSeedRandomlyParameter.Name;
            randomCreator.SetSeedRandomlyParameter.Value      = null;
            randomCreator.Successor = populationCreator;

            populationCreator.NumberOfSubScopesParameter.ActualName = NumberOfVillagesParameter.Name;
            populationCreator.Successor = ussp1;

            ussp1.Operator  = solutionsCreator;
            ussp1.Successor = variableCreator;

            solutionsCreator.NumberOfSolutionsParameter.ActualName = PopulationSizeParameter.Name;
            solutionsCreator.Successor = null;

            variableCreator.Name = "Initialize EvaluatedSolutions";
            variableCreator.CollectedValues.Add(new ValueParameter <IntValue>("EvaluatedSolutions", new IntValue()));
            variableCreator.Successor = ussp2;

            ussp2.Operator  = subScopesCounter;
            ussp2.Successor = resultsCollector;

            subScopesCounter.Name = "Increment EvaluatedSolutions";
            subScopesCounter.ValueParameter.ActualName = "EvaluatedSolutions";

            resultsCollector.CollectedValues.Add(new LookupParameter <IntValue>("Evaluated Solutions", "", "EvaluatedSolutions"));
            resultsCollector.ResultsParameter.ActualName = "Results";
            resultsCollector.Successor = mainLoop;

            mainLoop.NumberOfVillagesParameter.ActualName                 = NumberOfVillagesParameter.Name;
            mainLoop.SelectorParameter.ActualName                         = SelectorParameter.Name;
            mainLoop.CrossoverParameter.ActualName                        = CrossoverParameter.Name;
            mainLoop.ElitesParameter.ActualName                           = ElitesParameter.Name;
            mainLoop.ReevaluateElitesParameter.ActualName                 = ReevaluateElitesParameter.Name;
            mainLoop.MutatorParameter.ActualName                          = MutatorParameter.Name;
            mainLoop.MutationProbabilityParameter.ActualName              = MutationProbabilityParameter.Name;
            mainLoop.RandomParameter.ActualName                           = randomCreator.RandomParameter.ActualName;
            mainLoop.ResultsParameter.ActualName                          = "Results";
            mainLoop.SuccessRatioParameter.ActualName                     = SuccessRatioParameter.Name;
            mainLoop.ComparisonFactorStartParameter.ActualName            = ComparisonFactorLowerBoundParameter.Name;
            mainLoop.ComparisonFactorModifierParameter.ActualName         = ComparisonFactorModifierParameter.Name;
            mainLoop.MaximumSelectionPressureParameter.ActualName         = MaximumSelectionPressureParameter.Name;
            mainLoop.FinalMaximumSelectionPressureParameter.ActualName    = FinalMaximumSelectionPressureParameter.Name;
            mainLoop.MaximumGenerationsParameter.ActualName               = MaximumGenerationsParameter.Name;
            mainLoop.OffspringSelectionBeforeMutationParameter.ActualName = OffspringSelectionBeforeMutationParameter.Name;
            mainLoop.EvaluatedSolutionsParameter.ActualName               = "EvaluatedSolutions";
            mainLoop.FillPopulationWithParentsParameter.ActualName        = FillPopulationWithParentsParameter.Name;
            mainLoop.Successor = null;

            foreach (ISelector selector in ApplicationManager.Manager.GetInstances <ISelector>().Where(x => !(x is IMultiObjectiveSelector)).OrderBy(x => x.Name))
            {
                SelectorParameter.ValidValues.Add(selector);
            }
            ISelector proportionalSelector = SelectorParameter.ValidValues.FirstOrDefault(x => x.GetType().Name.Equals("ProportionalSelector"));

            if (proportionalSelector != null)
            {
                SelectorParameter.Value = proportionalSelector;
            }

            ParameterizeSelectors();

            foreach (IDiscreteDoubleValueModifier modifier in ApplicationManager.Manager.GetInstances <IDiscreteDoubleValueModifier>().OrderBy(x => x.Name))
            {
                ComparisonFactorModifierParameter.ValidValues.Add(modifier);
            }
            IDiscreteDoubleValueModifier linearModifier = ComparisonFactorModifierParameter.ValidValues.FirstOrDefault(x => x.GetType().Name.Equals("LinearDiscreteDoubleValueModifier"));

            if (linearModifier != null)
            {
                ComparisonFactorModifierParameter.Value = linearModifier;
            }
            ParameterizeComparisonFactorModifiers();

            qualityAnalyzer                  = new BestAverageWorstQualityAnalyzer();
            villageQualityAnalyzer           = new BestAverageWorstQualityAnalyzer();
            selectionPressureAnalyzer        = new ValueAnalyzer();
            villageSelectionPressureAnalyzer = new ValueAnalyzer();
            successfulOffspringAnalyzer      = new SuccessfulOffspringAnalyzer();
            ParameterizeAnalyzers();
            UpdateAnalyzers();

            Initialize();
        }
 private SuccessfulOffspringAnalyzer(SuccessfulOffspringAnalyzer original, Cloner cloner) : base(original, cloner)
 {
 }
    public OffspringSelectionGeneticAlgorithm()
      : base() {
      Parameters.Add(new ValueParameter<IntValue>("Seed", "The random seed used to initialize the new pseudo random number generator.", new IntValue(0)));
      Parameters.Add(new ValueParameter<BoolValue>("SetSeedRandomly", "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true)));
      Parameters.Add(new ValueParameter<IntValue>("PopulationSize", "The size of the population of solutions.", new IntValue(100)));
      Parameters.Add(new ConstrainedValueParameter<ISelector>("Selector", "The operator used to select solutions for reproduction."));
      Parameters.Add(new ConstrainedValueParameter<ICrossover>("Crossover", "The operator used to cross solutions."));
      Parameters.Add(new ValueParameter<PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution.", new PercentValue(0.05)));
      Parameters.Add(new OptionalConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions."));
      Parameters.Add(new ValueParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation.", new IntValue(1)));
      Parameters.Add(new FixedValueParameter<BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)", new BoolValue(false)) { Hidden = true });
      Parameters.Add(new ValueParameter<IntValue>("MaximumGenerations", "The maximum number of generations which should be processed.", new IntValue(1000)));
      Parameters.Add(new ValueLookupParameter<DoubleValue>("SuccessRatio", "The ratio of successful to total children that should be achieved.", new DoubleValue(1)));
      Parameters.Add(new ValueLookupParameter<DoubleValue>("ComparisonFactorLowerBound", "The lower bound of the comparison factor (start).", new DoubleValue(0)));
      Parameters.Add(new ValueLookupParameter<DoubleValue>("ComparisonFactorUpperBound", "The upper bound of the comparison factor (end).", new DoubleValue(1)));
      Parameters.Add(new OptionalConstrainedValueParameter<IDiscreteDoubleValueModifier>("ComparisonFactorModifier", "The operator used to modify the comparison factor.", new ItemSet<IDiscreteDoubleValueModifier>(new IDiscreteDoubleValueModifier[] { new LinearDiscreteDoubleValueModifier() }), new LinearDiscreteDoubleValueModifier()));
      Parameters.Add(new ValueLookupParameter<DoubleValue>("MaximumSelectionPressure", "The maximum selection pressure that terminates the algorithm.", new DoubleValue(100)));
      Parameters.Add(new ValueLookupParameter<BoolValue>("OffspringSelectionBeforeMutation", "True if the offspring selection step should be applied before mutation, false if it should be applied after mutation.", new BoolValue(false)));
      Parameters.Add(new ValueLookupParameter<IntValue>("SelectedParents", "How much parents should be selected each time the offspring selection step is performed until the population is filled. This parameter should be about the same or twice the size of PopulationSize for smaller problems, and less for large problems.", new IntValue(200)));
      Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze each generation.", new MultiAnalyzer()));
      Parameters.Add(new ValueParameter<IntValue>("MaximumEvaluatedSolutions", "The maximum number of evaluated solutions (approximately).", new IntValue(int.MaxValue)));
      Parameters.Add(new FixedValueParameter<BoolValue>("FillPopulationWithParents", "True if the population should be filled with parent individual or false if worse children should be used when the maximum selection pressure is exceeded.", new BoolValue(false)) { Hidden = true });

      RandomCreator randomCreator = new RandomCreator();
      SolutionsCreator solutionsCreator = new SolutionsCreator();
      SubScopesCounter subScopesCounter = new SubScopesCounter();
      ResultsCollector resultsCollector = new ResultsCollector();
      OffspringSelectionGeneticAlgorithmMainLoop mainLoop = new OffspringSelectionGeneticAlgorithmMainLoop();
      OperatorGraph.InitialOperator = randomCreator;

      randomCreator.RandomParameter.ActualName = "Random";
      randomCreator.SeedParameter.ActualName = SeedParameter.Name;
      randomCreator.SeedParameter.Value = null;
      randomCreator.SetSeedRandomlyParameter.ActualName = SetSeedRandomlyParameter.Name;
      randomCreator.SetSeedRandomlyParameter.Value = null;
      randomCreator.Successor = solutionsCreator;

      solutionsCreator.NumberOfSolutionsParameter.ActualName = PopulationSizeParameter.Name;
      solutionsCreator.Successor = subScopesCounter;

      subScopesCounter.Name = "Initialize EvaluatedSolutions";
      subScopesCounter.ValueParameter.ActualName = "EvaluatedSolutions";
      subScopesCounter.Successor = resultsCollector;

      resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Evaluated Solutions", "", "EvaluatedSolutions"));
      resultsCollector.ResultsParameter.ActualName = "Results";
      resultsCollector.Successor = mainLoop;

      mainLoop.AnalyzerParameter.ActualName = AnalyzerParameter.Name;
      mainLoop.ComparisonFactorModifierParameter.ActualName = ComparisonFactorModifierParameter.Name;
      mainLoop.ComparisonFactorParameter.ActualName = "ComparisonFactor";
      mainLoop.ComparisonFactorStartParameter.ActualName = ComparisonFactorLowerBoundParameter.Name;
      mainLoop.CrossoverParameter.ActualName = CrossoverParameter.Name;
      mainLoop.ElitesParameter.ActualName = ElitesParameter.Name;
      mainLoop.ReevaluateElitesParameter.ActualName = ReevaluateElitesParameter.Name;
      mainLoop.EvaluatedSolutionsParameter.ActualName = "EvaluatedSolutions";
      mainLoop.MaximumGenerationsParameter.ActualName = MaximumGenerationsParameter.Name;
      mainLoop.MaximumSelectionPressureParameter.ActualName = MaximumSelectionPressureParameter.Name;
      mainLoop.MutationProbabilityParameter.ActualName = MutationProbabilityParameter.Name;
      mainLoop.MutatorParameter.ActualName = MutatorParameter.Name;
      mainLoop.OffspringSelectionBeforeMutationParameter.ActualName = OffspringSelectionBeforeMutationParameter.Name;
      mainLoop.RandomParameter.ActualName = RandomCreator.RandomParameter.ActualName;
      mainLoop.ResultsParameter.ActualName = "Results";
      mainLoop.SelectorParameter.ActualName = SelectorParameter.Name;
      mainLoop.SuccessRatioParameter.ActualName = SuccessRatioParameter.Name;
      mainLoop.FillPopulationWithParentsParameter.ActualName = FillPopulationWithParentsParameter.Name;

      foreach (ISelector selector in ApplicationManager.Manager.GetInstances<ISelector>().Where(x => !(x is IMultiObjectiveSelector)).OrderBy(x => x.Name))
        SelectorParameter.ValidValues.Add(selector);
      ISelector proportionalSelector = SelectorParameter.ValidValues.FirstOrDefault(x => x.GetType().Name.Equals("ProportionalSelector"));
      if (proportionalSelector != null) SelectorParameter.Value = proportionalSelector;
      ParameterizeSelectors();

      foreach (IDiscreteDoubleValueModifier modifier in ApplicationManager.Manager.GetInstances<IDiscreteDoubleValueModifier>().OrderBy(x => x.Name))
        ComparisonFactorModifierParameter.ValidValues.Add(modifier);
      IDiscreteDoubleValueModifier linearModifier = ComparisonFactorModifierParameter.ValidValues.FirstOrDefault(x => x.GetType().Name.Equals("LinearDiscreteDoubleValueModifier"));
      if (linearModifier != null) ComparisonFactorModifierParameter.Value = linearModifier;
      ParameterizeComparisonFactorModifiers();

      qualityAnalyzer = new BestAverageWorstQualityAnalyzer();
      selectionPressureAnalyzer = new ValueAnalyzer();
      successfulOffspringAnalyzer = new SuccessfulOffspringAnalyzer();
      ParameterizeAnalyzers();
      UpdateAnalyzers();

      Initialize();
    }
 private OffspringSelectionGeneticAlgorithm(OffspringSelectionGeneticAlgorithm original, Cloner cloner)
   : base(original, cloner) {
   qualityAnalyzer = cloner.Clone(original.qualityAnalyzer);
   selectionPressureAnalyzer = cloner.Clone(original.selectionPressureAnalyzer);
   successfulOffspringAnalyzer = cloner.Clone(original.successfulOffspringAnalyzer);
   Initialize();
 }
    private void AfterDeserialization() {
      // BackwardsCompatibility3.3
      #region Backwards compatible code, remove with 3.4
      if (successfulOffspringAnalyzer == null)
        successfulOffspringAnalyzer = new SuccessfulOffspringAnalyzer();
      if (!Parameters.ContainsKey("ReevaluateElites")) {
        Parameters.Add(new FixedValueParameter<BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)", (BoolValue)new BoolValue(false).AsReadOnly()) { Hidden = true });
      }
      if (!Parameters.ContainsKey("FillPopulationWithParents"))
        Parameters.Add(new FixedValueParameter<BoolValue>("FillPopulationWithParents", "True if the population should be filled with parent individual or false if worse children should be used when the maximum selection pressure is exceeded.", new BoolValue(false)) { Hidden = true });
      #endregion

      Initialize();
    }
Exemple #10
0
 private SASEGASA(SASEGASA original, Cloner cloner)
   : base(original, cloner) {
   qualityAnalyzer = cloner.Clone(original.qualityAnalyzer);
   villageQualityAnalyzer = cloner.Clone(original.villageQualityAnalyzer);
   selectionPressureAnalyzer = cloner.Clone(original.selectionPressureAnalyzer);
   villageSelectionPressureAnalyzer = cloner.Clone(original.villageSelectionPressureAnalyzer);
   successfulOffspringAnalyzer = cloner.Clone(original.successfulOffspringAnalyzer);
   Initialize();
 }
 private SuccessfulOffspringAnalyzer(SuccessfulOffspringAnalyzer original, Cloner cloner) : base(original, cloner) { }