- Timestamp:
- 05/05/10 13:52:16 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.ArtificialAnt/3.3
- Files:
-
- 1 added
- 1 deleted
- 3 edited
- 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(); -
trunk/sources/HeuristicLab.Problems.ArtificialAnt/3.3/ArtificialAntProblem.cs
r3616 r3631 37 37 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.ArchitectureManipulators; 38 38 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Interfaces; 39 using HeuristicLab.Problems.ArtificialAnt.Analyzers; 39 40 40 41 namespace HeuristicLab.Problems.ArtificialAnt { … … 181 182 get { return BestKnownQualityParameter.Value; } 182 183 } 183 private List<I SymbolicExpressionTreeOperator> operators;184 private List<IOperator> operators; 184 185 public IEnumerable<IOperator> Operators { 185 get { return operators.Cast<IOperator>(); } 186 get { return operators; } 187 } 188 189 public IEnumerable<IAntTrailPopulationAnalyzer> AntTrailAnalyzers { 190 get { return operators.OfType<IAntTrailPopulationAnalyzer>(); } 186 191 } 187 192 #endregion … … 209 214 ParameterizeSolutionCreator(); 210 215 ParameterizeEvaluator(); 211 ParameterizeVisualizer();212 213 216 Initialize(); 214 217 } … … 248 251 ParameterizeSolutionCreator(); 249 252 ParameterizeEvaluator(); 250 Parameterize Visualizer();253 ParameterizeAnalyzers(); 251 254 ParameterizeOperators(); 252 255 OnSolutionCreatorChanged(); … … 254 257 private void SolutionCreator_SymbolicExpressionTreeParameter_ActualNameChanged(object sender, EventArgs e) { 255 258 ParameterizeEvaluator(); 256 Parameterize Visualizer();259 ParameterizeAnalyzers(); 257 260 ParameterizeOperators(); 258 261 } … … 260 263 Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged); 261 264 ParameterizeEvaluator(); 262 Parameterize Visualizer();265 ParameterizeAnalyzers(); 263 266 OnEvaluatorChanged(); 264 267 } 265 268 266 269 private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) { 267 Parameterize Visualizer();270 ParameterizeAnalyzers(); 268 271 } 269 272 … … 293 296 294 297 private void InitializeOperators() { 295 operators = new List<ISymbolicExpressionTreeOperator>(); 296 operators.AddRange(ApplicationManager.Manager.GetInstances<ISymbolicExpressionTreeOperator>()); 298 operators = new List<IOperator>(); 299 operators.AddRange(ApplicationManager.Manager.GetInstances<ISymbolicExpressionTreeOperator>().OfType<IOperator>()); 300 operators.Add(new PopulationBestAntTrailAnalyzer()); 301 ParameterizeAnalyzers(); 297 302 ParameterizeOperators(); 298 303 } … … 308 313 Evaluator.WorldParameter.ActualName = WorldParameter.Name; 309 314 } 310 private void ParameterizeVisualizer() { 311 //if (Visualizer != null) { 312 // Visualizer.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName; 313 // var antTrailVisualizer = Visualizer as IAntTrailVisualizer; 314 // if (antTrailVisualizer != null) { 315 // antTrailVisualizer.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName; 316 // antTrailVisualizer.WorldParameter.ActualName = WorldParameter.Name; 317 // antTrailVisualizer.MaxTimeStepsParameter.ActualName = MaxTimeStepsParameter.Name; 318 // } 319 // var bestSymExpressionVisualizer = Visualizer as BestSymbolicExpressionTreeVisualizer; 320 // if (bestSymExpressionVisualizer != null) { 321 // bestSymExpressionVisualizer.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName; 322 // } 323 //} 315 private void ParameterizeAnalyzers() { 316 foreach (IAntTrailPopulationAnalyzer analyzer in AntTrailAnalyzers) { 317 analyzer.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName; 318 analyzer.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName; 319 analyzer.WorldParameter.ActualName = WorldParameter.Name; 320 analyzer.MaxTimeStepsParameter.ActualName = MaxTimeStepsParameter.Name; 321 } 324 322 } 325 323 -
trunk/sources/HeuristicLab.Problems.ArtificialAnt/3.3/HeuristicLab.Problems.ArtificialAnt-3.3.csproj
r3384 r3631 81 81 </ItemGroup> 82 82 <ItemGroup> 83 <Compile Include="Analyzers\IAntTrailPopulationAnalyzer.cs" /> 84 <Compile Include="Analyzers\PopulationBestAntTrailAnalyzer.cs" /> 83 85 <Compile Include="AntInterpreter.cs" /> 84 <Compile Include="BestAntTrailVisualizer.cs" />85 <Compile Include="BestSymbolicExpressionTreeVisualizer.cs" />86 86 <Compile Include="HeuristicLabProblemsArtificialAntPlugin.cs" /> 87 <Compile Include="IAntTrailVisualizer.cs" />88 87 <Compile Include="Evaluator.cs" /> 89 88 <Compile Include="ArtificialAntExpressionGrammar.cs" /> -
trunk/sources/HeuristicLab.Problems.ArtificialAnt/3.3/HeuristicLabProblemsArtificialAntPlugin.cs.frame
r3239 r3631 29 29 [PluginFile("HeuristicLab.Problems.ArtificialAnt-3.3.dll", PluginFileType.Assembly)] 30 30 [PluginDependency("HeuristicLab.Collections", "3.3.0.0")] 31 [PluginDependency("HeuristicLab.Common", "3.3.0.0")] 31 32 [PluginDependency("HeuristicLab.Common.Resources", "3.2.0.0")] 32 33 [PluginDependency("HeuristicLab.Core", "3.3.0.0")]
Note: See TracChangeset
for help on using the changeset viewer.