Changeset 13110
- Timestamp:
- 11/03/15 15:34:46 (9 years ago)
- Location:
- branches/ALPS/HeuristicLab.Algorithms.ALPS/3.3
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ALPS/HeuristicLab.Algorithms.ALPS/3.3/AlpsGeneticAlgorithm.cs
r13096 r13110 114 114 get { return (IValueParameter<IntValue>)Parameters["MatingPoolRange"]; } 115 115 } 116 private IValueParameter<BoolValue> ContinuousReseedingParameter {117 get { return (IValueParameter<BoolValue>)Parameters["ContinuousReseeding"]; }118 }119 116 120 117 private IValueParameter<MultiTerminator> TerminatorParameter { … … 198 195 get { return MatingPoolRangeParameter.Value; } 199 196 set { MatingPoolRangeParameter.Value = value; } 200 }201 public BoolValue ContinuousReseeding {202 get { return ContinuousReseedingParameter.Value; }203 set { ContinuousReseedingParameter.Value = value; }204 197 } 205 198 … … 300 293 301 294 Parameters.Add(new ValueParameter<IntValue>("MatingPoolRange", "The range of layers used for creating a mating pool. (1 = current + previous layer)", new IntValue(1)) { Hidden = true }); 302 Parameters.Add(new ValueParameter<BoolValue>("ContinuousReseeding", "Instead of replacing the lowest layer every AgeGap generations replace 1/AgeGap individuals every generation", new BoolValue(false)) { Hidden = true });303 295 304 296 Parameters.Add(new ValueParameter<MultiTerminator>("Terminator", "The termination criteria which sould be checked.", new MultiTerminator())); -
branches/ALPS/HeuristicLab.Algorithms.ALPS/3.3/EldersEmigrator.cs
r13079 r13110 61 61 eldersSelector.Successor = null; 62 62 63 shiftToRightMigrator.ClockwiseMigration DirectionParameter.Value = new BoolValue(true);63 shiftToRightMigrator.ClockwiseMigrationParameter.Value = new BoolValue(true); 64 64 shiftToRightMigrator.Successor = mergingProsessor; 65 65 -
branches/ALPS/HeuristicLab.Algorithms.ALPS/3.3/LayerReseeder.cs
r13096 r13110 28 28 using HeuristicLab.Parameters; 29 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 30 using HeuristicLab.Selection;31 30 32 31 namespace HeuristicLab.Algorithms.ALPS { … … 44 43 } 45 44 46 private ILookupParameter<BoolValue> ContinuousReseedingParameter {47 get { return (ILookupParameter<BoolValue>)Parameters["ContinuousReseeding"]; }48 }49 45 private ILookupParameter<IntValue> GenerationsParameter { 50 46 get { return (ILookupParameter<IntValue>)Parameters["Generations"]; } … … 74 70 public LayerReseeder() 75 71 : base() { 76 Parameters.Add(new LookupParameter<BoolValue>("ContinuousReseeding"));77 72 Parameters.Add(new LookupParameter<IntValue>("Generations")); 78 73 Parameters.Add(new LookupParameter<IntValue>("AgeGap")); … … 80 75 operatorGraph = new OperatorGraph(); 81 76 82 var subScopesCounter = new SubScopesCounter();83 var numberOfReplacedCalculator = new ExpressionCalculator() { Name = "NumberOfReplaced = if ContinuousReseeding then max(LayerPopulationSize - (PopulationSize - PopulationSize / AgeGap), 0) else PopulationSize" };84 var numberOfNewIndividualsCalculator = new ExpressionCalculator() { Name = "NumberOfNewIndividuals = PopulationSize - (LayerPopulatioSize - NumberOfReplaced)" };85 var oldestSelector = new BestSelector();86 var processOldest = new SubScopesProcessor();87 77 var removeIndividuals = new SubScopesRemover(); 88 78 var createIndividuals = new SolutionsCreator(); 89 var mergeIndididuals = new MergingReducer();90 79 var initializeAgeProsessor = new UniformSubScopesProcessor(); 91 80 var initializeAge = new VariableCreator() { Name = "Initialize Age" }; 92 81 var incrEvaluatedSolutionsAfterReseeding = new SubScopesCounter() { Name = "Update EvaluatedSolutions" }; 93 var subScopesCounter2 = new SubScopesCounter();94 82 95 OperatorGraph.InitialOperator = subScopesCounter; 96 97 subScopesCounter.ValueParameter.ActualName = "LayerPopulationSize"; 98 subScopesCounter.AccumulateParameter.Value = new BoolValue(false); 99 subScopesCounter.Successor = numberOfReplacedCalculator; 100 101 numberOfReplacedCalculator.CollectedValues.Add(new LookupParameter<BoolValue>("ContinuousReseeding")); 102 numberOfReplacedCalculator.CollectedValues.Add(new LookupParameter<IntValue>("LayerPopulationSize")); 103 numberOfReplacedCalculator.CollectedValues.Add(new LookupParameter<IntValue>("PopulationSize")); 104 numberOfReplacedCalculator.CollectedValues.Add(new LookupParameter<IntValue>("AgeGap")); 105 numberOfReplacedCalculator.ExpressionResultParameter.ActualName = "NumberOfReplaced"; 106 const string numSelected = "LayerPopulationSize PopulationSize PopulationSize AgeGap / - -"; 107 numberOfReplacedCalculator.ExpressionParameter.Value = new StringValue(numSelected + " 0 0 " + numSelected + " < if PopulationSize ContinuousReseeding if toint"); 108 numberOfReplacedCalculator.Successor = numberOfNewIndividualsCalculator; 109 110 numberOfNewIndividualsCalculator.CollectedValues.Add(new LookupParameter<IntValue>("PopulationSize")); 111 numberOfNewIndividualsCalculator.CollectedValues.Add(new LookupParameter<IntValue>("NumberOfReplaced")); 112 numberOfNewIndividualsCalculator.CollectedValues.Add(new LookupParameter<IntValue>("LayerPopulationSize")); 113 numberOfNewIndividualsCalculator.ExpressionResultParameter.ActualName = "NumberOfNewIndividuals"; 114 numberOfNewIndividualsCalculator.ExpressionParameter.Value = new StringValue("PopulationSize LayerPopulationSize NumberOfReplaced - - toint"); 115 numberOfNewIndividualsCalculator.Successor = oldestSelector; 116 117 oldestSelector.QualityParameter.ActualName = "Age"; 118 oldestSelector.NumberOfSelectedSubScopesParameter.ActualName = "NumberOfReplaced"; 119 oldestSelector.MaximizationParameter.Value = new BoolValue(true); 120 oldestSelector.CopySelected = new BoolValue(false); 121 oldestSelector.Successor = processOldest; 122 123 processOldest.Operators.Add(new EmptyOperator()); 124 processOldest.Operators.Add(removeIndividuals); 125 processOldest.Successor = mergeIndididuals; 83 OperatorGraph.InitialOperator = removeIndividuals; 126 84 127 85 removeIndividuals.Successor = createIndividuals; 128 86 129 createIndividuals.NumberOfSolutionsParameter.ActualName = " NumberOfNewIndividuals";87 createIndividuals.NumberOfSolutionsParameter.ActualName = "PopulationSize"; 130 88 createIndividuals.Successor = initializeAgeProsessor; 131 89 … … 139 97 incrEvaluatedSolutionsAfterReseeding.AccumulateParameter.Value = new BoolValue(true); 140 98 incrEvaluatedSolutionsAfterReseeding.Successor = null; 141 142 mergeIndididuals.Successor = subScopesCounter2;143 144 subScopesCounter2.ValueParameter.ActualName = "LayerPopulationSize";145 subScopesCounter2.AccumulateParameter.Value = new BoolValue(false);146 99 } 147 100 148 101 public override IOperation Apply() { 149 bool continuousReseeding = ContinuousReseedingParameter.ActualValue.Value;150 102 int generations = GenerationsParameter.ActualValue.Value; 151 103 int ageGap = AgeGapParameter.ActualValue.Value; 152 104 153 105 var next = new OperationCollection(base.Apply()); 154 if ( continuousReseeding ||generations % ageGap == 0) {106 if (generations % ageGap == 0) { 155 107 var layerZeroScope = ExecutionContext.Scope.SubScopes[0]; 156 108 if (operatorGraph.InitialOperator != null)
Note: See TracChangeset
for help on using the changeset viewer.