- Timestamp:
- 10/29/14 15:06:25 (10 years ago)
- Location:
- branches/VOSGA/HeuristicLab.Algorithms.VOffspringSelectionGeneticAlgorithm
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/VOSGA/HeuristicLab.Algorithms.VOffspringSelectionGeneticAlgorithm/HeuristicLab.Algorithms.VOffspringSelectionGeneticAlgorithm-3.3.csproj
r11492 r11510 161 161 </ItemGroup> 162 162 <ItemGroup> 163 <Compile Include="OffspringSelectors\IOffspringSelector.cs" /> 164 <Compile Include="OffspringSelectors\StandardOffspringSelector.cs" /> 163 165 <Compile Include="ProbabilitiesGenerator.cs" /> 164 166 <Compile Include="Plugin.cs" /> -
branches/VOSGA/HeuristicLab.Algorithms.VOffspringSelectionGeneticAlgorithm/Plugin.cs.frame
r11492 r11510 40 40 [PluginDependency("HeuristicLab.Random", "3.3")] 41 41 [PluginDependency("HeuristicLab.Selection", "3.3")] 42 public class HeuristicLabAlgorithms OffspringSelectionGeneticAlgorithmPlugin : PluginBase {42 public class HeuristicLabAlgorithmsVOffspringSelectionGeneticAlgorithmPlugin : PluginBase { 43 43 } 44 44 } -
branches/VOSGA/HeuristicLab.Algorithms.VOffspringSelectionGeneticAlgorithm/VOffspringSelectionGeneticAlgorithm.cs
r11492 r11510 38 38 /// An offspring selection genetic algorithm. 39 39 /// </summary> 40 [Item(" Offspring Selection Genetic Algorithm", "An offspring selection genetic algorithm (Affenzeller, M. et al. 2009. Genetic Algorithms and Genetic Programming - Modern Concepts and Practical Applications. CRC Press).")]40 [Item("VOSGA", "An OSGA with selectable OS criteria and automtic crossover/mutation selection.")] 41 41 [Creatable("Algorithms")] 42 42 [StorableClass] 43 public sealed class OffspringSelectionGeneticAlgorithm : HeuristicOptimizationEngineAlgorithm, IStorableContent {43 public sealed class VOffspringSelectionGeneticAlgorithm : HeuristicOptimizationEngineAlgorithm, IStorableContent { 44 44 public string Filename { get; set; } 45 45 … … 114 114 private IFixedValueParameter<BoolValue> FillPopulationWithParentsParameter { 115 115 get { return (IFixedValueParameter<BoolValue>)Parameters["FillPopulationWithParents"]; } 116 } 117 public IConstrainedValueParameter<IOffspringSelector> OffspringSelectorParameter { 118 get { return (IConstrainedValueParameter<IOffspringSelector>)Parameters["OffspringSelector"]; } 116 119 } 117 120 #endregion … … 134 137 set { SelectorParameter.Value = value; } 135 138 } 139 public IOffspringSelector OffspringSelector { 140 get { return OffspringSelectorParameter.Value; } 141 set { OffspringSelectorParameter.Value = value; } 142 } 136 143 public ICrossover Crossover { 137 144 get { return CrossoverParameter.Value; } … … 204 211 get { return (SolutionsCreator)RandomCreator.Successor; } 205 212 } 206 private OffspringSelectionGeneticAlgorithmMainLoop MainLoop {213 private VOffspringSelectionGeneticAlgorithmMainLoop MainLoop { 207 214 get { return FindMainLoop(SolutionsCreator.Successor); } 208 215 } … … 216 223 217 224 [StorableConstructor] 218 private OffspringSelectionGeneticAlgorithm(bool deserializing) : base(deserializing) { }225 private VOffspringSelectionGeneticAlgorithm(bool deserializing) : base(deserializing) { } 219 226 [StorableHook(HookType.AfterDeserialization)] 220 227 private void AfterDeserialization() { … … 232 239 Initialize(); 233 240 } 234 private OffspringSelectionGeneticAlgorithm(OffspringSelectionGeneticAlgorithm original, Cloner cloner)241 private VOffspringSelectionGeneticAlgorithm(VOffspringSelectionGeneticAlgorithm original, Cloner cloner) 235 242 : base(original, cloner) { 236 243 qualityAnalyzer = cloner.Clone(original.qualityAnalyzer); … … 240 247 } 241 248 public override IDeepCloneable Clone(Cloner cloner) { 242 return new OffspringSelectionGeneticAlgorithm(this, cloner);243 } 244 public OffspringSelectionGeneticAlgorithm()249 return new VOffspringSelectionGeneticAlgorithm(this, cloner); 250 } 251 public VOffspringSelectionGeneticAlgorithm() 245 252 : base() { 246 253 Parameters.Add(new ValueParameter<IntValue>("Seed", "The random seed used to initialize the new pseudo random number generator.", new IntValue(0))); … … 264 271 Parameters.Add(new ValueParameter<IntValue>("MaximumEvaluatedSolutions", "The maximum number of evaluated solutions (approximately).", new IntValue(int.MaxValue))); 265 272 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 Parameters.Add(new ConstrainedValueParameter<IOffspringSelector>("OffspringSelector", "The operator used as selection criterea for deciding which individuals are successful and which should be disgarded.")); 274 266 275 267 276 RandomCreator randomCreator = new RandomCreator(); … … 269 278 SubScopesCounter subScopesCounter = new SubScopesCounter(); 270 279 ResultsCollector resultsCollector = new ResultsCollector(); 271 OffspringSelectionGeneticAlgorithmMainLoop mainLoop = newOffspringSelectionGeneticAlgorithmMainLoop();280 VOffspringSelectionGeneticAlgorithmMainLoop mainLoop = new VOffspringSelectionGeneticAlgorithmMainLoop(); 272 281 OperatorGraph.InitialOperator = randomCreator; 273 282 … … 321 330 ParameterizeComparisonFactorModifiers(); 322 331 332 foreach (IOffspringSelector selector in ApplicationManager.Manager.GetInstances<IOffspringSelector>().OrderBy(x => x.Name)) 333 OffspringSelectorParameter.ValidValues.Add(selector); 334 IOffspringSelector standardOffspringSelector = OffspringSelectorParameter.ValidValues.FirstOrDefault(x => x.GetType().Name.Equals("StandardOffspringSelector")); 335 if (standardOffspringSelector != null) OffspringSelectorParameter.Value = standardOffspringSelector; 336 ParameterizeOffspringSelectors(); 337 323 338 qualityAnalyzer = new BestAverageWorstQualityAnalyzer(); 324 339 selectionPressureAnalyzer = new ValueAnalyzer(); … … 329 344 Initialize(); 330 345 } 331 332 333 346 334 347 public override void Prepare() { … … 431 444 selector.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName; 432 445 } 446 } 447 } 448 private void ParameterizeOffspringSelectors() { 449 foreach (IOffspringSelector selector in OffspringSelectorParameter.ValidValues) { 450 //TODO: do we need to set these parameters? if yes, where? 451 // selector.CurrentSuccessRatioParameter.ActualName = CurrentSuccessRatioParameter.Name; 452 //selector.SelectionPressureParameter.ActualName = SelectionPressureParameter.Name; 453 selector.MaximumSelectionPressureParameter.ActualName = MaximumSelectionPressureParameter.Name; 454 selector.SuccessRatioParameter.ActualName = SuccessRatioParameter.Name; 455 selector.OffspringPopulationParameter.ActualName = "OffspringPopulation"; 456 selector.OffspringPopulationWinnersParameter.ActualName = "OffspringPopulationWinners"; 457 selector.SuccessfulOffspringParameter.ActualName = "SuccessfulOffspring"; 458 selector.FillPopulationWithParentsParameter.ActualName = FillPopulationWithParentsParameter.Name; 433 459 } 434 460 } … … 507 533 Analyzer.Operators.Add(successfulOffspringAnalyzer, successfulOffspringAnalyzer.EnabledByDefault); 508 534 } 509 private OffspringSelectionGeneticAlgorithmMainLoop FindMainLoop(IOperator start) {535 private VOffspringSelectionGeneticAlgorithmMainLoop FindMainLoop(IOperator start) { 510 536 IOperator mainLoop = start; 511 while (mainLoop != null && !(mainLoop is OffspringSelectionGeneticAlgorithmMainLoop))537 while (mainLoop != null && !(mainLoop is VOffspringSelectionGeneticAlgorithmMainLoop)) 512 538 mainLoop = ((SingleSuccessorOperator)mainLoop).Successor; 513 539 if (mainLoop == null) return null; 514 else return ( OffspringSelectionGeneticAlgorithmMainLoop)mainLoop;540 else return (VOffspringSelectionGeneticAlgorithmMainLoop)mainLoop; 515 541 } 516 542 #endregion -
branches/VOSGA/HeuristicLab.Algorithms.VOffspringSelectionGeneticAlgorithm/VOffspringSelectionGeneticAlgorithmMainLoop.cs
r11492 r11510 32 32 /// An operator which represents the main loop of an offspring selection genetic algorithm. 33 33 /// </summary> 34 [Item(" OffspringSelectionGeneticAlgorithmMainLoop", "An operator which represents the main loop of an offspring selection genetic algorithm.")]34 [Item("VOffspringSelectionGeneticAlgorithmMainLoop", "An operator which represents the main loop of an offspring selection genetic algorithm.")] 35 35 [StorableClass] 36 public sealed class OffspringSelectionGeneticAlgorithmMainLoop : AlgorithmOperator {36 public sealed class VOffspringSelectionGeneticAlgorithmMainLoop : AlgorithmOperator { 37 37 #region Parameter properties 38 38 public ValueLookupParameter<IRandom> RandomParameter { … … 102 102 103 103 [StorableConstructor] 104 private OffspringSelectionGeneticAlgorithmMainLoop(bool deserializing) : base(deserializing) { }105 private OffspringSelectionGeneticAlgorithmMainLoop(OffspringSelectionGeneticAlgorithmMainLoop original, Cloner cloner)104 private VOffspringSelectionGeneticAlgorithmMainLoop(bool deserializing) : base(deserializing) { } 105 private VOffspringSelectionGeneticAlgorithmMainLoop(VOffspringSelectionGeneticAlgorithmMainLoop original, Cloner cloner) 106 106 : base(original, cloner) { 107 107 } 108 108 public override IDeepCloneable Clone(Cloner cloner) { 109 return new OffspringSelectionGeneticAlgorithmMainLoop(this, cloner);110 } 111 public OffspringSelectionGeneticAlgorithmMainLoop()109 return new VOffspringSelectionGeneticAlgorithmMainLoop(this, cloner); 110 } 111 public VOffspringSelectionGeneticAlgorithmMainLoop() 112 112 : base() { 113 113 Initialize(); … … 157 157 Placeholder analyzer1 = new Placeholder(); 158 158 ResultsCollector resultsCollector1 = new ResultsCollector(); 159 OffspringSelectionGeneticAlgorithmMainOperator mainOperator = newOffspringSelectionGeneticAlgorithmMainOperator();159 VOffspringSelectionGeneticAlgorithmMainOperator mainOperator = new VOffspringSelectionGeneticAlgorithmMainOperator(); 160 160 IntCounter generationsCounter = new IntCounter(); 161 161 Comparator maxGenerationsComparator = new Comparator(); -
branches/VOSGA/HeuristicLab.Algorithms.VOffspringSelectionGeneticAlgorithm/VOffspringSelectionGeneticAlgorithmMainOperator.cs
r11492 r11510 33 33 /// An operator which represents the main loop of an offspring selection genetic algorithm. 34 34 /// </summary> 35 [Item(" OffspringSelectionGeneticAlgorithmMainOperator", "An operator that represents the core of an offspring selection genetic algorithm.")]35 [Item("VOffspringSelectionGeneticAlgorithmMainOperator", "An operator that represents the core of an offspring selection genetic algorithm.")] 36 36 [StorableClass] 37 public sealed class OffspringSelectionGeneticAlgorithmMainOperator : AlgorithmOperator {37 public sealed class VOffspringSelectionGeneticAlgorithmMainOperator : AlgorithmOperator { 38 38 #region Parameter properties 39 39 public ValueLookupParameter<IRandom> RandomParameter { … … 91 91 get { return (IValueLookupParameter<BoolValue>)Parameters["FillPopulationWithParents"]; } 92 92 } 93 public ValueLookupParameter<IOffspringSelector> OffspringSelectorParameter { 94 get { return (ValueLookupParameter<IOffspringSelector>)Parameters["OffspringSelector"]; } 95 } 93 96 #endregion 94 97 95 98 [StorableConstructor] 96 private OffspringSelectionGeneticAlgorithmMainOperator(bool deserializing) : base(deserializing) { }97 private OffspringSelectionGeneticAlgorithmMainOperator(OffspringSelectionGeneticAlgorithmMainOperator original, Cloner cloner)99 private VOffspringSelectionGeneticAlgorithmMainOperator(bool deserializing) : base(deserializing) { } 100 private VOffspringSelectionGeneticAlgorithmMainOperator(VOffspringSelectionGeneticAlgorithmMainOperator original, Cloner cloner) 98 101 : base(original, cloner) { 99 102 } 100 103 public override IDeepCloneable Clone(Cloner cloner) { 101 return new OffspringSelectionGeneticAlgorithmMainOperator(this, cloner);102 } 103 public OffspringSelectionGeneticAlgorithmMainOperator()104 return new VOffspringSelectionGeneticAlgorithmMainOperator(this, cloner); 105 } 106 public VOffspringSelectionGeneticAlgorithmMainOperator() 104 107 : base() { 105 108 Initialize(); … … 138 141 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 142 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.")); 143 Parameters.Add(new ValueLookupParameter<IOffspringSelector>("OffspringSelector", "The operator used as selection criterea for deciding which individuals are successful and which should be disgarded.")); 140 144 #endregion 141 145 … … 172 176 WeightedParentsQualityComparator qualityComparer2 = new WeightedParentsQualityComparator(); 173 177 SubScopesRemover subScopesRemover2 = new SubScopesRemover(); 174 OffspringSelector offspringSelector = new OffspringSelector();178 Placeholder offspringSelector = new Placeholder(); 175 179 SubScopesProcessor subScopesProcessor3 = new SubScopesProcessor(); 176 180 BestSelector bestSelector = new BestSelector(); … … 183 187 Placeholder evaluator4 = new Placeholder(); 184 188 SubScopesCounter subScopesCounter4 = new SubScopesCounter(); 189 ConditionalBranch conditionalBranch = new ConditionalBranch(); 185 190 186 191 selector.Name = "Selector (placeholder)"; … … 260 265 subScopesRemover2.RemoveAllSubScopes = true; 261 266 262 offspringSelector.CurrentSuccessRatioParameter.ActualName = CurrentSuccessRatioParameter.Name; 263 offspringSelector.MaximumSelectionPressureParameter.ActualName = MaximumSelectionPressureParameter.Name; 264 offspringSelector.SelectionPressureParameter.ActualName = SelectionPressureParameter.Name; 265 offspringSelector.SuccessRatioParameter.ActualName = SuccessRatioParameter.Name; 266 offspringSelector.OffspringPopulationParameter.ActualName = "OffspringPopulation"; 267 offspringSelector.OffspringPopulationWinnersParameter.ActualName = "OffspringPopulationWinners"; 268 offspringSelector.SuccessfulOffspringParameter.ActualName = "SuccessfulOffspring"; 269 offspringSelector.FillPopulationWithParentsParameter.ActualName = FillPopulationWithParentsParameter.Name; 267 offspringSelector.Name = "OffspringSelector (placeholder)"; 268 offspringSelector.OperatorParameter.ActualName = OffspringSelectorParameter.Name; 270 269 271 270 bestSelector.CopySelected = new BoolValue(false); … … 289 288 subScopesCounter4.Name = "Increment EvaluatedSolutions"; 290 289 subScopesCounter4.ValueParameter.ActualName = EvaluatedSolutionsParameter.Name; 290 291 conditionalBranch.Name = "Enough children produced?"; 292 conditionalBranch.ConditionParameter.ActualName = "EnoughChildrenGenerated"; 293 conditionalBranch.FalseBranch = selector; 294 conditionalBranch.TrueBranch = subScopesProcessor3; 291 295 #endregion 292 296 … … 340 344 subScopesRemover2.Successor = null; 341 345 subScopesCounter3.Successor = null; 342 offspringSelector.OffspringCreator = selector; 343 offspringSelector.Successor = subScopesProcessor3; 346 offspringSelector.Successor = conditionalBranch; 344 347 subScopesProcessor3.Operators.Add(bestSelector); 345 348 subScopesProcessor3.Operators.Add(worstSelector);
Note: See TracChangeset
for help on using the changeset viewer.