Changeset 8172 for branches/FitnessLandscapeAnalysis/HeuristicLab.Analysis.FitnessLandscape/NeutralSelector.cs
- Timestamp:
- 07/01/12 14:36:47 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/FitnessLandscapeAnalysis/HeuristicLab.Analysis.FitnessLandscape/NeutralSelector.cs
r7783 r8172 1 using System.Collections.Generic; 1 using System; 2 using System.Collections.Generic; 2 3 using System.Linq; 4 using HeuristicLab.Analysis.FitnessLandscape.DistanceCalculators; 3 5 using HeuristicLab.Common; 4 6 using HeuristicLab.Core; 5 7 using HeuristicLab.Data; 8 using HeuristicLab.Operators; 6 9 using HeuristicLab.Optimization; 7 10 using HeuristicLab.Parameters; 8 11 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 9 using HeuristicLab.Selection;10 12 using HeuristicLab.PluginInfrastructure; 11 using HeuristicLab.Operators;12 using System;13 using HeuristicLab.Analysis.FitnessLandscape.DistanceCalculators;14 13 15 14 namespace HeuristicLab.Analysis.FitnessLandscape { … … 50 49 get { return (ILookupParameter<ItemArray<IItem>>)Parameters["Solution"]; } 51 50 } 52 public ConstrainedValueParameter<IItemDistanceCalculator> SolutionDistanceCalculatorParameter {53 get { return ( ConstrainedValueParameter<IItemDistanceCalculator>)Parameters["SolutionDistanceCalculator"]; }51 public IConstrainedValueParameter<IItemDistanceCalculator> SolutionDistanceCalculatorParameter { 52 get { return (IConstrainedValueParameter<IItemDistanceCalculator>)Parameters["SolutionDistanceCalculator"]; } 54 53 } 55 54 public ValueLookupParameter<DoubleValue> EpsilonParameter { … … 57 56 } 58 57 public ILookupParameter<DoubleValue> CurrentFractionOfNeutralNeighborsParameter { 59 get { return (LookupParameter<DoubleValue>) 60 } 58 get { return (LookupParameter<DoubleValue>)Parameters["CurrentFractionOfNeutralNeighbors"]; } 59 } 61 60 public LookupParameter<DoubleValue> CurrentNeutralDistanceParameter { 62 61 get { return (LookupParameter<DoubleValue>)Parameters["CurrentNeutralDistance"]; } … … 78 77 set { 79 78 if (CurrentNeutralDistanceParameter.ActualValue == null) 80 CurrentNeutralDistanceParameter.ActualValue = new DoubleValue(value);81 else 79 CurrentNeutralDistanceParameter.ActualValue = new DoubleValue(value); 80 else 82 81 CurrentNeutralDistanceParameter.ActualValue.Value = value; 83 82 } 84 83 85 84 } 86 85 protected double CurrentFractionOfNeutralNeighbors { … … 165 164 166 165 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 }) 168 167 .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 }) 174 173 .Where(n => n.BaseDist > 0) 175 174 .ToList(); … … 181 180 if (mostDistantNeutralNeighbor != null && mostDistantNeutralNeighbor.StartDist > currentNeutralDistance) { 182 181 if (currentNeutralDistance == 0) { 183 StartingPointParameter.ActualValue = (IItem) 182 StartingPointParameter.ActualValue = (IItem)baseSolution.Clone(); 184 183 CurrentNeutralDistance = mostDistantNeutralNeighbor.BaseDist; 185 184 } else { … … 199 198 CurrentNeutralDistance = 0; 200 199 } 201 CurrentFractionOfNeutralNeighbors = 1.0 *neighbors.Count(n => n.Diff == 0)/neighbors.Count;200 CurrentFractionOfNeutralNeighbors = 1.0 * neighbors.Count(n => n.Diff == 0) / neighbors.Count; 202 201 } 203 202 return base.Apply(); 204 } 203 } 205 204 206 205 private void Select(int i) {
Note: See TracChangeset
for help on using the changeset viewer.