Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/15/16 14:14:50 (8 years ago)
Author:
mkommend
Message:

#1087: Further refactoring of testfunction problem and analyzers.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Analyzers/CrowdingAnalyzer.cs

    r14044 r14085  
    2525using HeuristicLab.Data;
    2626using HeuristicLab.Optimization;
     27using HeuristicLab.Parameters;
    2728using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2829
     
    3132  [Item("CrowdingAnalyzer", "The mean crowding distance for each point of the Front (see Multi-Objective Performance Metrics - Shodhganga for more information)")]
    3233  public class CrowdingAnalyzer : MOTFAnalyzer {
     34
     35    public ILookupParameter<DoubleMatrix> BoundsParameter {
     36      get { return (ILookupParameter<DoubleMatrix>)Parameters["Bounds"]; }
     37    }
    3338
    3439    [StorableConstructor]
     
    4146    }
    4247
    43     public CrowdingAnalyzer() { }
     48    public CrowdingAnalyzer() {
     49      Parameters.Add(new LookupParameter<DoubleMatrix>("Bounds",
     50        "The bounds of the solution given as either one line for all variables or a line for each variable. The first column specifies lower bound, the second upper bound."));
     51    }
    4452
    4553    public override IOperation Apply() {
    4654      var results = ResultsParameter.ActualValue;
    4755      var qualities = QualitiesParameter.ActualValue;
    48       var testFunction = TestFunctionParameter.ActualValue;
    49       int objectives = qualities[0].Length;
     56      var bounds = BoundsParameter.ActualValue;
    5057
    5158      if (!results.ContainsKey("Crowding")) results.Add(new Result("Crowding", new DoubleValue()));
    5259      var resultValue = (DoubleValue)results["Crowding"].Value;
    5360
    54       var crowdingDistance = Crowding.Calculate(qualities.Select(x => x.ToArray()), testFunction.Bounds(objectives));
     61      var crowdingDistance = Crowding.Calculate(qualities.Select(x => x.ToArray()), bounds.CloneAsMatrix());
    5562      resultValue.Value = crowdingDistance;
    5663
Note: See TracChangeset for help on using the changeset viewer.