Changeset 13046
- Timestamp:
- 10/21/15 17:42:18 (9 years ago)
- Location:
- branches/ALPS/HeuristicLab.Algorithms.ALPS/3.3
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ALPS/HeuristicLab.Algorithms.ALPS/3.3/AlpsGeneticAlgorithm.cs
r12999 r13046 344 344 initializeLayerPopulationSize.Successor = initializeLocalEvaluatedSolutions; 345 345 346 initializeAge.CollectedValues.Add(new ValueParameter< IntValue>("Age", new IntValue(0)));346 initializeAge.CollectedValues.Add(new ValueParameter<DoubleValue>("Age", new DoubleValue(0))); 347 347 initializeAge.Successor = null; 348 348 -
branches/ALPS/HeuristicLab.Algorithms.ALPS/3.3/AlpsGeneticAlgorithmMainLoop.cs
r13035 r13046 216 216 // Increment ages of all individuals after replacement 217 217 var incrementAgeProcessor = new UniformSubScopesProcessor(); 218 var ageIncrementor = new IntCounter() { Name = "Increment Age" };218 var ageIncrementor = new DoubleCounter() { Name = "Increment Age" }; 219 219 replacementBranch.Successor = incrementAgeProcessor; 220 220 incrementAgeProcessor.Operator = ageIncrementor; 221 221 incrementAgeProcessor.Successor = null; 222 222 ageIncrementor.ValueParameter.ActualName = "Age"; 223 ageIncrementor.Increment = new IntValue(1); 224 //ageIncrementor.Successor = null; 223 ageIncrementor.Increment = new DoubleValue(1.0); 225 224 226 225 // Insert AgeCalculator between crossover and its successor -
branches/ALPS/HeuristicLab.Algorithms.ALPS/3.3/Analyzers/AgeDistributionAnalyzer.cs
r12046 r13046 37 37 38 38 #region Parameter Properties 39 public IScopeTreeLookupParameter< IntValue> AgeParameter {40 get { return (IScopeTreeLookupParameter< IntValue>)Parameters["Age"]; }39 public IScopeTreeLookupParameter<DoubleValue> AgeParameter { 40 get { return (IScopeTreeLookupParameter<DoubleValue>)Parameters["Age"]; } 41 41 } 42 42 public ValueLookupParameter<ResultCollection> ResultsParameter { … … 78 78 public AgeDistributionAnalyzer() 79 79 : base() { 80 Parameters.Add(new ScopeTreeLookupParameter< IntValue>("Age", "The value which represents the age of a solution."));80 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Age", "The value which represents the age of a solution.")); 81 81 Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The results collection where the analysis values should be stored.")); 82 82 Parameters.Add(new FixedValueParameter<StringValue>("HistogramName", "The name of the histogram that gets injected in to the results collection.", new StringValue("Age Distribution"))); … … 110 110 } 111 111 var ages = AgeParameter.ActualValue; 112 row.Values.Replace(ages.Select(x => (double)x.Value));112 row.Values.Replace(ages.Select(x => x.Value)); 113 113 114 114 if (StoreHistory) { -
branches/ALPS/HeuristicLab.Algorithms.ALPS/3.3/Analyzers/OldestAverageYoungestAgeAnalyzer.cs
r12996 r13046 36 36 public sealed class OldestAverageYoungestAgeAnalyzer : AlgorithmOperator, IAnalyzer { 37 37 #region Parameter properties 38 public IScopeTreeLookupParameter< IntValue> AgeParameter {39 get { return (IScopeTreeLookupParameter< IntValue>)Parameters["Age"]; }38 public IScopeTreeLookupParameter<DoubleValue> AgeParameter { 39 get { return (IScopeTreeLookupParameter<DoubleValue>)Parameters["Age"]; } 40 40 } 41 public IValueLookupParameter< IntValue> CurrentOldestAgeParameter {42 get { return (IValueLookupParameter< IntValue>)Parameters["CurrentOldestAge"]; }41 public IValueLookupParameter<DoubleValue> CurrentOldestAgeParameter { 42 get { return (IValueLookupParameter<DoubleValue>)Parameters["CurrentOldestAge"]; } 43 43 } 44 public IValueLookupParameter< IntValue> CurrentAverageAgeParameter {45 get { return (IValueLookupParameter< IntValue>)Parameters["CurrentAverageAge"]; }44 public IValueLookupParameter<DoubleValue> CurrentAverageAgeParameter { 45 get { return (IValueLookupParameter<DoubleValue>)Parameters["CurrentAverageAge"]; } 46 46 } 47 public IValueLookupParameter< IntValue> CurrentYoungestAgeParameter {48 get { return (IValueLookupParameter< IntValue>)Parameters["CurrentYoungestAge"]; }47 public IValueLookupParameter<DoubleValue> CurrentYoungestAgeParameter { 48 get { return (IValueLookupParameter<DoubleValue>)Parameters["CurrentYoungestAge"]; } 49 49 } 50 50 public IValueLookupParameter<DataTable> AgesParameter { … … 79 79 : base() { 80 80 #region Create parameters 81 Parameters.Add(new ScopeTreeLookupParameter< IntValue>("Age", "The value which represents the age of a solution."));82 Parameters.Add(new ValueLookupParameter< IntValue>("CurrentOldestAge", "The oldest age value found in the current population."));83 Parameters.Add(new ValueLookupParameter< IntValue>("CurrentAverageAge", "The average age value of all solutions in the current population."));84 Parameters.Add(new ValueLookupParameter< IntValue>("CurrentYoungestAge", "The youngest age value found in the current population."));81 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Age", "The value which represents the age of a solution.")); 82 Parameters.Add(new ValueLookupParameter<DoubleValue>("CurrentOldestAge", "The oldest age value found in the current population.")); 83 Parameters.Add(new ValueLookupParameter<DoubleValue>("CurrentAverageAge", "The average age value of all solutions in the current population.")); 84 Parameters.Add(new ValueLookupParameter<DoubleValue>("CurrentYoungestAge", "The youngest age value found in the current population.")); 85 85 Parameters.Add(new ValueLookupParameter<DataTable>("Ages", "The data table to store the current oldest, current average, current youngest age value.")); 86 86 Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The results collection where the analysis values should be stored.")); … … 103 103 oldestAverageYoungestAgeCalculator.YoungestAgeParameter.ActualName = CurrentYoungestAgeParameter.Name; 104 104 105 dataTableValuesCollector.CollectedValues.Add(new LookupParameter< IntValue>("CurrentOldestAge", null, CurrentOldestAgeParameter.Name));106 dataTableValuesCollector.CollectedValues.Add(new LookupParameter< IntValue>("CurrentAverageAge", null, CurrentAverageAgeParameter.Name));107 dataTableValuesCollector.CollectedValues.Add(new LookupParameter< IntValue>("CurrentYoungestAge", null, CurrentYoungestAgeParameter.Name));105 dataTableValuesCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("CurrentOldestAge", null, CurrentOldestAgeParameter.Name)); 106 dataTableValuesCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("CurrentAverageAge", null, CurrentAverageAgeParameter.Name)); 107 dataTableValuesCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("CurrentYoungestAge", null, CurrentYoungestAgeParameter.Name)); 108 108 dataTableValuesCollector.DataTableParameter.ActualName = AgesParameter.Name; 109 109 110 //resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("CurrentOldestAge", null, CurrentOldestAgeParameter.Name));111 //resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("CurrentAverageAge", null, CurrentAverageAgeParameter.Name));112 //resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("CurrentYoungestAge", null, CurrentYoungestAgeParameter.Name));113 110 resultsCollector.CollectedValues.Add(new LookupParameter<DataTable>(AgesParameter.Name)); 114 111 resultsCollector.ResultsParameter.ActualName = ResultsParameter.Name; -
branches/ALPS/HeuristicLab.Algorithms.ALPS/3.3/Analyzers/OldestAverageYoungestAgeCalculator.cs
r12570 r13046 31 31 [StorableClass] 32 32 public sealed class OldestAverageYoungestAgeCalculator : SingleSuccessorOperator { 33 public IScopeTreeLookupParameter< IntValue> AgeParameter {34 get { return (IScopeTreeLookupParameter< IntValue>)Parameters["Age"]; }33 public IScopeTreeLookupParameter<DoubleValue> AgeParameter { 34 get { return (IScopeTreeLookupParameter<DoubleValue>)Parameters["Age"]; } 35 35 } 36 public IValueLookupParameter< IntValue> OldestAgeParameter {37 get { return (IValueLookupParameter< IntValue>)Parameters["OldestAge"]; }36 public IValueLookupParameter<DoubleValue> OldestAgeParameter { 37 get { return (IValueLookupParameter<DoubleValue>)Parameters["OldestAge"]; } 38 38 } 39 public IValueLookupParameter< IntValue> AverageAgeParameter {40 get { return (IValueLookupParameter< IntValue>)Parameters["AverageAge"]; }39 public IValueLookupParameter<DoubleValue> AverageAgeParameter { 40 get { return (IValueLookupParameter<DoubleValue>)Parameters["AverageAge"]; } 41 41 } 42 public IValueLookupParameter< IntValue> YoungestAgeParameter {43 get { return (IValueLookupParameter< IntValue>)Parameters["YoungestAge"]; }42 public IValueLookupParameter<DoubleValue> YoungestAgeParameter { 43 get { return (IValueLookupParameter<DoubleValue>)Parameters["YoungestAge"]; } 44 44 } 45 45 … … 55 55 public OldestAverageYoungestAgeCalculator() 56 56 : base() { 57 Parameters.Add(new ScopeTreeLookupParameter< IntValue>("Age", "The value contained in the scope tree which represents the solution age."));58 Parameters.Add(new ValueLookupParameter< IntValue>("OldestAge", "The age value of the oldest solution."));59 Parameters.Add(new ValueLookupParameter< IntValue>("AverageAge", "The average age of all solutions."));60 Parameters.Add(new ValueLookupParameter< IntValue>("YoungestAge", "The age value of the youngest solution."));57 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Age", "The value contained in the scope tree which represents the solution age.")); 58 Parameters.Add(new ValueLookupParameter<DoubleValue>("OldestAge", "The age value of the oldest solution.")); 59 Parameters.Add(new ValueLookupParameter<DoubleValue>("AverageAge", "The average age of all solutions.")); 60 Parameters.Add(new ValueLookupParameter<DoubleValue>("YoungestAge", "The age value of the youngest solution.")); 61 61 62 62 OldestAgeParameter.Hidden = true; … … 69 69 70 70 if (ages.Length > 0) { 71 int min = int.MaxValue, max = int.MinValue, sum = 0;71 double min = double.MaxValue, max = double.MinValue, sum = 0; 72 72 for (int i = 0; i < ages.Length; i++) { 73 73 if (ages[i].Value < min) min = ages[i].Value; … … 77 77 78 78 var oldest = OldestAgeParameter.ActualValue; 79 if (oldest == null) OldestAgeParameter.ActualValue = new IntValue(max);79 if (oldest == null) OldestAgeParameter.ActualValue = new DoubleValue(max); 80 80 else oldest.Value = max; 81 81 var average = AverageAgeParameter.ActualValue; 82 if (average == null) AverageAgeParameter.ActualValue = new IntValue(sum / ages.Length);82 if (average == null) AverageAgeParameter.ActualValue = new DoubleValue(sum / ages.Length); 83 83 else average.Value = sum / ages.Length; 84 84 var youngest = YoungestAgeParameter.ActualValue; 85 if (youngest == null) YoungestAgeParameter.ActualValue = new IntValue(min);85 if (youngest == null) YoungestAgeParameter.ActualValue = new DoubleValue(min); 86 86 else youngest.Value = min; 87 87 } -
branches/ALPS/HeuristicLab.Algorithms.ALPS/3.3/EldersEmigrator.cs
r12992 r13046 59 59 selectorProsessor.Successor = shiftToRightMigrator; 60 60 61 eldersSelector.CopySelected = new BoolValue(false);62 61 eldersSelector.Successor = null; 63 62 -
branches/ALPS/HeuristicLab.Algorithms.ALPS/3.3/EldersSelector.cs
r12018 r13046 33 33 [Item("EldersSelector", "Select all individuals which are to old for their current layer.")] 34 34 [StorableClass] 35 public sealed class EldersSelector : SingleObjectiveSelector { 36 35 public sealed class EldersSelector : Selector { 36 private IScopeTreeLookupParameter<DoubleValue> AgeParameter { 37 get { return (IScopeTreeLookupParameter<DoubleValue>)Parameters["Age"]; } 38 } 37 39 private ILookupParameter<IntArray> AgeLimitsParameter { 38 40 get { return (ILookupParameter<IntArray>)Parameters["AgeLimits"]; } … … 55 57 public EldersSelector() 56 58 : base() { 59 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Age")); 57 60 Parameters.Add(new LookupParameter<IntArray>("AgeLimits")); 58 61 Parameters.Add(new LookupParameter<IntValue>("NumberOfLayers")); … … 61 64 62 65 protected override IScope[] Select(List<IScope> scopes) { 66 var ages = AgeParameter.ActualValue; 63 67 var ageLimits = AgeLimitsParameter.ActualValue; 64 68 int numberOfLayers = NumberOfLayersParameter.ActualValue.Value; … … 69 73 70 74 int limit = ageLimits[layer]; 71 var eldersQuery = 72 from scope in scopes 73 let age = ((IntValue)scope.Variables["Age"].Value).Value 74 where age > limit 75 select scope; 75 var elders = ages 76 .Select((x, index) => new { index, age = x.Value }) 77 .Where(x => x.age > limit) 78 .ToList(); 76 79 77 var elders = eldersQuery.ToArray();78 79 if (!CopySelected.Value)80 foreach (var elder in elders)81 scopes.Remove(elder);82 83 return elders;80 IScope[] selected = new IScope[elders.Count]; 81 for (int i = 0; i < elders.Count; i++) { 82 selected[i] = scopes[elders[i].index]; 83 scopes[elders[i].index] = null; 84 } 85 scopes.RemoveAll(x => x == null); 86 return selected; 84 87 } 85 88 } -
branches/ALPS/HeuristicLab.Algorithms.ALPS/3.3/LayerCreator.cs
r13037 r13046 35 35 [StorableClass] 36 36 public sealed class LayerCreator : SingleSuccessorOperator { 37 38 /*private static readonly ISet<string> SavedVariables = new HashSet<string>{39 "LocalRandom", "Layer", "LayerEvaluatedSolutions", "NumSubScopes"40 };*/41 42 37 private ILookupParameter<IntValue> OpenLayersParameter { 43 38 get { return (ILookupParameter<IntValue>)Parameters["OpenLayers"]; } … … 78 73 // Decrement ages, because MainOperator is goint to increment it 79 74 foreach (var solution in clone.SubScopes) 80 (( IntValue)solution.Variables["Age"].Value).Value -= 1;75 ((DoubleValue)solution.Variables["Age"].Value).Value -= 1; 81 76 82 77 // Reset existing values in the results to NaN to symbolize that no layer existed during that duration -
branches/ALPS/HeuristicLab.Algorithms.ALPS/3.3/LayerUpdator.cs
r12992 r13046 64 64 var newLayerLayerProcessor = new UniformSubScopesProcessor(); 65 65 var newLayerReducer = new MergingReducer(); 66 var layerInitializer = new Assigner() { Name = "Init Layer" };67 var correctAgeProcessor = new UniformSubScopesProcessor() { Name = "Hack: Decrement Age" };68 var correctAgeDecrementor = new IntCounter() { Name = "Age = Age - 1" };69 66 var incrEvaluatedSolutionsForNewLayer = new SubScopesCounter() { Name = "Update EvaluatedSolutions" }; 70 67 var newResultCollectionAssigner = new Assigner() { Name = "Empty Results" }; … … 131 128 newLayerReducer.Successor = incrOpenLayers; 132 129 133 layerInitializer.LeftSideParameter.ActualName = "Layer";134 layerInitializer.RightSideParameter.ActualName = "OpenLayers";135 layerInitializer.Successor = correctAgeProcessor;136 137 correctAgeProcessor.Operator = correctAgeDecrementor;138 correctAgeProcessor.Successor = incrEvaluatedSolutionsForNewLayer;139 140 correctAgeDecrementor.Increment = new IntValue(-1);141 correctAgeDecrementor.ValueParameter.ActualName = "Age";142 143 130 incrEvaluatedSolutionsForNewLayer.ValueParameter.ActualName = "EvaluatedSolutions"; 144 131 incrEvaluatedSolutionsForNewLayer.AccumulateParameter.Value = new BoolValue(true); … … 179 166 initializeAgeProsessor.Successor = incrEvaluatedSolutionsAfterReseeding; 180 167 181 initializeAge.CollectedValues.Add(new ValueParameter< IntValue>("Age", new IntValue(0)));168 initializeAge.CollectedValues.Add(new ValueParameter<DoubleValue>("Age", new DoubleValue(0))); 182 169 initializeAge.Successor = null; 183 170 -
branches/ALPS/HeuristicLab.Algorithms.ALPS/3.3/WeightingReducer.cs
r12997 r13046 34 34 public sealed class WeightingReducer : SingleSuccessorOperator { 35 35 36 public ScopeTreeLookupParameter<IntValue> ParameterToReduce {37 get { return ( ScopeTreeLookupParameter<IntValue>)Parameters["ParameterToReduce"]; }36 public IScopeTreeLookupParameter<DoubleValue> ParameterToReduce { 37 get { return (IScopeTreeLookupParameter<DoubleValue>)Parameters["ParameterToReduce"]; } 38 38 } 39 public LookupParameter<IntValue> TargetParameter {40 get { return ( LookupParameter<IntValue>)Parameters["TargetParameter"]; }39 public ILookupParameter<DoubleValue> TargetParameter { 40 get { return (ILookupParameter<DoubleValue>)Parameters["TargetParameter"]; } 41 41 } 42 42 public IValueLookupParameter<DoubleValue> WeightParameter { … … 54 54 public WeightingReducer() 55 55 : base() { 56 Parameters.Add(new ScopeTreeLookupParameter< IntValue>("ParameterToReduce", "The parameter on which the weighting should be applied."));57 Parameters.Add(new LookupParameter< IntValue>("TargetParameter", "The target variable in which the weighted value should be stored."));56 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("ParameterToReduce", "The parameter on which the weighting should be applied.")); 57 Parameters.Add(new LookupParameter<DoubleValue>("TargetParameter", "The target variable in which the weighted value should be stored.")); 58 58 Parameters.Add(new ValueLookupParameter<DoubleValue>("Weight", "Weight of the two values (0.0 for the smaller, 1.0 for the larger).")); 59 59 } … … 64 64 throw new InvalidOperationException("Weighting between values can only done for two values."); 65 65 66 varweight = WeightParameter.ActualValue.Value;66 double weight = WeightParameter.ActualValue.Value; 67 67 68 varmax = values.Max(v => v.Value);69 varmin = values.Min(v => v.Value);68 double max = values.Max(v => v.Value); 69 double min = values.Min(v => v.Value); 70 70 71 int result = (int)(max * weight + min * (1 - weight));71 double result = max * weight + min * (1 - weight); 72 72 73 73 if (TargetParameter.ActualValue == null) 74 TargetParameter.ActualValue = new IntValue(result);74 TargetParameter.ActualValue = new DoubleValue(result); 75 75 else TargetParameter.ActualValue.Value = result; 76 76
Note: See TracChangeset
for help on using the changeset viewer.