Changeset 11513


Ignore:
Timestamp:
10/30/14 14:47:32 (8 years ago)
Author:
ascheibe
Message:

#2267 made subscopes offspring comparer configurable

Location:
branches/VOSGA/HeuristicLab.Algorithms.VOffspringSelectionGeneticAlgorithm
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • branches/VOSGA/HeuristicLab.Algorithms.VOffspringSelectionGeneticAlgorithm/HeuristicLab.Algorithms.VOffspringSelectionGeneticAlgorithm-3.3.csproj

    r11511 r11513  
    161161  </ItemGroup>
    162162  <ItemGroup>
     163    <Compile Include="ISubScopesQualityComparatorOperator.cs" />
    163164    <Compile Include="OffspringCollector.cs" />
    164165    <Compile Include="OffspringSelectors\IOffspringSelector.cs" />
     
    171172    <Compile Include="VOffspringSelectionGeneticAlgorithmMainLoop.cs" />
    172173    <Compile Include="VOffspringSelectionGeneticAlgorithmMainOperator.cs" />
     174    <Compile Include="WeightedParentsQualityComparator.cs" />
    173175  </ItemGroup>
    174176  <ItemGroup>
  • branches/VOSGA/HeuristicLab.Algorithms.VOffspringSelectionGeneticAlgorithm/VOffspringSelectionGeneticAlgorithm.cs

    r11510 r11513  
    118118      get { return (IConstrainedValueParameter<IOffspringSelector>)Parameters["OffspringSelector"]; }
    119119    }
     120    public ConstrainedValueParameter<ISubScopesQualityComparatorOperator> SubScopesQualityComparatorParameter {
     121      get { return (ConstrainedValueParameter<ISubScopesQualityComparatorOperator>)Parameters["SubScopesQualityComparator"]; }
     122    }
    120123    #endregion
    121124
     
    205208      set { FillPopulationWithParentsParameter.Value.Value = value; }
    206209    }
     210    public ISubScopesQualityComparatorOperator SubScopesQualityComparator {
     211      get { return SubScopesQualityComparatorParameter.Value; }
     212      set { SubScopesQualityComparatorParameter.Value = value; }
     213    }
     214
    207215    private RandomCreator RandomCreator {
    208216      get { return (RandomCreator)OperatorGraph.InitialOperator; }
     
    272280      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 });
    273281      Parameters.Add(new ConstrainedValueParameter<IOffspringSelector>("OffspringSelector", "The operator used as selection criterea for deciding which individuals are successful and which should be disgarded."));
    274 
     282      Parameters.Add(new ConstrainedValueParameter<ISubScopesQualityComparatorOperator>("SubScopesQualityComparator", "The operator used to compare solution candidates with."));
    275283
    276284      RandomCreator randomCreator = new RandomCreator();
     
    336344      ParameterizeOffspringSelectors();
    337345
     346      foreach (ISubScopesQualityComparatorOperator comparator in ApplicationManager.Manager.GetInstances<ISubScopesQualityComparatorOperator>().OrderBy(x => x.Name))
     347        SubScopesQualityComparatorParameter.ValidValues.Add(comparator);
     348      ISubScopesQualityComparatorOperator standardComparator = SubScopesQualityComparatorParameter.ValidValues.FirstOrDefault(x => x.GetType().Name.Equals("WeightedParentsQualityComparator"));
     349      if (standardComparator != null) SubScopesQualityComparatorParameter.Value = standardComparator;
     350      ParameterizeSubScopesQualityComparators();
     351
    338352      qualityAnalyzer = new BestAverageWorstQualityAnalyzer();
    339353      selectionPressureAnalyzer = new ValueAnalyzer();
     
    362376      UpdateMutators();
    363377      UpdateAnalyzers();
     378      ParameterizeSubScopesQualityComparators();
     379      ParameterizeOffspringSelectors();
    364380      Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
    365381      base.OnProblemChanged();
     
    457473        selector.SuccessfulOffspringParameter.ActualName = "SuccessfulOffspring";
    458474        selector.FillPopulationWithParentsParameter.ActualName = FillPopulationWithParentsParameter.Name;
     475      }
     476    }
     477    private void ParameterizeSubScopesQualityComparators() {
     478      foreach (var comp in SubScopesQualityComparatorParameter.ValidValues) {
     479        comp.ComparisonFactorParameter.ActualName = "ComparisonFactor";
     480        if (Problem != null) {
     481          comp.LeftSideParameter.ActualName = Problem.Evaluator.QualityParameter.Name;
     482          comp.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
     483          comp.RightSideParameter.ActualName = Problem.Evaluator.QualityParameter.Name;
     484        }
     485        comp.ResultParameter.ActualName = "SuccessfulOffspring";
    459486      }
    460487    }
  • branches/VOSGA/HeuristicLab.Algorithms.VOffspringSelectionGeneticAlgorithm/VOffspringSelectionGeneticAlgorithmMainOperator.cs

    r11510 r11513  
    9393    public ValueLookupParameter<IOffspringSelector> OffspringSelectorParameter {
    9494      get { return (ValueLookupParameter<IOffspringSelector>)Parameters["OffspringSelector"]; }
     95    }
     96    public ValueLookupParameter<ISubScopesQualityComparatorOperator> SubScopesQualityComparatorParameter {
     97      get { return (ValueLookupParameter<ISubScopesQualityComparatorOperator>)Parameters["SubScopesQualityComparator"]; }
    9598    }
    9699    #endregion
     
    142145      Parameters.Add(new ValueLookupParameter<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."));
    143146      Parameters.Add(new ValueLookupParameter<IOffspringSelector>("OffspringSelector", "The operator used as selection criterea for deciding which individuals are successful and which should be disgarded."));
     147      Parameters.Add(new ValueLookupParameter<ISubScopesQualityComparatorOperator>("SubScopesQualityComparator", "The operator used to compare solution candidates."));
    144148      #endregion
    145149
     
    154158      Placeholder evaluator1 = new Placeholder();
    155159      SubScopesCounter subScopesCounter1 = new SubScopesCounter();
    156       WeightedParentsQualityComparator qualityComparer1 = new WeightedParentsQualityComparator();
     160      Placeholder qualityComparer1 = new Placeholder();
    157161      SubScopesRemover subScopesRemover1 = new SubScopesRemover();
    158162      UniformSubScopesProcessor uniformSubScopesProcessor3 = new UniformSubScopesProcessor();
     
    174178      Placeholder evaluator3 = new Placeholder();
    175179      SubScopesCounter subScopesCounter3 = new SubScopesCounter();
    176       WeightedParentsQualityComparator qualityComparer2 = new WeightedParentsQualityComparator();
     180      Placeholder qualityComparer2 = new Placeholder();
    177181      SubScopesRemover subScopesRemover2 = new SubScopesRemover();
    178182      Placeholder offspringSelector = new Placeholder();
     
    208212      subScopesCounter1.ValueParameter.ActualName = EvaluatedSolutionsParameter.Name;
    209213
    210       qualityComparer1.ComparisonFactorParameter.ActualName = ComparisonFactorParameter.Name;
    211       qualityComparer1.LeftSideParameter.ActualName = QualityParameter.Name;
    212       qualityComparer1.MaximizationParameter.ActualName = MaximizationParameter.Name;
    213       qualityComparer1.RightSideParameter.ActualName = QualityParameter.Name;
    214       qualityComparer1.ResultParameter.ActualName = "SuccessfulOffspring";
     214      qualityComparer1.Name = "Quality Comparator (placeholder)";
     215      qualityComparer1.OperatorParameter.ActualName = SubScopesQualityComparatorParameter.ActualName;
    215216
    216217      subScopesRemover1.RemoveAllSubScopes = true;
     
    257258      subScopesCounter3.ValueParameter.ActualName = EvaluatedSolutionsParameter.Name;
    258259
    259       qualityComparer2.ComparisonFactorParameter.ActualName = ComparisonFactorParameter.Name;
    260       qualityComparer2.LeftSideParameter.ActualName = QualityParameter.Name;
    261       qualityComparer2.MaximizationParameter.ActualName = MaximizationParameter.Name;
    262       qualityComparer2.RightSideParameter.ActualName = QualityParameter.Name;
    263       qualityComparer2.ResultParameter.ActualName = "SuccessfulOffspring";
     260      qualityComparer2.Name = "Quality Comparator (placeholder)";
     261      qualityComparer2.OperatorParameter.ActualName = SubScopesQualityComparatorParameter.ActualName;
    264262
    265263      subScopesRemover2.RemoveAllSubScopes = true;
Note: See TracChangeset for help on using the changeset viewer.