Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/06/10 12:49:05 (15 years ago)
Author:
svonolfe
Message:
  • Updated OneMax analyzer
  • Updated Knapsack analyzer
  • Fixed bug in OneMax and TF analyzer views

(#999)

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  
    3838  [Item("BestOneMaxSolutionAnalyzer", "An operator for analyzing the best solution for a OneMax problem.")]
    3939  [StorableClass]
    40   class BestOneMaxSolutionAnalyzer : SingleSuccessorOperator, IBestOneMaxSolutionAnalyzer, IAnalyzer {
     40  class BestOneMaxSolutionAnalyzer : SingleSuccessorOperator, IAnalyzer {
    4141
    42     public ILookupParameter<BinaryVector> BinaryVectorParameter {
    43       get { return (ILookupParameter<BinaryVector>)Parameters["BinaryVector"]; }
     42    public ScopeTreeLookupParameter<BinaryVector> BinaryVectorParameter {
     43      get { return (ScopeTreeLookupParameter<BinaryVector>)Parameters["BinaryVector"]; }
    4444    }
    45     ILookupParameter IBestOneMaxSolutionAnalyzer.BinaryVectorParameter {
    46       get { return BinaryVectorParameter; }
     45    public ScopeTreeLookupParameter<DoubleValue> QualityParameter {
     46      get { return (ScopeTreeLookupParameter<DoubleValue>)Parameters["Quality"]; }
    4747    }
    48     public ILookupParameter<DoubleValue> QualityParameter {
    49       get { return (ILookupParameter<DoubleValue>)Parameters["Quality"]; }
     48    public LookupParameter<OneMaxSolution> BestSolutionParameter {
     49      get { return (LookupParameter<OneMaxSolution>)Parameters["BestSolution"]; }
    5050    }
    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"]; }
    5953    }
    6054
    6155    public BestOneMaxSolutionAnalyzer()
    6256      : 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."));
    6458
    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."));
    6660      Parameters.Add(new LookupParameter<OneMaxSolution>("BestSolution", "The best Onemax solution."));
    6761      Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The result collection where the Onemax solution should be stored."));
     
    6963
    7064    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;
    7367      ResultCollection results = ResultsParameter.ActualValue;
     68
     69      int i = qualities.Select((x, index) => new { index, x.Value }).OrderBy(x => x.Value).First().index;
    7470
    7571      OneMaxSolution solution = BestSolutionParameter.ActualValue;
    7672      if (solution == null) {
    77         solution = new OneMaxSolution(binaryVector, QualityParameter.ActualValue);
     73        solution = new OneMaxSolution(binaryVectors[i], QualityParameter.ActualValue[i]);
    7874        BestSolutionParameter.ActualValue = solution;
    7975        results.Add(new Result("Best OneMax Solution", solution));
    8076      }  else {
    81         solution.BinaryVector = binaryVector;
    82         solution.Quality = QualityParameter.ActualValue;
     77        solution.BinaryVector = binaryVectors[i];
     78        solution.Quality = QualityParameter.ActualValue[i];
    8379
    8480        results["Best OneMax Solution"].Value = solution;
Note: See TracChangeset for help on using the changeset viewer.