Changeset 12044
- Timestamp:
- 02/20/15 11:45:04 (10 years ago)
- Location:
- branches/NSGA-II Changes
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/NSGA-II Changes/HeuristicLab.Algorithms.NSGA2/3.3/NSGA2.cs
r12034 r12044 89 89 } 90 90 91 private IFixedValueParameter<BoolValue> TreatSolutionsWithEqualQualityAsDominatedParameter {92 get { return (IFixedValueParameter<BoolValue>)Parameters[" TreatSolutionsWithEqualQualityAsDominated"]; }91 private IFixedValueParameter<BoolValue> DominateOnEqualQualitiesParameter { 92 get { return (IFixedValueParameter<BoolValue>)Parameters["DominateOnEqualQualities"]; } 93 93 } 94 94 #endregion … … 139 139 set { SelectedParentsParameter.Value = value; } 140 140 } 141 public bool TreatSolutionsWithEqualQualityAsDominated{142 get { return TreatSolutionsWithEqualQualityAsDominatedParameter.Value.Value; }143 set { TreatSolutionsWithEqualQualityAsDominatedParameter.Value.Value = value; }141 public bool DominateOnEqualQualities { 142 get { return DominateOnEqualQualitiesParameter.Value.Value; } 143 set { DominateOnEqualQualitiesParameter.Value.Value = value; } 144 144 } 145 145 … … 180 180 Parameters.Add(new ValueParameter<IntValue>("MaximumGenerations", "The maximum number of generations which should be processed.", new IntValue(1000))); 181 181 Parameters.Add(new ValueParameter<IntValue>("SelectedParents", "Each two parents form a new child, typically this value should be twice the population size, but because the NSGA-II is maximally elitist it can be any multiple of 2 greater than 0.", new IntValue(200))); 182 Parameters.Add(new FixedValueParameter<BoolValue>(" TreatSolutionsWithEqualQualityAsDominated", "Flag which determines wether solutions with equal quality values should be treated as dominated.", new BoolValue(false)));182 Parameters.Add(new FixedValueParameter<BoolValue>("DominateOnEqualQualities", "Flag which determines wether solutions with equal quality values should be treated as dominated.", new BoolValue(false))); 183 183 184 184 RandomCreator randomCreator = new RandomCreator(); … … 205 205 subScopesCounter.Successor = rankAndCrowdingSorter; 206 206 207 rankAndCrowdingSorter. TreatSolutionsWithEqualQualityAsDominatedParameter.ActualName = TreatSolutionsWithEqualQualityAsDominatedParameter.Name;207 rankAndCrowdingSorter.DominateOnEqualQualitiesParameter.ActualName = DominateOnEqualQualitiesParameter.Name; 208 208 rankAndCrowdingSorter.CrowdingDistanceParameter.ActualName = "CrowdingDistance"; 209 209 rankAndCrowdingSorter.RankParameter.ActualName = "Rank"; … … 324 324 // BackwardsCompatibility3.3 325 325 #region Backwards compatible code, remove with 3.4 326 if (!Parameters.ContainsKey(" TreatSolutionsWithEqualQualityAsDominated"))327 Parameters.Add(new FixedValueParameter<BoolValue>(" TreatSolutionsWithEqualQualityAsDominated", "Flag which determines wether solutions with equal quality values should be treated as dominated.", new BoolValue(false)));326 if (!Parameters.ContainsKey("DominateOnEqualQualities")) 327 Parameters.Add(new FixedValueParameter<BoolValue>("DominateOnEqualQualities", "Flag which determines wether solutions with equal quality values should be treated as dominated.", new BoolValue(false))); 328 328 #endregion 329 329 -
branches/NSGA-II Changes/HeuristicLab.Algorithms.NSGA2/3.3/NSGA2MainLoop.cs
r12034 r12044 79 79 get { return (LookupParameter<IntValue>)Parameters["EvaluatedSolutions"]; } 80 80 } 81 public IValueLookupParameter<BoolValue> TreatSolutionsWithEqualQualityAsDominatedParameter {82 get { return (ValueLookupParameter<BoolValue>)Parameters[" TreatSolutionsWithEqualQualityAsDominated"]; }81 public IValueLookupParameter<BoolValue> DominateOnEqualQualitiesParameter { 82 get { return (ValueLookupParameter<BoolValue>)Parameters["DominateOnEqualQualities"]; } 83 83 } 84 84 #endregion … … 90 90 // BackwardsCompatibility3.3 91 91 #region Backwards compatible code, remove with 3.4 92 if (!Parameters.ContainsKey(" TreatSolutionsWithEqualQualityAsDominated"))93 Parameters.Add(new ValueLookupParameter<BoolValue>(" TreatSolutionsWithEqualQualityAsDominated", "Flag which determines wether solutions with equal quality values should be treated as dominated."));92 if (!Parameters.ContainsKey("DominateOnEqualQualities")) 93 Parameters.Add(new ValueLookupParameter<BoolValue>("DominateOnEqualQualities", "Flag which determines wether solutions with equal quality values should be treated as dominated.")); 94 94 #endregion 95 95 } … … 117 117 Parameters.Add(new ValueLookupParameter<IOperator>("Analyzer", "The operator used to analyze each generation.")); 118 118 Parameters.Add(new LookupParameter<IntValue>("EvaluatedSolutions", "The number of times solutions have been evaluated.")); 119 Parameters.Add(new ValueLookupParameter<BoolValue>(" TreatSolutionsWithEqualQualityAsDominated", "Flag which determines wether solutions with equal quality values should be treated as dominated."));119 Parameters.Add(new ValueLookupParameter<BoolValue>("DominateOnEqualQualities", "Flag which determines wether solutions with equal quality values should be treated as dominated.")); 120 120 #endregion 121 121 … … 184 184 subScopesCounter.ValueParameter.ActualName = EvaluatedSolutionsParameter.Name; 185 185 186 rankAndCrowdingSorter. TreatSolutionsWithEqualQualityAsDominatedParameter.ActualName = TreatSolutionsWithEqualQualityAsDominatedParameter.Name;186 rankAndCrowdingSorter.DominateOnEqualQualitiesParameter.ActualName = DominateOnEqualQualitiesParameter.Name; 187 187 rankAndCrowdingSorter.CrowdingDistanceParameter.ActualName = "CrowdingDistance"; 188 188 rankAndCrowdingSorter.RankParameter.ActualName = "Rank"; -
branches/NSGA-II Changes/HeuristicLab.Optimization.Operators/3.3/MultiObjective/FastNonDominatedSort.cs
r12034 r12044 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Drawing;25 24 using System.Linq; 26 25 using HeuristicLab.Common; … … 46 45 get { return (IValueLookupParameter<BoolArray>)Parameters["Maximization"]; } 47 46 } 48 public IValueLookupParameter<BoolValue> TreatSolutionsWithEqualQualityAsDominatedParameter {49 get { return (ValueLookupParameter<BoolValue>)Parameters[" TreatSolutionsWithEqualQualityAsDominated"]; }47 public IValueLookupParameter<BoolValue> DominateOnEqualQualitiesParameter { 48 get { return (ValueLookupParameter<BoolValue>)Parameters["DominateOnEqualQualities "]; } 50 49 } 51 50 public IScopeTreeLookupParameter<DoubleArray> QualitiesParameter { … … 62 61 public FastNonDominatedSort() { 63 62 Parameters.Add(new ValueLookupParameter<BoolArray>("Maximization", "Whether each objective is maximization or minimization.")); 64 Parameters.Add(new ValueLookupParameter<BoolValue>(" TreatSolutionsWithEqualQualityAsDominated", "Flag which determines wether solutions with equal quality values should be treated as dominated."));63 Parameters.Add(new ValueLookupParameter<BoolValue>("DominateOnEqualQualities ", "Flag which determines wether solutions with equal quality values should be treated as dominated.")); 65 64 Parameters.Add(new ScopeTreeLookupParameter<DoubleArray>("Qualities", "The qualities of a solution.", 1)); 66 65 Parameters.Add(new ScopeTreeLookupParameter<IntValue>("Rank", "The rank of a solution.", 1)); … … 68 67 69 68 public override IOperation Apply() { 70 bool treatSolutionsWithEqualQualityAsDominated = TreatSolutionsWithEqualQualityAsDominatedParameter.ActualValue.Value;69 bool dominateOnEqualQualities = DominateOnEqualQualitiesParameter.ActualValue.Value; 71 70 BoolArray maximization = MaximizationParameter.ActualValue; 72 71 ItemArray<DoubleArray> qualities = QualitiesParameter.ActualValue; … … 86 85 dominatedScopes[p] = new List<int>(); 87 86 for (int qI = pI + 1; qI < populationSize; qI++) { 88 DominationResult test = Dominates(qualities[pI], qualities[qI], maximization, treatSolutionsWithEqualQualityAsDominated);87 DominationResult test = Dominates(qualities[pI], qualities[qI], maximization, dominateOnEqualQualities); 89 88 if (test == DominationResult.Dominates) { 90 89 dominatedScopes[p].Add(qI); … … 141 140 } 142 141 143 private static DominationResult Dominates(DoubleArray left, DoubleArray right, BoolArray maximizations, bool treatSolutionsWithEqualQualityAsDominated) {144 if ( treatSolutionsWithEqualQualityAsDominated&& left.SequenceEqual(right)) return DominationResult.Dominates;142 private static DominationResult Dominates(DoubleArray left, DoubleArray right, BoolArray maximizations, bool dominateOnEqualQualities) { 143 if (dominateOnEqualQualities && left.SequenceEqual(right)) return DominationResult.Dominates; 145 144 146 145 bool leftIsBetter = false, rightIsBetter = false; … … 174 173 // BackwardsCompatibility3.3 175 174 #region Backwards compatible code, remove with 3.4 176 if (!Parameters.ContainsKey(" TreatSolutionsWithEqualQualityAsDominated"))177 Parameters.Add(new ValueLookupParameter<BoolValue>(" TreatSolutionsWithEqualQualityAsDominated", "Flag which determines wether solutions with equal quality values should be treated as dominated."));175 if (!Parameters.ContainsKey("DominateOnEqualQualities ")) 176 Parameters.Add(new ValueLookupParameter<BoolValue>("DominateOnEqualQualities ", "Flag which determines wether solutions with equal quality values should be treated as dominated.")); 178 177 #endregion 179 178 } -
branches/NSGA-II Changes/HeuristicLab.Optimization.Operators/3.3/MultiObjective/RankAndCrowdingSorter.cs
r12034 r12044 43 43 get { return (ScopeTreeLookupParameter<DoubleValue>)Parameters["CrowdingDistance"]; } 44 44 } 45 public IValueLookupParameter<BoolValue> TreatSolutionsWithEqualQualityAsDominatedParameter {46 get { return (ValueLookupParameter<BoolValue>)Parameters[" TreatSolutionsWithEqualQualityAsDominated"]; }45 public IValueLookupParameter<BoolValue> DominateOnEqualQualitiesParameter { 46 get { return (ValueLookupParameter<BoolValue>)Parameters["DominateOnEqualQualities "]; } 47 47 } 48 48 #endregion … … 54 54 : base() { 55 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>(" TreatSolutionsWithEqualQualityAsDominated", "Flag which determines wether solutions with equal quality values should be treated as dominated."));56 Parameters.Add(new ValueLookupParameter<BoolValue>("DominateOnEqualQualities ", "Flag which determines wether solutions with equal quality values should be treated as dominated.")); 57 57 Parameters.Add(new ScopeTreeLookupParameter<DoubleArray>("Qualities", "The vector of quality values.")); 58 58 Parameters.Add(new ScopeTreeLookupParameter<IntValue>("Rank", "The rank of a solution (to which front it belongs).")); … … 66 66 67 67 fastNonDominatedSort.MaximizationParameter.ActualName = MaximizationParameter.Name; 68 fastNonDominatedSort. TreatSolutionsWithEqualQualityAsDominatedParameter.ActualName = TreatSolutionsWithEqualQualityAsDominatedParameter.Name;68 fastNonDominatedSort.DominateOnEqualQualitiesParameter.ActualName = DominateOnEqualQualitiesParameter.Name; 69 69 fastNonDominatedSort.QualitiesParameter.ActualName = QualitiesParameter.Name; 70 70 fastNonDominatedSort.RankParameter.ActualName = RankParameter.Name; … … 93 93 // BackwardsCompatibility3.3 94 94 #region Backwards compatible code, remove with 3.4 95 if (!Parameters.ContainsKey(" TreatSolutionsWithEqualQualityAsDominated"))96 Parameters.Add(new ValueLookupParameter<BoolValue>(" TreatSolutionsWithEqualQualityAsDominated", "Flag which determines wether solutions with equal quality values should be treated as dominated."));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 97 #endregion 98 98 }
Note: See TracChangeset
for help on using the changeset viewer.