Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/01/12 14:36:47 (12 years ago)
Author:
gkronber
Message:

#1797: adapted return type of ConstrainedValueParameter properties in FLA branch.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Analysis.FitnessLandscape/NeutralSelector.cs

    r7783 r8172  
    1 using System.Collections.Generic;
     1using System;
     2using System.Collections.Generic;
    23using System.Linq;
     4using HeuristicLab.Analysis.FitnessLandscape.DistanceCalculators;
    35using HeuristicLab.Common;
    46using HeuristicLab.Core;
    57using HeuristicLab.Data;
     8using HeuristicLab.Operators;
    69using HeuristicLab.Optimization;
    710using HeuristicLab.Parameters;
    811using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    9 using HeuristicLab.Selection;
    1012using HeuristicLab.PluginInfrastructure;
    11 using HeuristicLab.Operators;
    12 using System;
    13 using HeuristicLab.Analysis.FitnessLandscape.DistanceCalculators;
    1413
    1514namespace HeuristicLab.Analysis.FitnessLandscape {
     
    5049      get { return (ILookupParameter<ItemArray<IItem>>)Parameters["Solution"]; }
    5150    }
    52     public ConstrainedValueParameter<IItemDistanceCalculator> SolutionDistanceCalculatorParameter {
    53       get { return (ConstrainedValueParameter<IItemDistanceCalculator>)Parameters["SolutionDistanceCalculator"]; }
     51    public IConstrainedValueParameter<IItemDistanceCalculator> SolutionDistanceCalculatorParameter {
     52      get { return (IConstrainedValueParameter<IItemDistanceCalculator>)Parameters["SolutionDistanceCalculator"]; }
    5453    }
    5554    public ValueLookupParameter<DoubleValue> EpsilonParameter {
     
    5756    }
    5857    public ILookupParameter<DoubleValue> CurrentFractionOfNeutralNeighborsParameter {
    59       get { return (LookupParameter<DoubleValue>) Parameters["CurrentFractionOfNeutralNeighbors"]; }
    60     } 
     58      get { return (LookupParameter<DoubleValue>)Parameters["CurrentFractionOfNeutralNeighbors"]; }
     59    }
    6160    public LookupParameter<DoubleValue> CurrentNeutralDistanceParameter {
    6261      get { return (LookupParameter<DoubleValue>)Parameters["CurrentNeutralDistance"]; }
     
    7877      set {
    7978        if (CurrentNeutralDistanceParameter.ActualValue == null)
    80           CurrentNeutralDistanceParameter.ActualValue= new DoubleValue(value);
    81         else 
     79          CurrentNeutralDistanceParameter.ActualValue = new DoubleValue(value);
     80        else
    8281          CurrentNeutralDistanceParameter.ActualValue.Value = value;
    8382      }
    84      
     83
    8584    }
    8685    protected double CurrentFractionOfNeutralNeighbors {
     
    165164
    166165      var neighbors = QualityParameter.ActualValue
    167         .Zip(items, (q, i) => new { Quality=q.Value, Item=i })
     166        .Zip(items, (q, i) => new { Quality = q.Value, Item = i })
    168167        .Select((p, i) => new {
    169           Idx=i,
    170           Diff=Squash(Math.Abs(baseQuality-p.Quality), eps),
    171           StartDist=calc.Distance(startingPoint, p.Item),
    172           BaseDist=calc.Distance(baseSolution, p.Item)
    173         })       
     168          Idx = i,
     169          Diff = Squash(Math.Abs(baseQuality - p.Quality), eps),
     170          StartDist = calc.Distance(startingPoint, p.Item),
     171          BaseDist = calc.Distance(baseSolution, p.Item)
     172        })
    174173        .Where(n => n.BaseDist > 0)
    175174        .ToList();
     
    181180        if (mostDistantNeutralNeighbor != null && mostDistantNeutralNeighbor.StartDist > currentNeutralDistance) {
    182181          if (currentNeutralDistance == 0) {
    183             StartingPointParameter.ActualValue = (IItem) baseSolution.Clone();
     182            StartingPointParameter.ActualValue = (IItem)baseSolution.Clone();
    184183            CurrentNeutralDistance = mostDistantNeutralNeighbor.BaseDist;
    185184          } else {
     
    199198          CurrentNeutralDistance = 0;
    200199        }
    201         CurrentFractionOfNeutralNeighbors = 1.0*neighbors.Count(n => n.Diff == 0)/neighbors.Count;
     200        CurrentFractionOfNeutralNeighbors = 1.0 * neighbors.Count(n => n.Diff == 0) / neighbors.Count;
    202201      }
    203202      return base.Apply();
    204     }   
     203    }
    205204
    206205    private void Select(int i) {
Note: See TracChangeset for help on using the changeset viewer.