Changeset 15432 for branches/Enhanced OSALPS
- Timestamp:
- 10/25/17 13:53:11 (7 years ago)
- Location:
- branches/Enhanced OSALPS/HeuristicLab.Algorithms.ALPS/3.3
- Files:
-
- 3 added
- 2 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/Enhanced OSALPS/HeuristicLab.Algorithms.ALPS/3.3/AlpsOs2MainLoop.cs
r15429 r15432 32 32 namespace HeuristicLab.Algorithms.ALPS { 33 33 34 [Item("AlpsO ffspringSelectionGeneticAlgorithmMainLoop", "An ALPS offspring selection genetic algorithm main loop operator.")]34 [Item("AlpsOs2MainLoop", "An ALPS offspring selection genetic algorithm main loop operator.")] 35 35 [StorableClass] 36 public sealed class AlpsO ffspringSelectionGeneticAlgorithmMainLoop : AlgorithmOperator {36 public sealed class AlpsOs2MainLoop : AlgorithmOperator { 37 37 #region Parameter Properties 38 38 public IValueLookupParameter<IRandom> GlobalRandomParameter { … … 121 121 } 122 122 123 public IValueLookupParameter< IntValue> MatingPoolRangeParameter {124 get { return (IValueLookupParameter< IntValue>)Parameters["MatingPoolRange"]; }123 public IValueLookupParameter<DoubleArray> MatingPoolRangesParameter { 124 get { return (IValueLookupParameter<DoubleArray>)Parameters["MatingPoolRanges"]; } 125 125 } 126 126 public IValueLookupParameter<BoolValue> ReduceToPopulationSizeParameter { … … 133 133 #endregion 134 134 135 [StorableConstructor] 136 private AlpsOffspringSelectionGeneticAlgorithmMainLoop(bool deserializing) 137 : base(deserializing) { } 138 private AlpsOffspringSelectionGeneticAlgorithmMainLoop(AlpsOffspringSelectionGeneticAlgorithmMainLoop original, Cloner cloner) 139 : base(original, cloner) { } 140 public override IDeepCloneable Clone(Cloner cloner) { 141 return new AlpsOffspringSelectionGeneticAlgorithmMainLoop(this, cloner); 142 } 143 public AlpsOffspringSelectionGeneticAlgorithmMainLoop() 135 #region Constructor, Cloning & Persistence 136 public AlpsOs2MainLoop() 144 137 : base() { 145 138 Parameters.Add(new ValueLookupParameter<IRandom>("GlobalRandom", "A pseudo random number generator.")); … … 176 169 Parameters.Add(new ValueLookupParameter<IntArray>("AgeLimits", "The maximum age an individual is allowed to reach in a certain layer.")); 177 170 178 Parameters.Add(new ValueLookupParameter< IntValue>("MatingPoolRange", "The range of sub -populations used for creating a mating pool. (1 = current + previous sub-population)"));171 Parameters.Add(new ValueLookupParameter<DoubleArray>("MatingPoolRanges", "The range of sub-populations used for creating a mating pool. (1 = current + previous sub-population)")); 179 172 Parameters.Add(new ValueLookupParameter<BoolValue>("ReduceToPopulationSize", "Reduce the CurrentPopulationSize after elder migration to PopulationSize")); 180 173 … … 189 182 var initAnalyzerPlaceholder = new Placeholder() { Name = "Analyzer (Placeholder)" }; 190 183 var resultsCollector = new ResultsCollector(); 191 var matingPoolCreator = new MatingPoolCreator() { Name = "Create Mating Pools" };184 var matingPoolCreator = new ContinuousMatingPoolCreator() { Name = "Create Mating Pools" }; 192 185 var matingPoolProcessor = new UniformSubScopesProcessor() { Name = "Process Mating Pools" }; 193 186 var initializeLayer = new Assigner() { Name = "Reset LayerEvaluatedSolutions" }; 194 var mainOperator = new AlpsO ffspringSelectionGeneticAlgorithmMainOperator();187 var mainOperator = new AlpsOs2MainOperator(); 195 188 var generationsIcrementor = new IntCounter() { Name = "Increment Generations" }; 196 189 var evaluatedSolutionsReducer = new DataReducer() { Name = "Increment EvaluatedSolutions" }; … … 235 228 resultsCollector.Successor = matingPoolCreator; 236 229 237 matingPoolCreator.MatingPoolRangeParameter.Value = null; 238 matingPoolCreator.MatingPoolRangeParameter.ActualName = MatingPoolRangeParameter.Name; 230 matingPoolCreator.RangesParameter.ActualName = MatingPoolRangesParameter.Name; 231 matingPoolCreator.QualityParameter.ActualName = QualityParameter.Name; 232 matingPoolCreator.MaximizationParameter.ActualName = MaximizationParameter.Name; 239 233 matingPoolCreator.Successor = matingPoolProcessor; 240 234 … … 466 460 return reseeder; 467 461 } 462 463 public override IDeepCloneable Clone(Cloner cloner) { 464 return new AlpsOs2MainLoop(this, cloner); 465 } 466 private AlpsOs2MainLoop(AlpsOs2MainLoop original, Cloner cloner) 467 : base(original, cloner) { } 468 469 [StorableConstructor] 470 private AlpsOs2MainLoop(bool deserializing) 471 : base(deserializing) { } 472 #endregion 468 473 } 469 474 } -
branches/Enhanced OSALPS/HeuristicLab.Algorithms.ALPS/3.3/AlpsOs2MainOperator.cs
r15429 r15432 33 33 /// An operator which represents the main loop of an offspring selection genetic algorithm. 34 34 /// </summary> 35 [Item("AlpsO ffspringSelectionGeneticAlgorithmMainOperator", "An operator that represents the core of an alps offspring selection genetic algorithm.")]35 [Item("AlpsOs2MainOperator", "An operator that represents the core of an alps offspring selection genetic algorithm.")] 36 36 [StorableClass] 37 public sealed class AlpsO ffspringSelectionGeneticAlgorithmMainOperator : AlgorithmOperator {37 public sealed class AlpsOs2MainOperator : AlgorithmOperator { 38 38 #region Parameter properties 39 39 public IValueLookupParameter<IRandom> RandomParameter { … … 109 109 #endregion 110 110 111 [StorableConstructor] 112 private AlpsOffspringSelectionGeneticAlgorithmMainOperator(bool deserializing) : base(deserializing) { } 113 private AlpsOffspringSelectionGeneticAlgorithmMainOperator(AlpsOffspringSelectionGeneticAlgorithmMainOperator original, Cloner cloner) 114 : base(original, cloner) { 115 } 116 public override IDeepCloneable Clone(Cloner cloner) { 117 return new AlpsOffspringSelectionGeneticAlgorithmMainOperator(this, cloner); 118 } 119 public AlpsOffspringSelectionGeneticAlgorithmMainOperator() 120 : base() { 121 Initialize(); 122 } 123 124 private void Initialize() { 111 #region Constructor, Cloning & Persistence 112 public AlpsOs2MainOperator() 113 : base() { 125 114 Parameters.Add(new ValueLookupParameter<IRandom>("Random", "A pseudo random number generator.")); 126 115 … … 401 390 } 402 391 392 private AlpsOs2MainOperator(AlpsOs2MainOperator original, Cloner cloner) 393 : base(original, cloner) { 394 } 395 public override IDeepCloneable Clone(Cloner cloner) { 396 return new AlpsOs2MainOperator(this, cloner); 397 } 398 399 [StorableConstructor] 400 private AlpsOs2MainOperator(bool deserializing) 401 : base(deserializing) { } 402 #endregion 403 403 404 public override IOperation Apply() { 404 405 if (CrossoverParameter.ActualValue == null) -
branches/Enhanced OSALPS/HeuristicLab.Algorithms.ALPS/3.3/ContinuousMatingPoolCreator.cs
r15429 r15432 20 20 #endregion 21 21 22 using System; 23 using System.Collections.Generic; 24 using System.Linq; 22 25 using HeuristicLab.Common; 23 26 using HeuristicLab.Core; … … 28 31 29 32 namespace HeuristicLab.Algorithms.ALPS { 30 [Item(" MatingPoolCreator", "An operator which creates mating pools based on a set of sub-populations. For each sub-population, the individuals from the previous sub-population are copied into the current sub-population.")]33 [Item("ContinuousMatingPoolCreator", "An operator which creates mating pools based on a set of sub-populations. For each sub-population, the individuals from the previous sub-population are copied into the current sub-population.")] 31 34 [StorableClass] 32 public sealed class MatingPoolCreator : SingleSuccessorOperator { 33 public IValueLookupParameter<IntValue> MatingPoolRangeParameter { 34 get { return (IValueLookupParameter<IntValue>)Parameters["MatingPoolRange"]; } 35 public sealed class ContinuousMatingPoolCreator : SingleSuccessorOperator, IMatingPoolCreator { 36 public IValueLookupParameter<DoubleArray> RangesParameter { 37 get { return (IValueLookupParameter<DoubleArray>)Parameters["Ranges"]; } 38 } 39 40 public IScopeTreeLookupParameter<DoubleValue> QualityParameter { 41 get { return (IScopeTreeLookupParameter<DoubleValue>)Parameters["Quality"]; } 42 } 43 public IValueLookupParameter<BoolValue> MaximizationParameter { 44 get { return (IValueLookupParameter<BoolValue>)Parameters["Maximization"]; } 45 } 46 47 48 #region Constructor, Cloning & Persistence 49 public ContinuousMatingPoolCreator() 50 : base() { 51 Parameters.Add(new ValueLookupParameter<DoubleArray>("Ranges", "The range of sub-populations used for creating a mating pool. (1 = current + previous sub-population)")); 52 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The quality value contained in each sub-scope which is used for selection.")); 53 Parameters.Add(new ValueLookupParameter<BoolValue>("Maximization", "True if the current problem is a maximization problem, otherwise false.")); 54 } 55 56 private ContinuousMatingPoolCreator(ContinuousMatingPoolCreator original, Cloner cloner) 57 : base(original, cloner) { } 58 public override IDeepCloneable Clone(Cloner cloner) { 59 return new ContinuousMatingPoolCreator(this, cloner); 35 60 } 36 61 37 62 [StorableConstructor] 38 private MatingPoolCreator(bool deserializing)63 private ContinuousMatingPoolCreator(bool deserializing) 39 64 : base(deserializing) { } 40 private MatingPoolCreator(MatingPoolCreator original, Cloner cloner) 41 : base(original, cloner) { } 42 public override IDeepCloneable Clone(Cloner cloner) { 43 return new MatingPoolCreator(this, cloner); 44 } 45 public MatingPoolCreator() 46 : base() { 47 Parameters.Add(new ValueLookupParameter<IntValue>("MatingPoolRange", "The range of sub-populations used for creating a mating pool. (1 = current + previous sub-population)", new IntValue(1))); 48 } 65 #endregion 49 66 50 67 /// <summary> … … 62 79 public override IOperation Apply() { 63 80 var subScopes = ExecutionContext.Scope.SubScopes; 64 int range = MatingPoolRangeParameter.ActualValue.Value; 81 var ranges = RangesParameter.ActualValue; 82 var qualityName = QualityParameter.TranslatedName; 83 bool maximization = MaximizationParameter.ActualValue.Value; 65 84 66 85 for (int targetIndex = subScopes.Count - 1; targetIndex > 0; targetIndex--) { 67 86 var targetScope = subScopes[targetIndex]; 68 for (int n = 1; (n <= range) && (targetIndex - n >= 0); n++) { 87 var range = ranges.Length == 1 ? ranges[0] : ranges[targetIndex]; 88 for (int n = 1; (n <= (range + 1)) && (targetIndex - n >= 0); n++) { 69 89 var prevScope = subScopes[targetIndex - n]; 70 var individuals = prevScope.SubScopes; 90 IEnumerable<IScope> individuals = prevScope.SubScopes 91 .OrderBy(i => ((DoubleValue)i.Variables[qualityName].Value).Value); 92 if (maximization) individuals = individuals.Reverse(); 93 individuals = individuals.Take((int)(Math.Min(range + 1 - n, 1.0) * prevScope.SubScopes.Count)); 71 94 foreach (var individual in individuals) { 72 95 targetScope.SubScopes.Add((IScope)individual.Clone()); -
branches/Enhanced OSALPS/HeuristicLab.Algorithms.ALPS/3.3/HeuristicLab.Algorithms.ALPS-3.3.csproj
r15429 r15432 83 83 <SpecificVersion>False</SpecificVersion> 84 84 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Analysis-3.3.dll</HintPath> 85 <Private>False</Private> 85 86 </Reference> 86 87 <Reference Include="HeuristicLab.Collections-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 87 88 <SpecificVersion>False</SpecificVersion> 88 89 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Collections-3.3.dll</HintPath> 89 </Reference> 90 <Reference Include="HeuristicLab.Common-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec" /> 90 <Private>False</Private> 91 </Reference> 92 <Reference Include="HeuristicLab.Common-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec"> 93 <Private>False</Private> 94 </Reference> 91 95 <Reference Include="HeuristicLab.Core-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 92 96 <SpecificVersion>False</SpecificVersion> 93 97 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Core-3.3.dll</HintPath> 98 <Private>False</Private> 94 99 </Reference> 95 100 <Reference Include="HeuristicLab.Data-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 96 101 <SpecificVersion>False</SpecificVersion> 97 102 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Data-3.3.dll</HintPath> 103 <Private>False</Private> 98 104 </Reference> 99 105 <Reference Include="HeuristicLab.Operators-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 100 106 <SpecificVersion>False</SpecificVersion> 101 107 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Operators-3.3.dll</HintPath> 108 <Private>False</Private> 102 109 </Reference> 103 110 <Reference Include="HeuristicLab.Optimization-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 104 111 <SpecificVersion>False</SpecificVersion> 105 112 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Optimization-3.3.dll</HintPath> 113 <Private>False</Private> 106 114 </Reference> 107 115 <Reference Include="HeuristicLab.Optimization.Operators-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 108 116 <SpecificVersion>False</SpecificVersion> 109 117 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Optimization.Operators-3.3.dll</HintPath> 118 <Private>False</Private> 110 119 </Reference> 111 120 <Reference Include="HeuristicLab.Parameters-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 112 121 <SpecificVersion>False</SpecificVersion> 113 122 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Parameters-3.3.dll</HintPath> 123 <Private>False</Private> 114 124 </Reference> 115 125 <Reference Include="HeuristicLab.Persistence-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 116 126 <SpecificVersion>False</SpecificVersion> 117 127 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Persistence-3.3.dll</HintPath> 128 <Private>False</Private> 118 129 </Reference> 119 130 <Reference Include="HeuristicLab.PluginInfrastructure-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 120 131 <SpecificVersion>False</SpecificVersion> 121 132 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath> 133 <Private>False</Private> 122 134 </Reference> 123 135 <Reference Include="HeuristicLab.Random-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 124 136 <SpecificVersion>False</SpecificVersion> 125 137 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Random-3.3.dll</HintPath> 138 <Private>False</Private> 126 139 </Reference> 127 140 <Reference Include="HeuristicLab.Selection-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 128 141 <SpecificVersion>False</SpecificVersion> 129 142 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Selection-3.3.dll</HintPath> 143 <Private>False</Private> 130 144 </Reference> 131 145 <Reference Include="System" /> … … 134 148 </ItemGroup> 135 149 <ItemGroup> 150 <Compile Include="AlpsOs2MainOperator.cs" /> 151 <Compile Include="AlpsOs2MainLoop.cs" /> 136 152 <Compile Include="AlpsOffspringSelectionGeneticAlgorithmMainLoop.cs" /> 137 153 <Compile Include="AlpsOffspringSelectionGeneticAlgorithm.cs" /> … … 139 155 <Compile Include="AlpsOffspringSelectionGeneticAlgorithmMainOperator.cs" /> 140 156 <Compile Include="AlpsOffspringSelector.cs" /> 157 <Compile Include="AlpsOs2.cs" /> 158 <Compile Include="Interfaces\IMatingPoolCreator.cs" /> 159 <Compile Include="ContinuousMatingPoolCreator.cs" /> 141 160 <Compile Include="ReseedingController.cs" /> 142 161 <Compile Include="ResultsHistoryWiper.cs" /> -
branches/Enhanced OSALPS/HeuristicLab.Algorithms.ALPS/3.3/MatingPoolCreator.cs
r14185 r15432 30 30 [Item("MatingPoolCreator", "An operator which creates mating pools based on a set of sub-populations. For each sub-population, the individuals from the previous sub-population are copied into the current sub-population.")] 31 31 [StorableClass] 32 public sealed class MatingPoolCreator : SingleSuccessorOperator {32 public sealed class MatingPoolCreator : SingleSuccessorOperator, IMatingPoolCreator { 33 33 public IValueLookupParameter<IntValue> MatingPoolRangeParameter { 34 34 get { return (IValueLookupParameter<IntValue>)Parameters["MatingPoolRange"]; }
Note: See TracChangeset
for help on using the changeset viewer.