Changeset 3667 for trunk/sources/HeuristicLab.Problems.OneMax/3.3/Analyzers
- Timestamp:
- 05/06/10 12:49:05 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.OneMax/3.3/Analyzers
- Files:
-
- 2 deleted
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.OneMax/3.3/Analyzers/BestOneMaxSolutionAnalyzer.cs
r3658 r3667 38 38 [Item("BestOneMaxSolutionAnalyzer", "An operator for analyzing the best solution for a OneMax problem.")] 39 39 [StorableClass] 40 class BestOneMaxSolutionAnalyzer : SingleSuccessorOperator, I BestOneMaxSolutionAnalyzer, IAnalyzer {40 class BestOneMaxSolutionAnalyzer : SingleSuccessorOperator, IAnalyzer { 41 41 42 public ILookupParameter<BinaryVector> BinaryVectorParameter {43 get { return ( ILookupParameter<BinaryVector>)Parameters["BinaryVector"]; }42 public ScopeTreeLookupParameter<BinaryVector> BinaryVectorParameter { 43 get { return (ScopeTreeLookupParameter<BinaryVector>)Parameters["BinaryVector"]; } 44 44 } 45 ILookupParameter IBestOneMaxSolutionAnalyzer.BinaryVectorParameter {46 get { return BinaryVectorParameter; }45 public ScopeTreeLookupParameter<DoubleValue> QualityParameter { 46 get { return (ScopeTreeLookupParameter<DoubleValue>)Parameters["Quality"]; } 47 47 } 48 public ILookupParameter<DoubleValue> QualityParameter {49 get { return ( ILookupParameter<DoubleValue>)Parameters["Quality"]; }48 public LookupParameter<OneMaxSolution> BestSolutionParameter { 49 get { return (LookupParameter<OneMaxSolution>)Parameters["BestSolution"]; } 50 50 } 51 ILookupParameter IBestOneMaxSolutionAnalyzer.QualityParameter { 52 get { return QualityParameter; } 53 } 54 public ILookupParameter<OneMaxSolution> BestSolutionParameter { 55 get { return (ILookupParameter<OneMaxSolution>)Parameters["BestSolution"]; } 56 } 57 public IValueLookupParameter<ResultCollection> ResultsParameter { 58 get { return (IValueLookupParameter<ResultCollection>)Parameters["Results"]; } 51 public ValueLookupParameter<ResultCollection> ResultsParameter { 52 get { return (ValueLookupParameter<ResultCollection>)Parameters["Results"]; } 59 53 } 60 54 61 55 public BestOneMaxSolutionAnalyzer() 62 56 : base() { 63 Parameters.Add(new LookupParameter<BinaryVector>("BinaryVector", "The Onemax solutions from which the best solution should be visualized."));57 Parameters.Add(new ScopeTreeLookupParameter<BinaryVector>("BinaryVector", "The Onemax solutions from which the best solution should be visualized.")); 64 58 65 Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The qualities of the Onemax solutions which should be visualized."));59 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The qualities of the Onemax solutions which should be visualized.")); 66 60 Parameters.Add(new LookupParameter<OneMaxSolution>("BestSolution", "The best Onemax solution.")); 67 61 Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The result collection where the Onemax solution should be stored.")); … … 69 63 70 64 public override IOperation Apply() { 71 BinaryVector binaryVector= BinaryVectorParameter.ActualValue;72 DoubleValue quality= QualityParameter.ActualValue;65 ItemArray<BinaryVector> binaryVectors = BinaryVectorParameter.ActualValue; 66 ItemArray<DoubleValue> qualities = QualityParameter.ActualValue; 73 67 ResultCollection results = ResultsParameter.ActualValue; 68 69 int i = qualities.Select((x, index) => new { index, x.Value }).OrderBy(x => x.Value).First().index; 74 70 75 71 OneMaxSolution solution = BestSolutionParameter.ActualValue; 76 72 if (solution == null) { 77 solution = new OneMaxSolution(binaryVector , QualityParameter.ActualValue);73 solution = new OneMaxSolution(binaryVectors[i], QualityParameter.ActualValue[i]); 78 74 BestSolutionParameter.ActualValue = solution; 79 75 results.Add(new Result("Best OneMax Solution", solution)); 80 76 } else { 81 solution.BinaryVector = binaryVector ;82 solution.Quality = QualityParameter.ActualValue ;77 solution.BinaryVector = binaryVectors[i]; 78 solution.Quality = QualityParameter.ActualValue[i]; 83 79 84 80 results["Best OneMax Solution"].Value = solution;
Note: See TracChangeset
for help on using the changeset viewer.