Changeset 3618


Ignore:
Timestamp:
05/05/10 02:02:51 (12 years ago)
Author:
swagner
Message:

Worked on refactoring of algorithm analysis and tracing (#999)

  • added interfaces to specify on which scope level an analyzer can be applied
  • adapted MultiAnalyzer
Location:
trunk/sources
Files:
3 added
5 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.GeneticAlgorithm/3.3/GeneticAlgorithm.cs

    r3616 r3618  
    7878      get { return (ValueParameter<IntValue>)Parameters["Elites"]; }
    7979    }
    80     private ValueParameter<MultiAnalyzer> AnalyzerParameter {
    81       get { return (ValueParameter<MultiAnalyzer>)Parameters["Analyzer"]; }
     80    private ValueParameter<MultiAnalyzer<IPopulationAnalyzer>> AnalyzerParameter {
     81      get { return (ValueParameter<MultiAnalyzer<IPopulationAnalyzer>>)Parameters["Analyzer"]; }
    8282    }
    8383    private ValueParameter<IntValue> MaximumGenerationsParameter {
     
    119119      set { ElitesParameter.Value = value; }
    120120    }
    121     public MultiAnalyzer Analyzer {
     121    public MultiAnalyzer<IPopulationAnalyzer> Analyzer {
    122122      get { return AnalyzerParameter.Value; }
    123123      set { AnalyzerParameter.Value = value; }
     
    140140      get { return selectors; }
    141141    }
    142     private BestAverageWorstQualityAnalyzer qualityAnalyzer;
     142    private PopulationBestAverageWorstQualityAnalyzer qualityAnalyzer;
    143143    #endregion
    144144
     
    153153      Parameters.Add(new OptionalConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions."));
    154154      Parameters.Add(new ValueParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation.", new IntValue(1)));
    155       Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze each generation.", new MultiAnalyzer()));
     155      Parameters.Add(new ValueParameter<MultiAnalyzer<IPopulationAnalyzer>>("Analyzer", "The operator used to analyze each generation.", new MultiAnalyzer<IPopulationAnalyzer>()));
    156156      Parameters.Add(new ValueParameter<IntValue>("MaximumGenerations", "The maximum number of generations which should be processed.", new IntValue(1000)));
    157157
     
    291291    }
    292292    private void InitializeAnalyzers() {
    293       qualityAnalyzer = new BestAverageWorstQualityAnalyzer();
     293      qualityAnalyzer = new PopulationBestAverageWorstQualityAnalyzer();
    294294      ParameterizeAnalyzers();
    295295    }
     
    353353      Analyzer.Operators.Add(qualityAnalyzer);
    354354      if (Problem != null) {
    355         foreach (IAnalyzer analyzer in Problem.Operators.OfType<IAnalyzer>().OrderBy(x => x.Name))
     355        foreach (IPopulationAnalyzer analyzer in Problem.Operators.OfType<IPopulationAnalyzer>().OrderBy(x => x.Name))
    356356          Analyzer.Operators.Add(analyzer);
    357357      }
  • trunk/sources/HeuristicLab.Analysis/3.3/HeuristicLab.Analysis-3.3.csproj

    r3616 r3618  
    8585  <ItemGroup>
    8686    <None Include="HeuristicLabAnalysisPlugin.cs.frame" />
    87     <Compile Include="BestAverageWorstQualityAnalyzer.cs" />
    8887    <Compile Include="BestAverageWorstQualityCalculator.cs" />
    8988    <Compile Include="BestQualityMemorizer.cs" />
    9089    <Compile Include="MultiAnalyzer.cs" />
     90    <Compile Include="PopulationBestAverageWorstQualityAnalyzer.cs" />
    9191    <Compile Include="QualityDifferenceCalculator.cs" />
    9292    <Compile Include="DataRow.cs" />
  • trunk/sources/HeuristicLab.Analysis/3.3/MultiAnalyzer.cs

    r3616 r3618  
    3232  /// An analyzer which applies arbitrary many other analyzers.
    3333  /// </summary>
    34   [Item("MultiAnalyzer", "An analyzer which applies arbitrary many other analyzers.")]
     34  [Item("MultiAnalyzer<T>", "An analyzer which applies arbitrary many other analyzers.")]
    3535  [StorableClass]
    36   public class MultiAnalyzer : CheckedMultiOperator<IAnalyzer>, IAnalyzer {
     36  public class MultiAnalyzer<T> : CheckedMultiOperator<T>, IAnalyzer where T : class, IAnalyzer {
    3737    public override bool CanChangeName {
    3838      get { return false; }
     
    6969        counter.Value = 0;
    7070        OperationCollection next = new OperationCollection();
    71         foreach (IndexedItem<IAnalyzer> item in Operators.CheckedItems)
     71        foreach (IndexedItem<T> item in Operators.CheckedItems)
    7272          next.Add(ExecutionContext.CreateOperation(item.Value));
    7373        next.Add(base.Apply());
  • trunk/sources/HeuristicLab.Analysis/3.3/PopulationBestAverageWorstQualityAnalyzer.cs

    r3616 r3618  
    3232  /// An operator which analyzes the best, average and worst solution quality in the current population.
    3333  /// </summary>
    34   [Item("BestAverageWorstQualityAnalyzer", "An operator which analyzes the best, average and worst solution quality in the current population.")]
     34  [Item("PopulationBestAverageWorstQualityAnalyzer", "An operator which analyzes the best, average and worst solution quality in the current population.")]
    3535  [StorableClass]
    36   public sealed class BestAverageWorstQualityAnalyzer : AlgorithmOperator, IAnalyzer {
     36  public sealed class PopulationBestAverageWorstQualityAnalyzer : AlgorithmOperator, IPopulationAnalyzer {
    3737    #region Parameter properties
    3838    public ValueLookupParameter<BoolValue> MaximizationParameter {
     
    6969
    7070    [StorableConstructor]
    71     private BestAverageWorstQualityAnalyzer(bool deserializing) : base() { }
    72     public BestAverageWorstQualityAnalyzer()
     71    private PopulationBestAverageWorstQualityAnalyzer(bool deserializing) : base() { }
     72    public PopulationBestAverageWorstQualityAnalyzer()
    7373      : base() {
    7474      Initialize();
  • trunk/sources/HeuristicLab.Optimization/3.3/HeuristicLab.Optimization-3.3.csproj

    r3617 r3618  
    8787    <Compile Include="Algorithm.cs" />
    8888    <Compile Include="BatchRun.cs" />
     89    <Compile Include="Interfaces\IMultiPopulationAnalyzer.cs" />
     90    <Compile Include="Interfaces\IPopulationAnalyzer.cs" />
     91    <Compile Include="Interfaces\ISolutionAnalyzer.cs" />
    8992    <Compile Include="RunCollectionConstraints\RunCollectionComparisonConstraint.cs" />
    9093    <Compile Include="RunCollectionConstraints\RunCollectionConstraintCollection.cs" />
  • trunk/sources/HeuristicLab.Problems.TravelingSalesman/3.3/Analyzers/BestTSPSolutionAnalyzer.cs

    r3616 r3618  
    3636  [Item("BestTSPSolutionAnalyzer", "An operator for analyzing the best solution of Traveling Salesman Problems given in path representation using city coordinates.")]
    3737  [StorableClass]
    38   public sealed class BestTSPSolutionAnalyzer : SingleSuccessorOperator, IAnalyzer {
     38  public sealed class BestTSPSolutionAnalyzer : SingleSuccessorOperator, IPopulationAnalyzer {
    3939    public LookupParameter<DoubleMatrix> CoordinatesParameter {
    4040      get { return (LookupParameter<DoubleMatrix>)Parameters["Coordinates"]; }
Note: See TracChangeset for help on using the changeset viewer.