Changeset 3642


Ignore:
Timestamp:
05/05/10 16:37:12 (12 years ago)
Author:
svonolfe
Message:

Added anaylzers for the onemax problem (#999)

Location:
trunk/sources/HeuristicLab.Problems.OneMax/3.3
Files:
6 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.OneMax/3.3/HeuristicLab.Problems.OneMax-3.3.csproj

    r3384 r3642  
    8686  </ItemGroup>
    8787  <ItemGroup>
     88    <Compile Include="Analyzers\BestOneMaxSolutionAnalyzer.cs" />
     89    <Compile Include="Analyzers\MultiPopulationBestOneMaxSolutionAnalyzer.cs" />
     90    <Compile Include="Analyzers\PopulationBestOneMaxSolutionAnalyzer.cs" />
     91    <Compile Include="Interfaces\IBestOneMaxSolutionAnalyzer.cs" />
    8892    <Compile Include="Interfaces\IOneMaxSolutionsVisualizer.cs" />
    8993    <Compile Include="Interfaces\IOneMaxMoveEvaluator.cs" />
     94    <Compile Include="OneMaxSolution.cs" />
    9095    <Compile Include="MoveEvaluators\OneMaxMoveEvaluator.cs" />
    9196    <Compile Include="MoveEvaluators\OneMaxOneBitflipMoveEvaluator.cs" />
  • trunk/sources/HeuristicLab.Problems.OneMax/3.3/OnemaxProblem.cs

    r3616 r3642  
    3232using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3333using HeuristicLab.PluginInfrastructure;
     34using HeuristicLab.Problems.OneMax.Analyzers;
    3435
    3536namespace HeuristicLab.Problems.OneMax {
     
    9798      get { return BestKnownQualityParameter.Value; }
    9899    }
    99     private List<IBinaryVectorOperator> operators;
     100    private List<IOperator> operators;
    100101    public IEnumerable<IOperator> Operators {
    101102      get { return operators.Cast<IOperator>(); }
     103    }
     104    private IEnumerable<IBestOneMaxSolutionAnalyzer> BestOneMaxSolutionAnalyzers {
     105      get { return operators.OfType<IBestOneMaxSolutionAnalyzer>(); }
    102106    }
    103107    #endregion
     
    150154
    151155    private void SolutionCreatorParameter_ValueChanged(object sender, EventArgs e) {
    152       SolutionCreator.BinaryVectorParameter.ActualNameChanged += new EventHandler(SolutionCreator_PermutationParameter_ActualNameChanged);
     156      SolutionCreator.BinaryVectorParameter.ActualNameChanged += new EventHandler(SolutionCreator_BinaryVectorParameter_ActualNameChanged);
    153157      ParameterizeSolutionCreator();
    154158      ParameterizeEvaluator();
     159      ParameterizeAnalyzers();
    155160      ParameterizeOperators();
    156161      OnSolutionCreatorChanged();
    157162    }
    158     private void SolutionCreator_PermutationParameter_ActualNameChanged(object sender, EventArgs e) {
    159       ParameterizeEvaluator();
     163    private void SolutionCreator_BinaryVectorParameter_ActualNameChanged(object sender, EventArgs e) {
     164      ParameterizeEvaluator();
     165      ParameterizeAnalyzers();
    160166      ParameterizeOperators();
    161167    }
    162168    private void EvaluatorParameter_ValueChanged(object sender, EventArgs e) {
    163169      ParameterizeEvaluator();
     170      ParameterizeAnalyzers();
    164171      OnEvaluatorChanged();
    165172    }
     
    188195      InitializeOperators();
    189196      SolutionCreatorParameter.ValueChanged += new EventHandler(SolutionCreatorParameter_ValueChanged);
    190       SolutionCreator.BinaryVectorParameter.ActualNameChanged += new EventHandler(SolutionCreator_PermutationParameter_ActualNameChanged);
     197      SolutionCreator.BinaryVectorParameter.ActualNameChanged += new EventHandler(SolutionCreator_BinaryVectorParameter_ActualNameChanged);
    191198      EvaluatorParameter.ValueChanged += new EventHandler(EvaluatorParameter_ValueChanged);
    192199      LengthParameter.ValueChanged += new EventHandler(LengthParameter_ValueChanged);
     
    202209        ((OneMaxEvaluator)Evaluator).BinaryVectorParameter.ActualName = SolutionCreator.BinaryVectorParameter.ActualName;
    203210    }
     211    private void ParameterizeAnalyzers() {
     212      foreach (IBestOneMaxSolutionAnalyzer analyzer in BestOneMaxSolutionAnalyzers) {
     213        analyzer.BinaryVectorParameter.ActualName = SolutionCreator.BinaryVectorParameter.ActualName;
     214        analyzer.ResultsParameter.ActualName = "Results";
     215      }
     216    }
    204217    private void InitializeOperators() {
    205       operators = new List<IBinaryVectorOperator>();
     218      operators = new List<IOperator>();
     219      operators.Add(new BestOneMaxSolutionAnalyzer());
     220      operators.Add(new PopulationBestOneMaxSolutionAnalyzer());
     221      operators.Add(new MultiPopulationBestOneMaxSolutionAnalyzer());
     222      ParameterizeAnalyzers();
    206223      foreach(IBinaryVectorOperator op in ApplicationManager.Manager.GetInstances<IBinaryVectorOperator>()) {
    207224        if (!(op is ISingleObjectiveMoveEvaluator) || (op is IOneMaxMoveEvaluator)) {
Note: See TracChangeset for help on using the changeset viewer.