- Timestamp:
- 09/25/15 14:39:59 (9 years ago)
- Location:
- branches/gteufl
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/gteufl
- Property svn:ignore
-
old new 8 8 FxCopResults.txt 9 9 Google.ProtocolBuffers-0.9.1.dll 10 Google.ProtocolBuffers-2.4.1.473.dll 10 11 HeuristicLab 3.3.5.1.ReSharper.user 11 12 HeuristicLab 3.3.6.0.ReSharper.user 12 13 HeuristicLab.4.5.resharper.user 13 14 HeuristicLab.ExtLibs.6.0.ReSharper.user 15 HeuristicLab.Scripting.Development 14 16 HeuristicLab.resharper.user 15 17 ProtoGen.exe … … 17 19 _ReSharper.HeuristicLab 18 20 _ReSharper.HeuristicLab 3.3 21 _ReSharper.HeuristicLab 3.3 Tests 19 22 _ReSharper.HeuristicLab.ExtLibs 20 23 bin 21 24 protoc.exe 22 _ReSharper.HeuristicLab 3.3 Tests 23 Google.ProtocolBuffers-2.4.1.473.dll 25 obj
-
- Property svn:mergeinfo changed
-
Property
svn:global-ignores
set to
*.nuget
packages
- Property svn:ignore
-
branches/gteufl/HeuristicLab.Optimization.Operators/3.3/MultiObjective/CrowdedComparisonSorter.cs
r9456 r12969 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 3Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/gteufl/HeuristicLab.Optimization.Operators/3.3/MultiObjective/CrowdingDistanceAssignment.cs
r9456 r12969 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 3Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 33 33 [Item("CrowdingDistanceAssignment", "Calculates the crowding distances for each sub-scope as described in Deb et al. 2002. A Fast and Elitist Multiobjective Genetic Algorithm: NSGA-II. IEEE Transactions on Evolutionary Computation, 6(2), pp. 182-197.")] 34 34 [StorableClass] 35 public class CrowdingDistanceAssignment : SingleSuccessorOperator {35 public class CrowdingDistanceAssignment : SingleSuccessorOperator, IMultiObjectiveOperator { 36 36 37 37 public ScopeTreeLookupParameter<DoubleArray> QualitiesParameter { -
branches/gteufl/HeuristicLab.Optimization.Operators/3.3/MultiObjective/FastNonDominatedSort.cs
r9456 r12969 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 3Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Linq; 24 25 using HeuristicLab.Common; 25 26 using HeuristicLab.Core; … … 37 38 Genetic Algorithm: NSGA-II"", IEEE Transactions On Evolutionary Computation, Vol. 6, No. 2, April 2002")] 38 39 [StorableClass] 39 public class FastNonDominatedSort : SingleSuccessorOperator {40 public class FastNonDominatedSort : SingleSuccessorOperator, IMultiObjectiveOperator { 40 41 private enum DominationResult { Dominates, IsDominated, IsNonDominated }; 41 42 43 #region Parameter properties 42 44 public IValueLookupParameter<BoolArray> MaximizationParameter { 43 45 get { return (IValueLookupParameter<BoolArray>)Parameters["Maximization"]; } 44 46 } 45 47 public IValueLookupParameter<BoolValue> DominateOnEqualQualitiesParameter { 48 get { return (ValueLookupParameter<BoolValue>)Parameters["DominateOnEqualQualities"]; } 49 } 46 50 public IScopeTreeLookupParameter<DoubleArray> QualitiesParameter { 47 51 get { return (IScopeTreeLookupParameter<DoubleArray>)Parameters["Qualities"]; } 48 52 } 49 50 53 public IScopeTreeLookupParameter<IntValue> RankParameter { 51 54 get { return (IScopeTreeLookupParameter<IntValue>)Parameters["Rank"]; } 52 55 } 56 #endregion 53 57 54 58 [StorableConstructor] … … 57 61 public FastNonDominatedSort() { 58 62 Parameters.Add(new ValueLookupParameter<BoolArray>("Maximization", "Whether each objective is maximization or minimization.")); 63 Parameters.Add(new ValueLookupParameter<BoolValue>("DominateOnEqualQualities", "Flag which determines wether solutions with equal quality values should be treated as dominated.")); 59 64 Parameters.Add(new ScopeTreeLookupParameter<DoubleArray>("Qualities", "The qualities of a solution.", 1)); 60 65 Parameters.Add(new ScopeTreeLookupParameter<IntValue>("Rank", "The rank of a solution.", 1)); … … 62 67 63 68 public override IOperation Apply() { 64 BoolArray maximization = MaximizationParameter.ActualValue; 65 ItemArray<DoubleArray> qualities = QualitiesParameter.ActualValue; 69 bool dominateOnEqualQualities = DominateOnEqualQualitiesParameter.ActualValue.Value; 70 bool[] maximization = MaximizationParameter.ActualValue.ToArray(); 71 double[][] qualities = QualitiesParameter.ActualValue.Select(x => x.ToArray()).ToArray(); 66 72 if (qualities == null) throw new InvalidOperationException(Name + ": No qualities found."); 67 73 … … 76 82 for (int pI = 0; pI < populationSize - 1; pI++) { 77 83 IScope p = scope.SubScopes[pI]; 78 if (!dominatedScopes.ContainsKey(p)) 79 dominatedScopes[p] = new List<int>(); 84 List<int> dominatedScopesByp; 85 if (!dominatedScopes.TryGetValue(p, out dominatedScopesByp)) 86 dominatedScopes[p] = dominatedScopesByp = new List<int>(); 80 87 for (int qI = pI + 1; qI < populationSize; qI++) { 81 DominationResult test = Dominates(qualities[pI], qualities[qI], maximization );88 DominationResult test = Dominates(qualities[pI], qualities[qI], maximization, dominateOnEqualQualities); 82 89 if (test == DominationResult.Dominates) { 83 dominatedScopes [p].Add(qI);90 dominatedScopesByp.Add(qI); 84 91 dominationCounter[qI] += 1; 85 92 } else if (test == DominationResult.IsDominated) { … … 105 112 ScopeList nextFront = new ScopeList(); 106 113 foreach (IScope p in fronts[i]) { 107 if (dominatedScopes.ContainsKey(p)) { 108 for (int k = 0; k < dominatedScopes[p].Count; k++) { 109 int dominatedScope = dominatedScopes[p][k]; 114 List<int> dominatedScopesByp; 115 if (dominatedScopes.TryGetValue(p, out dominatedScopesByp)) { 116 for (int k = 0; k < dominatedScopesByp.Count; k++) { 117 int dominatedScope = dominatedScopesByp[k]; 110 118 dominationCounter[dominatedScope] -= 1; 111 119 if (dominationCounter[dominatedScope] == 0) { … … 134 142 } 135 143 136 private DominationResult Dominates(DoubleArray left, DoubleArray right, BoolArray maximizations) { 144 private static DominationResult Dominates(double[] left, double[] right, bool[] maximizations, bool dominateOnEqualQualities) { 145 //mkommend Caution: do not use LINQ.SequenceEqual for comparing the two quality arrays (left and right) due to performance reasons 146 if (dominateOnEqualQualities) { 147 var equal = true; 148 for (int i = 0; i < left.Length; i++) { 149 if (left[i] != right[i]) { 150 equal = false; 151 break; 152 } 153 } 154 if (equal) return DominationResult.Dominates; 155 } 156 137 157 bool leftIsBetter = false, rightIsBetter = false; 138 158 for (int i = 0; i < left.Length; i++) { … … 141 161 if (leftIsBetter && rightIsBetter) break; 142 162 } 163 143 164 if (leftIsBetter && !rightIsBetter) return DominationResult.Dominates; 144 165 if (!leftIsBetter && rightIsBetter) return DominationResult.IsDominated; … … 146 167 } 147 168 148 private bool IsDominated(double left, double right, bool maximization) {169 private static bool IsDominated(double left, double right, bool maximization) { 149 170 return maximization && left < right 150 171 || !maximization && left > right; 151 172 } 152 173 153 private void AddToFront(IScope p, List<ScopeList> fronts, int i) {174 private static void AddToFront(IScope p, List<ScopeList> fronts, int i) { 154 175 if (i == fronts.Count) fronts.Add(new ScopeList()); 155 176 fronts[i].Add(p); … … 159 180 return new FastNonDominatedSort(this, cloner); 160 181 } 182 183 [StorableHook(HookType.AfterDeserialization)] 184 private void AfterDeserialization() { 185 // BackwardsCompatibility3.3 186 #region Backwards compatible code, remove with 3.4 187 if (!Parameters.ContainsKey("DominateOnEqualQualities")) 188 Parameters.Add(new ValueLookupParameter<BoolValue>("DominateOnEqualQualities", "Flag which determines wether solutions with equal quality values should be treated as dominated.")); 189 #endregion 190 } 161 191 } 162 192 } -
branches/gteufl/HeuristicLab.Optimization.Operators/3.3/MultiObjective/RankAndCrowdingSorter.cs
r9456 r12969 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 3Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 29 29 30 30 namespace HeuristicLab.Optimization.Operators { 31 public class RankAndCrowdingSorter : AlgorithmOperator { 31 public class RankAndCrowdingSorter : AlgorithmOperator, IMultiObjectiveOperator { 32 #region Parameter properties 32 33 public ValueLookupParameter<BoolArray> MaximizationParameter { 33 34 get { return (ValueLookupParameter<BoolArray>)Parameters["Maximization"]; } … … 42 43 get { return (ScopeTreeLookupParameter<DoubleValue>)Parameters["CrowdingDistance"]; } 43 44 } 45 public IValueLookupParameter<BoolValue> DominateOnEqualQualitiesParameter { 46 get { return (ValueLookupParameter<BoolValue>)Parameters["DominateOnEqualQualities"]; } 47 } 48 #endregion 44 49 45 50 [StorableConstructor] … … 49 54 : base() { 50 55 Parameters.Add(new ValueLookupParameter<BoolArray>("Maximization", "For each objective a value that is true if that objective should be maximized, or false if it should be minimized.")); 56 Parameters.Add(new ValueLookupParameter<BoolValue>("DominateOnEqualQualities", "Flag which determines wether solutions with equal quality values should be treated as dominated.")); 51 57 Parameters.Add(new ScopeTreeLookupParameter<DoubleArray>("Qualities", "The vector of quality values.")); 52 58 Parameters.Add(new ScopeTreeLookupParameter<IntValue>("Rank", "The rank of a solution (to which front it belongs).")); … … 60 66 61 67 fastNonDominatedSort.MaximizationParameter.ActualName = MaximizationParameter.Name; 68 fastNonDominatedSort.DominateOnEqualQualitiesParameter.ActualName = DominateOnEqualQualitiesParameter.Name; 62 69 fastNonDominatedSort.QualitiesParameter.ActualName = QualitiesParameter.Name; 63 70 fastNonDominatedSort.RankParameter.ActualName = RankParameter.Name; … … 81 88 return new RankAndCrowdingSorter(this, cloner); 82 89 } 90 91 [StorableHook(HookType.AfterDeserialization)] 92 private void AfterDeserialization() { 93 // BackwardsCompatibility3.3 94 #region Backwards compatible code, remove with 3.4 95 if (!Parameters.ContainsKey("DominateOnEqualQualities")) 96 Parameters.Add(new ValueLookupParameter<BoolValue>("DominateOnEqualQualities", "Flag which determines wether solutions with equal quality values should be treated as dominated.")); 97 #endregion 98 } 83 99 } 84 100 }
Note: See TracChangeset
for help on using the changeset viewer.