Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/05/10 13:52:16 (15 years ago)
Author:
gkronber
Message:

Added best solution analyzer for artificial ant problem. #999 (Refactor algorithm analysis and tracing)

Location:
trunk/sources/HeuristicLab.Problems.ArtificialAnt/3.3/Analyzers
Files:
1 added
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.ArtificialAnt/3.3/Analyzers/IAntTrailPopulationAnalyzer.cs

    r3628 r3631  
    2727using HeuristicLab.Data;
    2828
    29 namespace HeuristicLab.Problems.ArtificialAnt {
    30   public interface IAntTrailVisualizer : IAnalyzer {
     29namespace HeuristicLab.Problems.ArtificialAnt.Analyzers {
     30  public interface IAntTrailPopulationAnalyzer : IPopulationAnalyzer {
     31    ILookupParameter<ItemArray<DoubleValue>> QualityParameter { get; }
    3132    ILookupParameter<ItemArray<SymbolicExpressionTree>> SymbolicExpressionTreeParameter { get; }
    3233    ILookupParameter<BoolMatrix> WorldParameter { get; }
  • trunk/sources/HeuristicLab.Problems.ArtificialAnt/3.3/Analyzers/PopulationBestAntTrailAnalyzer.cs

    r3628 r3631  
    3030using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    3131
    32 namespace HeuristicLab.Problems.ArtificialAnt {
     32namespace HeuristicLab.Problems.ArtificialAnt.Analyzers {
    3333  /// <summary>
    3434  /// An operator for visualizing the best ant trail of an artificial ant problem.
    3535  /// </summary>
    36   [Item("BestAntTrailVisualizer", "An operator for visualizing the best ant trail of an artificial ant problem.")]
     36  [Item("PopulationBestAntTrailAnalyzer", "An operator for visualizing the best ant trail of an artificial ant problem.")]
    3737  [StorableClass]
    38   public sealed class BestAntTrailVisualizer : SingleSuccessorOperator, IAntTrailVisualizer {
     38  public sealed class PopulationBestAntTrailAnalyzer : SingleSuccessorOperator, IAntTrailPopulationAnalyzer {
    3939    public ILookupParameter<BoolMatrix> WorldParameter {
    4040      get { return (ILookupParameter<BoolMatrix>)Parameters["World"]; }
     
    4949      get { return (ILookupParameter<IntValue>)Parameters["MaxTimeSteps"]; }
    5050    }
    51 
    52     public ILookupParameter<AntTrail> AntTrailParameter {
    53       get { return (ILookupParameter<AntTrail>)Parameters["AntTrail"]; }
     51    public ILookupParameter<AntTrail> BestSolutionParameter {
     52      get { return (ILookupParameter<AntTrail>)Parameters["BestSolution"]; }
     53    }
     54    public ValueLookupParameter<ResultCollection> ResultsParameter {
     55      get { return (ValueLookupParameter<ResultCollection>)Parameters["Results"]; }
    5456    }
    5557
    56     public BestAntTrailVisualizer()
     58    public PopulationBestAntTrailAnalyzer()
    5759      : base() {
    5860      Parameters.Add(new LookupParameter<BoolMatrix>("World", "The world with food items for the artificial ant."));
    5961      Parameters.Add(new SubScopesLookupParameter<SymbolicExpressionTree>("SymbolicExpressionTree", "The artificial ant solutions from which the best solution should be visualized."));
    6062      Parameters.Add(new SubScopesLookupParameter<DoubleValue>("Quality", "The qualities of the artificial ant solutions which should be visualized."));
    61       Parameters.Add(new LookupParameter<AntTrail>("AntTrail", "The visual representation of the best ant trail."));
     63      Parameters.Add(new LookupParameter<AntTrail>("BestSolution", "The visual representation of the best ant trail."));
    6264      Parameters.Add(new LookupParameter<IntValue>("MaxTimeSteps", "The maximal time steps that the artificial ant has available to collect all food items."));
     65      Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The result collection where the best artificial ant solution should be stored."));
    6366    }
    6467
     
    6871      BoolMatrix world = WorldParameter.ActualValue;
    6972      IntValue maxTimeSteps = MaxTimeStepsParameter.ActualValue;
     73      ResultCollection results = ResultsParameter.ActualValue;
    7074
    7175      int i = qualities.Select((x, index) => new { index, x.Value }).OrderBy(x => -x.Value).First().index;
    7276
    73       AntTrail antTrail = AntTrailParameter.ActualValue;
    74       if (antTrail == null) AntTrailParameter.ActualValue = new AntTrail(world, expressions[i], maxTimeSteps);
    75       else {
     77      AntTrail antTrail = BestSolutionParameter.ActualValue;
     78      if (antTrail == null) {
     79        var bestAntTrail = new AntTrail(world, expressions[i], maxTimeSteps);
     80        BestSolutionParameter.ActualValue = bestAntTrail;
     81        results.Add(new Result("Best Artificial Ant Solution", bestAntTrail));
     82      } else {
    7683        antTrail.World = world;
    7784        antTrail.SymbolicExpressionTree = expressions[i];
    7885        antTrail.MaxTimeSteps = maxTimeSteps;
     86        results["Best Artificial Ant Solution"].Value = antTrail;
    7987      }
    8088      return base.Apply();
Note: See TracChangeset for help on using the changeset viewer.