- Timestamp:
- 05/05/10 13:52:16 (15 years ago)
- 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 27 27 using HeuristicLab.Data; 28 28 29 namespace HeuristicLab.Problems.ArtificialAnt { 30 public interface IAntTrailVisualizer : IAnalyzer { 29 namespace HeuristicLab.Problems.ArtificialAnt.Analyzers { 30 public interface IAntTrailPopulationAnalyzer : IPopulationAnalyzer { 31 ILookupParameter<ItemArray<DoubleValue>> QualityParameter { get; } 31 32 ILookupParameter<ItemArray<SymbolicExpressionTree>> SymbolicExpressionTreeParameter { get; } 32 33 ILookupParameter<BoolMatrix> WorldParameter { get; } -
trunk/sources/HeuristicLab.Problems.ArtificialAnt/3.3/Analyzers/PopulationBestAntTrailAnalyzer.cs
r3628 r3631 30 30 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 31 31 32 namespace HeuristicLab.Problems.ArtificialAnt {32 namespace HeuristicLab.Problems.ArtificialAnt.Analyzers { 33 33 /// <summary> 34 34 /// An operator for visualizing the best ant trail of an artificial ant problem. 35 35 /// </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.")] 37 37 [StorableClass] 38 public sealed class BestAntTrailVisualizer : SingleSuccessorOperator, IAntTrailVisualizer {38 public sealed class PopulationBestAntTrailAnalyzer : SingleSuccessorOperator, IAntTrailPopulationAnalyzer { 39 39 public ILookupParameter<BoolMatrix> WorldParameter { 40 40 get { return (ILookupParameter<BoolMatrix>)Parameters["World"]; } … … 49 49 get { return (ILookupParameter<IntValue>)Parameters["MaxTimeSteps"]; } 50 50 } 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"]; } 54 56 } 55 57 56 public BestAntTrailVisualizer()58 public PopulationBestAntTrailAnalyzer() 57 59 : base() { 58 60 Parameters.Add(new LookupParameter<BoolMatrix>("World", "The world with food items for the artificial ant.")); 59 61 Parameters.Add(new SubScopesLookupParameter<SymbolicExpressionTree>("SymbolicExpressionTree", "The artificial ant solutions from which the best solution should be visualized.")); 60 62 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.")); 62 64 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.")); 63 66 } 64 67 … … 68 71 BoolMatrix world = WorldParameter.ActualValue; 69 72 IntValue maxTimeSteps = MaxTimeStepsParameter.ActualValue; 73 ResultCollection results = ResultsParameter.ActualValue; 70 74 71 75 int i = qualities.Select((x, index) => new { index, x.Value }).OrderBy(x => -x.Value).First().index; 72 76 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 { 76 83 antTrail.World = world; 77 84 antTrail.SymbolicExpressionTree = expressions[i]; 78 85 antTrail.MaxTimeSteps = maxTimeSteps; 86 results["Best Artificial Ant Solution"].Value = antTrail; 79 87 } 80 88 return base.Apply();
Note: See TracChangeset
for help on using the changeset viewer.