Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/30/12 14:13:17 (12 years ago)
Author:
jkarder
Message:

#1247:

  • adjusted event handling
  • improved operator graph
  • changed default parameter values
Location:
branches/RAPGA/HeuristicLab.Algorithms.RAPGA/3.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/RAPGA/HeuristicLab.Algorithms.RAPGA/3.3/RAPGA.cs

    r8349 r8359  
    189189      Parameters.Add(new ValueParameter<IntValue>("Seed", "The random seed used to initialize the new pseudo random number generator.", new IntValue(0)));
    190190      Parameters.Add(new ValueParameter<BoolValue>("SetSeedRandomly", "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true)));
    191       Parameters.Add(new ValueParameter<IntValue>("PopulationSize", "The size of the population of solutions.", new IntValue(300)));
     191      Parameters.Add(new ValueParameter<IntValue>("PopulationSize", "The size of the population of solutions.", new IntValue(100)));
    192192      Parameters.Add(new ValueParameter<IntValue>("MinimumPopulationSize", "The minimum size of the population of solutions.", new IntValue(2)));
    193       Parameters.Add(new ValueParameter<IntValue>("MaximumPopulationSize", "The maximum size of the population of solutions.", new IntValue(499)));
     193      Parameters.Add(new ValueParameter<IntValue>("MaximumPopulationSize", "The maximum size of the population of solutions.", new IntValue(299)));
    194194      Parameters.Add(new ValueParameter<DoubleValue>("ComparisonFactor", "The comparison factor.", new DoubleValue(0.0)));
    195       Parameters.Add(new ValueParameter<IntValue>("Effort", "The maximum number of offspring created in each generation.", new IntValue(1000)));
     195      Parameters.Add(new ValueParameter<IntValue>("Effort", "The maximum number of offspring created in each generation.", new IntValue(400)));
    196196      Parameters.Add(new ConstrainedValueParameter<ISelector>("Selector", "The operator used to select solutions for reproduction."));
    197197      Parameters.Add(new ConstrainedValueParameter<ICrossover>("Crossover", "The operator used to cross solutions."));
     
    302302      base.Problem_OperatorsChanged(sender, e);
    303303    }
     304    void EffortParameter_ValueChanged(object sender, EventArgs e) {
     305      Effort.ValueChanged +=new EventHandler(Effort_ValueChanged);
     306      ParameterizeSelectors();
     307    }
     308    void Effort_ValueChanged(object sender, EventArgs e) {
     309      ParameterizeSelectors();
     310    }
    304311    private void ElitesParameter_ValueChanged(object sender, EventArgs e) {
    305312      Elites.ValueChanged += new EventHandler(Elites_ValueChanged);
     
    330337      ElitesParameter.ValueChanged += new EventHandler(ElitesParameter_ValueChanged);
    331338      Elites.ValueChanged += new EventHandler(Elites_ValueChanged);
     339      EffortParameter.ValueChanged += new EventHandler(EffortParameter_ValueChanged);
     340      Effort.ValueChanged += new EventHandler(Effort_ValueChanged);
    332341      if (Problem != null) {
    333342        Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
     
    356365      foreach (ISelector selector in SelectorParameter.ValidValues) {
    357366        selector.CopySelected = new BoolValue(true);
    358         selector.NumberOfSelectedSubScopesParameter.Value = new IntValue(2 * (PopulationSizeParameter.Value.Value - ElitesParameter.Value.Value));
     367        selector.NumberOfSelectedSubScopesParameter.Value = new IntValue(2 * EffortParameter.Value.Value);
    359368        selector.NumberOfSelectedSubScopesParameter.Hidden = true;
    360369        ParameterizeStochasticOperator(selector);
  • branches/RAPGA/HeuristicLab.Algorithms.RAPGA/3.3/RAPGAMainLoop.cs

    r8349 r8359  
    136136      #region Create operators
    137137      VariableCreator variableCreator = new VariableCreator();
    138       Assigner assigner1 = new Assigner();
    139       ResultsCollector resultsCollector1 = new ResultsCollector();
     138      IntCounter intCounter1 = new IntCounter();
     139      ResultsCollector resultsCollector = new ResultsCollector();
    140140      Placeholder analyzer1 = new Placeholder();
    141141      Placeholder selector = new Placeholder();
     
    149149      Placeholder evaluator = new Placeholder();
    150150      WeightedParentsQualityComparator comparator1 = new WeightedParentsQualityComparator();
     151      SubScopesCounter subScopesCounter1 = new SubScopesCounter();
    151152      ConditionalSelector conditionalSelector = new ConditionalSelector();
    152153      RightReducer rightReducer1 = new RightReducer();
     
    155156      DuplicateSelector duplicateSelector = new DuplicateSelector();
    156157      LeftReducer leftReducer = new LeftReducer();
    157       SubScopesCounter subScopesCounter1 = new SubScopesCounter();
    158       IntCounter intCounter1 = new IntCounter();
     158      SubScopesCounter subScopesCounter2 = new SubScopesCounter();
    159159      Comparator comparator2 = new Comparator();
    160160      ConditionalBranch conditionalBranch1 = new ConditionalBranch();
     
    170170      Placeholder analyzer2 = new Placeholder();
    171171      ConditionalBranch conditionalBranch2 = new ConditionalBranch();
    172       Assigner assigner2 = new Assigner();
    173       SubScopesCounter subScopesCounter2 = new SubScopesCounter();
    174       ResultsCollector resultsCollector2 = new ResultsCollector();
     172      SubScopesCounter subScopesCounter3 = new SubScopesCounter();
    175173      Comparator comparator4 = new Comparator();
    176174      ConditionalBranch conditionalBranch3 = new ConditionalBranch();
    177175
    178       variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Generations", new IntValue(0))); // Class GeneticAlgorithm expects this to be called Generations
     176      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Generations", new IntValue(0))); // Class RAPGA expects this to be called Generations
    179177      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("CurrentPopulationSize", new IntValue(0)));
    180178
    181       assigner1.Name = "Initialize CurrentPopulationSize";
    182       assigner1.LeftSideParameter.ActualName = "CurrentPopulationSize";
    183       assigner1.RightSideParameter.ActualName = EvaluatedSolutionsParameter.ActualName;
    184 
    185       resultsCollector1.CollectedValues.Add(new LookupParameter<IntValue>("Generations"));
    186       resultsCollector1.CollectedValues.Add(new LookupParameter<IntValue>("CurrentPopulationSize"));
    187       resultsCollector1.ResultsParameter.ActualName = "Results";
     179      intCounter1.Name = "Initialize CurrentPopulationSize";
     180      intCounter1.IncrementParameter.ActualName = PopulationSizeParameter.Name;
     181      intCounter1.IncrementParameter.Value = null;
     182      intCounter1.ValueParameter.ActualName = "CurrentPopulationSize";
     183
     184      resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Generations"));
     185      resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("CurrentPopulationSize"));
     186      resultsCollector.ResultsParameter.ActualName = "Results";
    188187
    189188      analyzer1.Name = "Analyzer";
     
    215214      comparator1.ResultParameter.ActualName = "SuccessfulOffspring";
    216215
     216      subScopesCounter1.Name = "Increment EvaluatedSolutions";
     217      subScopesCounter1.ValueParameter.ActualName = EvaluatedSolutionsParameter.Name;
     218
    217219      conditionalSelector.ConditionParameter.ActualName = "SuccessfulOffspring";
    218220      conditionalSelector.ConditionParameter.Depth = 1;
     
    225227      subScopesRemover.RemoveAllSubScopes = true;
    226228
    227       subScopesCounter1.Name = "Count Successful Offspring";
    228       subScopesCounter1.ValueParameter.ActualName = "NumberOfSuccessfulOffspring";
    229 
    230       intCounter1.IncrementParameter.ActualName = "NumberOfSuccessfulOffspring";
    231       intCounter1.IncrementParameter.Value = null;
    232       intCounter1.ValueParameter.ActualName = EvaluatedSolutionsParameter.Name;
     229      subScopesCounter2.Name = "Count Successful Offspring";
     230      subScopesCounter2.ValueParameter.ActualName = "NumberOfSuccessfulOffspring";
    233231
    234232      comparator2.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
     
    239237      conditionalBranch1.ConditionParameter.ActualName = "SelectMaximum";
    240238
    241       bestSelector1.CopySelected = new BoolValue(true);
     239      bestSelector1.CopySelected = new BoolValue(false);
    242240      bestSelector1.MaximizationParameter.ActualName = MaximizationParameter.Name;
    243241      bestSelector1.NumberOfSelectedSubScopesParameter.ActualName = MaximumPopulationSizeParameter.Name;
    244242      bestSelector1.QualityParameter.ActualName = QualityParameter.Name;
    245243
    246       bestSelector2.CopySelected = new BoolValue(true);
     244      bestSelector2.CopySelected = new BoolValue(false);
    247245      bestSelector2.MaximizationParameter.ActualName = MaximizationParameter.Name;
    248246      bestSelector2.NumberOfSelectedSubScopesParameter.ActualName = "NumberOfSuccessfulOffspring";
     
    267265      conditionalBranch2.ConditionParameter.ActualName = "Terminate";
    268266
    269       assigner2.Name = "Reset CurrentPopulationSize";
    270       assigner2.LeftSideParameter.ActualName = "CurrentPopulationSize";
    271       assigner2.RightSideParameter.Value = new IntValue(0);
    272 
    273       subScopesCounter2.Name = "Set CurrentPopulationSize";
    274       subScopesCounter2.ValueParameter.ActualName = "CurrentPopulationSize";
    275 
    276       resultsCollector2.CollectedValues.Add(new LookupParameter<IntValue>("CurrentPopulationSize"));
    277       resultsCollector2.ResultsParameter.ActualName = "Results";
     267      subScopesCounter3.Name = "Set CurrentPopulationSize";
     268      subScopesCounter3.ValueParameter.ActualName = "CurrentPopulationSize";
     269      subScopesCounter3.AccumulateParameter.Value = new BoolValue(false);
    278270
    279271      comparator4.Comparison = new Comparison(ComparisonType.Less);
     
    287279      #region Create operator graph
    288280      OperatorGraph.InitialOperator = variableCreator;
    289       variableCreator.Successor = assigner1;
    290       assigner1.Successor = resultsCollector1;
    291       resultsCollector1.Successor = analyzer1;
     281      variableCreator.Successor = intCounter1;
     282      intCounter1.Successor = resultsCollector;
     283      resultsCollector.Successor = analyzer1;
    292284      analyzer1.Successor = selector;
    293285      selector.Successor = subScopesProcessor1;
     
    305297      subScopesRemover.Successor = null;
    306298      uniformSubScopesProcessor2.Operator = evaluator;
    307       uniformSubScopesProcessor2.Successor = conditionalSelector;
     299      uniformSubScopesProcessor2.Successor = subScopesCounter1;
    308300      evaluator.Successor = comparator1;
     301      subScopesCounter1.Successor = conditionalSelector;
    309302      conditionalSelector.Successor = rightReducer1;
    310303      rightReducer1.Successor = uniformSubScopesProcessor3;
     
    312305      uniformSubScopesProcessor3.Successor = duplicateSelector;
    313306      duplicateSelector.Successor = leftReducer;
    314       leftReducer.Successor = subScopesCounter1;
    315       subScopesCounter1.Successor = intCounter1;
    316       intCounter1.Successor = comparator2;
     307      leftReducer.Successor = subScopesCounter2;
     308      subScopesCounter2.Successor = comparator2;
    317309      comparator2.Successor = conditionalBranch1;
    318310      conditionalBranch1.TrueBranch = bestSelector1;
     
    329321      comparator3.Successor = analyzer2;
    330322      analyzer2.Successor = conditionalBranch2;
    331       conditionalBranch2.FalseBranch = assigner2;
     323      conditionalBranch2.FalseBranch = subScopesCounter3;
    332324      conditionalBranch2.TrueBranch = null;
    333325      conditionalBranch2.Successor = null;
    334       assigner2.Successor = subScopesCounter2;
    335       subScopesCounter2.Successor = resultsCollector2;
    336       resultsCollector2.Successor = comparator4;
     326      subScopesCounter3.Successor = comparator4;
    337327      comparator4.Successor = conditionalBranch3;
    338328      conditionalBranch3.FalseBranch = selector;
Note: See TracChangeset for help on using the changeset viewer.