Changeset 10643
- Timestamp:
- 03/21/14 14:20:03 (11 years ago)
- Location:
- trunk/sources
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/IslandOffspringSelectionGeneticAlgorithm.cs
r9592 r10643 133 133 get { return (ValueParameter<IntValue>)Parameters["MaximumEvaluatedSolutions"]; } 134 134 } 135 private IFixedValueParameter<BoolValue> FillPopulationWithParentsParameter { 136 get { return (IFixedValueParameter<BoolValue>)Parameters["FillPopulationWithParents"]; } 137 } 135 138 #endregion 136 139 … … 200 203 set { ReevaluateElitesParameter.Value.Value = value; } 201 204 } 202 p rivateDoubleValue SuccessRatio {205 public DoubleValue SuccessRatio { 203 206 get { return SuccessRatioParameter.Value; } 204 207 set { SuccessRatioParameter.Value = value; } 205 208 } 206 p rivateDoubleValue ComparisonFactorLowerBound {209 public DoubleValue ComparisonFactorLowerBound { 207 210 get { return ComparisonFactorLowerBoundParameter.Value; } 208 211 set { ComparisonFactorLowerBoundParameter.Value = value; } 209 212 } 210 p rivateDoubleValue ComparisonFactorUpperBound {213 public DoubleValue ComparisonFactorUpperBound { 211 214 get { return ComparisonFactorUpperBoundParameter.Value; } 212 215 set { ComparisonFactorUpperBoundParameter.Value = value; } … … 216 219 set { ComparisonFactorModifierParameter.Value = value; } 217 220 } 218 p rivateDoubleValue MaximumSelectionPressure {221 public DoubleValue MaximumSelectionPressure { 219 222 get { return MaximumSelectionPressureParameter.Value; } 220 223 set { MaximumSelectionPressureParameter.Value = value; } 221 224 } 222 p rivateBoolValue OffspringSelectionBeforeMutation {225 public BoolValue OffspringSelectionBeforeMutation { 223 226 get { return OffspringSelectionBeforeMutationParameter.Value; } 224 227 set { OffspringSelectionBeforeMutationParameter.Value = value; } … … 235 238 get { return MaximumEvaluatedSolutionsParameter.Value; } 236 239 set { MaximumEvaluatedSolutionsParameter.Value = value; } 240 } 241 public bool FillPopulationWithParents { 242 get { return FillPopulationWithParentsParameter.Value.Value; } 243 set { FillPopulationWithParentsParameter.Value.Value = value; } 237 244 } 238 245 private RandomCreator RandomCreator { … … 271 278 Parameters.Add(new FixedValueParameter<BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)", (BoolValue)new BoolValue(false).AsReadOnly()) { Hidden = true }); 272 279 } 280 if (!Parameters.ContainsKey("FillPopulationWithParents")) 281 Parameters.Add(new FixedValueParameter<BoolValue>("FillPopulationWithParents", "True if the population should be filled with parent individual or false if worse children should be used when the maximum selection pressure is exceeded.", new BoolValue(false)) { Hidden = true }); 273 282 #endregion 274 283 … … 315 324 Parameters.Add(new ValueParameter<MultiAnalyzer>("IslandAnalyzer", "The operator used to analyze each island.", new MultiAnalyzer())); 316 325 Parameters.Add(new ValueParameter<IntValue>("MaximumEvaluatedSolutions", "The maximum number of evaluated solutions (approximately).", new IntValue(int.MaxValue))); 326 Parameters.Add(new FixedValueParameter<BoolValue>("FillPopulationWithParents", "True if the population should be filled with parent individual or false if worse children should be used when the maximum selection pressure is exceeded.", new BoolValue(true)) { Hidden = true }); 317 327 318 328 RandomCreator randomCreator = new RandomCreator(); … … 379 389 mainLoop.OffspringSelectionBeforeMutationParameter.ActualName = OffspringSelectionBeforeMutationParameter.Name; 380 390 mainLoop.EvaluatedSolutionsParameter.ActualName = "EvaluatedSolutions"; 391 mainLoop.FillPopulationWithParentsParameter.ActualName = FillPopulationWithParentsParameter.Name; 381 392 mainLoop.Successor = null; 382 393 -
trunk/sources/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/IslandOffspringSelectionGeneticAlgorithmMainLoop.cs
r10639 r10643 20 20 #endregion 21 21 22 using System.Linq;23 22 using HeuristicLab.Common; 24 23 using HeuristicLab.Core; … … 29 28 using HeuristicLab.Parameters; 30 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 31 using HeuristicLab.Selection;32 30 33 31 namespace HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm { … … 131 129 public LookupParameter<IntValue> EvaluatedSolutionsParameter { 132 130 get { return (LookupParameter<IntValue>)Parameters["EvaluatedSolutions"]; } 131 } 132 public IValueLookupParameter<BoolValue> FillPopulationWithParentsParameter { 133 get { return (IValueLookupParameter<BoolValue>)Parameters["FillPopulationWithParents"]; } 133 134 } 134 135 #endregion … … 176 177 Parameters.Add(new ValueLookupParameter<IOperator>("IslandAnalyzer", "The operator used to analyze each island.")); 177 178 Parameters.Add(new LookupParameter<IntValue>("EvaluatedSolutions", "The number of times solutions have been evaluated.")); 179 Parameters.Add(new ValueLookupParameter<BoolValue>("FillPopulationWithParents", "True if the population should be filled with parent individual or false if worse children should be used when the maximum selection pressure is exceeded.")); 178 180 #endregion 179 181 … … 267 269 mainOperator.SelectorParameter.ActualName = SelectorParameter.Name; 268 270 mainOperator.SuccessRatioParameter.ActualName = SuccessRatioParameter.Name; 269 foreach (var offspringSelector in mainOperator.OperatorGraph.Operators.OfType<OffspringSelector>()) 270 offspringSelector.FillPopulationWithParents = true; 271 mainOperator.FillPopulationWithParentsParameter.ActualName = FillPopulationWithParentsParameter.Name; 271 272 272 273 islandAnalyzer2.Name = "Island Analyzer (placeholder)"; … … 430 431 Parameters.Add(new ValueLookupParameter<BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)")); 431 432 } 433 if (!Parameters.ContainsKey("FillPopulationWithParents")) 434 Parameters.Add(new ValueLookupParameter<BoolValue>("FillPopulationWithParents", "True if the population should be filled with parent individual or false if worse children should be used when the maximum selection pressure is exceeded.")); 432 435 #endregion 433 436 } -
trunk/sources/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/OffspringSelectionGeneticAlgorithm.cs
r9592 r10643 112 112 get { return (ValueParameter<IntValue>)Parameters["MaximumEvaluatedSolutions"]; } 113 113 } 114 private IFixedValueParameter<BoolValue> FillPopulationWithParentsParameter { 115 get { return (IFixedValueParameter<BoolValue>)Parameters["FillPopulationWithParents"]; } 116 } 114 117 #endregion 115 118 … … 190 193 get { return MaximumEvaluatedSolutionsParameter.Value; } 191 194 set { MaximumEvaluatedSolutionsParameter.Value = value; } 195 } 196 public bool FillPopulationWithParents { 197 get { return FillPopulationWithParentsParameter.Value.Value; } 198 set { FillPopulationWithParentsParameter.Value.Value = value; } 192 199 } 193 200 private RandomCreator RandomCreator { … … 219 226 Parameters.Add(new FixedValueParameter<BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)", (BoolValue)new BoolValue(false).AsReadOnly()) { Hidden = true }); 220 227 } 228 if (!Parameters.ContainsKey("FillPopulationWithParents")) 229 Parameters.Add(new FixedValueParameter<BoolValue>("FillPopulationWithParents", "True if the population should be filled with parent individual or false if worse children should be used when the maximum selection pressure is exceeded.", new BoolValue(false)) { Hidden = true }); 221 230 #endregion 222 231 … … 254 263 Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze each generation.", new MultiAnalyzer())); 255 264 Parameters.Add(new ValueParameter<IntValue>("MaximumEvaluatedSolutions", "The maximum number of evaluated solutions (approximately).", new IntValue(int.MaxValue))); 265 Parameters.Add(new FixedValueParameter<BoolValue>("FillPopulationWithParents", "True if the population should be filled with parent individual or false if worse children should be used when the maximum selection pressure is exceeded.", new BoolValue(false)) { Hidden = true }); 256 266 257 267 RandomCreator randomCreator = new RandomCreator(); … … 297 307 mainLoop.SelectorParameter.ActualName = SelectorParameter.Name; 298 308 mainLoop.SuccessRatioParameter.ActualName = SuccessRatioParameter.Name; 309 mainLoop.FillPopulationWithParentsParameter.ActualName = FillPopulationWithParentsParameter.Name; 299 310 300 311 foreach (ISelector selector in ApplicationManager.Manager.GetInstances<ISelector>().Where(x => !(x is IMultiObjectiveSelector)).OrderBy(x => x.Name)) -
trunk/sources/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/OffspringSelectionGeneticAlgorithmMainLoop.cs
r9592 r10643 96 96 get { return (LookupParameter<IntValue>)Parameters["EvaluatedSolutions"]; } 97 97 } 98 public IValueLookupParameter<BoolValue> FillPopulationWithParentsParameter { 99 get { return (IValueLookupParameter<BoolValue>)Parameters["FillPopulationWithParents"]; } 100 } 98 101 #endregion 99 102 … … 118 121 Parameters.Add(new ValueLookupParameter<BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)")); 119 122 } 123 if (!Parameters.ContainsKey("FillPopulationWithParents")) 124 Parameters.Add(new ValueLookupParameter<BoolValue>("FillPopulationWithParents", "True if the population should be filled with parent individual or false if worse children should be used when the maximum selection pressure is exceeded.")); 120 125 #endregion 121 126 } … … 144 149 Parameters.Add(new ValueLookupParameter<BoolValue>("OffspringSelectionBeforeMutation", "True if the offspring selection step should be applied before mutation, false if it should be applied after mutation.")); 145 150 Parameters.Add(new LookupParameter<IntValue>("EvaluatedSolutions", "The number of times solutions have been evaluated.")); 151 Parameters.Add(new ValueLookupParameter<BoolValue>("FillPopulationWithParents", "True if the population should be filled with parent individual or false if worse children should be used when the maximum selection pressure is exceeded.")); 146 152 #endregion 147 153 … … 197 203 mainOperator.SelectorParameter.ActualName = SelectorParameter.Name; 198 204 mainOperator.SuccessRatioParameter.ActualName = SuccessRatioParameter.Name; 205 mainOperator.FillPopulationWithParentsParameter.ActualName = FillPopulationWithParentsParameter.Name; 199 206 200 207 generationsCounter.Increment = new IntValue(1); -
trunk/sources/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/OffspringSelectionGeneticAlgorithmMainOperator.cs
r9592 r10643 88 88 get { return (ValueLookupParameter<BoolValue>)Parameters["OffspringSelectionBeforeMutation"]; } 89 89 } 90 public IValueLookupParameter<BoolValue> FillPopulationWithParentsParameter { 91 get { return (IValueLookupParameter<BoolValue>)Parameters["FillPopulationWithParents"]; } 92 } 90 93 #endregion 91 94 … … 110 113 Parameters.Add(new ValueLookupParameter<BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)")); 111 114 } 115 if (!Parameters.ContainsKey("FillPopulationWithParents")) 116 Parameters.Add(new ValueLookupParameter<BoolValue>("FillPopulationWithParents", "True if the population should be filled with parent individual or false if worse children should be used when the maximum selection pressure is exceeded.")); 112 117 #endregion 113 118 } … … 132 137 Parameters.Add(new ValueLookupParameter<DoubleValue>("MaximumSelectionPressure", "The maximum selection pressure that terminates the algorithm.")); 133 138 Parameters.Add(new ValueLookupParameter<BoolValue>("OffspringSelectionBeforeMutation", "True if the offspring selection step should be applied before mutation, false if it should be applied after mutation.")); 139 Parameters.Add(new ValueLookupParameter<BoolValue>("FillPopulationWithParents", "True if the population should be filled with parent individual or false if worse children should be used when the maximum selection pressure is exceeded.")); 134 140 #endregion 135 141 … … 261 267 offspringSelector.OffspringPopulationWinnersParameter.ActualName = "OffspringPopulationWinners"; 262 268 offspringSelector.SuccessfulOffspringParameter.ActualName = "SuccessfulOffspring"; 269 offspringSelector.FillPopulationWithParentsParameter.ActualName = FillPopulationWithParentsParameter.Name; 263 270 264 271 bestSelector.CopySelected = new BoolValue(false); -
trunk/sources/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/SASEGASA.cs
r9592 r10643 121 121 get { return (ValueParameter<IntValue>)Parameters["MaximumEvaluatedSolutions"]; } 122 122 } 123 private IFixedValueParameter<BoolValue> FillPopulationWithParentsParameter { 124 get { return (IFixedValueParameter<BoolValue>)Parameters["FillPopulationWithParents"]; } 125 } 123 126 #endregion 124 127 … … 211 214 get { return MaximumEvaluatedSolutionsParameter.Value; } 212 215 set { MaximumEvaluatedSolutionsParameter.Value = value; } 216 } 217 public bool FillPopulationWithParents { 218 get { return FillPopulationWithParentsParameter.Value.Value; } 219 set { FillPopulationWithParentsParameter.Value.Value = value; } 213 220 } 214 221 private RandomCreator RandomCreator { … … 247 254 Parameters.Add(new FixedValueParameter<BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)", (BoolValue)new BoolValue(false).AsReadOnly()) { Hidden = true }); 248 255 } 256 if (!Parameters.ContainsKey("FillPopulationWithParents")) 257 Parameters.Add(new FixedValueParameter<BoolValue>("FillPopulationWithParents", "True if the population should be filled with parent individual or false if worse children should be used when the maximum selection pressure is exceeded.", new BoolValue(false)) { Hidden = true }); 249 258 #endregion 250 259 … … 287 296 Parameters.Add(new ValueParameter<MultiAnalyzer>("VillageAnalyzer", "The operator used to analyze each village.", new MultiAnalyzer())); 288 297 Parameters.Add(new ValueParameter<IntValue>("MaximumEvaluatedSolutions", "The maximum number of evaluated solutions (approximately).", new IntValue(int.MaxValue))); 298 Parameters.Add(new FixedValueParameter<BoolValue>("FillPopulationWithParents", "True if the population should be filled with parent individual or false if worse children should be used when the maximum selection pressure is exceeded.", new BoolValue(true)) { Hidden = true }); 289 299 290 300 RandomCreator randomCreator = new RandomCreator(); … … 346 356 mainLoop.OffspringSelectionBeforeMutationParameter.ActualName = OffspringSelectionBeforeMutationParameter.Name; 347 357 mainLoop.EvaluatedSolutionsParameter.ActualName = "EvaluatedSolutions"; 358 mainLoop.FillPopulationWithParentsParameter.ActualName = FillPopulationWithParentsParameter.Name; 348 359 mainLoop.Successor = null; 349 360 -
trunk/sources/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/SASEGASAMainLoop.cs
r9592 r10643 111 111 public LookupParameter<IntValue> EvaluatedSolutionsParameter { 112 112 get { return (LookupParameter<IntValue>)Parameters["EvaluatedSolutions"]; } 113 } 114 public IValueLookupParameter<BoolValue> FillPopulationWithParentsParameter { 115 get { return (IValueLookupParameter<BoolValue>)Parameters["FillPopulationWithParents"]; } 113 116 } 114 117 #endregion … … 150 153 Parameters.Add(new ValueLookupParameter<BoolValue>("OffspringSelectionBeforeMutation", "True if the offspring selection step should be applied before mutation, false if it should be applied after mutation.")); 151 154 Parameters.Add(new LookupParameter<IntValue>("EvaluatedSolutions", "The number of times solutions have been evaluated.")); 155 Parameters.Add(new ValueLookupParameter<BoolValue>("FillPopulationWithParents", "True if the population should be filled with parent individual or false if worse children should be used when the maximum selection pressure is exceeded.")); 152 156 #endregion 153 157 … … 253 257 mainOperator.SelectorParameter.ActualName = SelectorParameter.Name; 254 258 mainOperator.SuccessRatioParameter.ActualName = SuccessRatioParameter.Name; 259 mainOperator.FillPopulationWithParentsParameter.ActualName = FillPopulationWithParentsParameter.Name; 255 260 256 261 villageAnalyzer2.Name = "Village Analyzer (placeholder)"; … … 436 441 Parameters.Add(new ValueLookupParameter<BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)")); 437 442 } 443 if (!Parameters.ContainsKey("FillPopulationWithParents")) 444 Parameters.Add(new ValueLookupParameter<BoolValue>("FillPopulationWithParents", "True if the population should be filled with parent individual or false if worse children should be used when the maximum selection pressure is exceeded.")); 438 445 #endregion 439 446 } -
trunk/sources/HeuristicLab.Selection/3.3/OffspringSelector.cs
r10639 r10643 57 57 } 58 58 59 public FixedValueParameter<BoolValue> FillPopulationWithParentsParameter {60 get { return ( FixedValueParameter<BoolValue>)Parameters["FillPopulationWithParents"]; }59 public IValueLookupParameter<BoolValue> FillPopulationWithParentsParameter { 60 get { return (IValueLookupParameter<BoolValue>)Parameters["FillPopulationWithParents"]; } 61 61 } 62 62 … … 64 64 get { return OffspringCreatorParameter.Value; } 65 65 set { OffspringCreatorParameter.Value = value; } 66 }67 68 public bool FillPopulationWithParents {69 get { return FillPopulationWithParentsParameter.Value.Value; }70 set { FillPopulationWithParentsParameter.Value.Value = value; }71 66 } 72 67 … … 77 72 // BackwardsCompatibility3.3 78 73 #region Backwards compatible code, remove with 3.4 74 if (Parameters.ContainsKey("FillPopulationWithParents") && Parameters["FillPopulationWithParents"] is FixedValueParameter<BoolValue>) 75 Parameters.Remove("FillPopulationWithParents"); 79 76 if (!Parameters.ContainsKey("FillPopulationWithParents")) 80 Parameters.Add(new FixedValueParameter<BoolValue>("FillPopulationWithParents", "True if the population should be filled with parent individuals instead of lucky losers.", new BoolValue(false)));77 Parameters.Add(new ValueLookupParameter<BoolValue>("FillPopulationWithParents", "True if the population should be filled with parent individuals instead of lucky losers.")); 81 78 #endregion 82 79 } … … 96 93 Parameters.Add(new ScopeTreeLookupParameter<BoolValue>("SuccessfulOffspring", "True if the offspring was more successful than its parents.", 2)); 97 94 Parameters.Add(new OperatorParameter("OffspringCreator", "The operator used to create new offspring.")); 98 Parameters.Add(new FixedValueParameter<BoolValue>("FillPopulationWithParents", "True if the population should be filled with parent individuals instead of lucky losers.", new BoolValue(false)));95 Parameters.Add(new ValueLookupParameter<BoolValue>("FillPopulationWithParents", "True if the population should be filled with parent individual or false if worse children should be used when the maximum selection pressure is exceeded.")); 99 96 } 100 97 … … 102 99 double maxSelPress = MaximumSelectionPressureParameter.ActualValue.Value; 103 100 double successRatio = SuccessRatioParameter.ActualValue.Value; 101 bool fillPopulationWithParents = FillPopulationWithParentsParameter.ActualValue.Value; 104 102 IScope scope = ExecutionContext.Scope; 105 103 IScope parents = scope.SubScopes[0]; … … 153 151 } else if (worseOffspringNeeded > 0 || tmpSelPress >= maxSelPress) { 154 152 IScope currentOffspring; 155 if (! FillPopulationWithParents || worseOffspringNeeded > 0) {153 if (!fillPopulationWithParents || worseOffspringNeeded > 0) { 156 154 currentOffspring = offspring.SubScopes[i]; 157 155 offspring.SubScopes.Remove(currentOffspring);
Note: See TracChangeset
for help on using the changeset viewer.