Changeset 10353
- Timestamp:
- 01/17/14 13:05:47 (11 years ago)
- Location:
- branches/DataAnalysis.IslandAlgorithms/HeuristicLab.Algorithms.DataAnalysis.Symbolic/3.3
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataAnalysis.IslandAlgorithms/HeuristicLab.Algorithms.DataAnalysis.Symbolic/3.3/ConsecutiveSamplesEvaluator.cs
r10230 r10353 63 63 get { return (ILookupParameter<IntRange>)Parameters[FixedSamplesPartitionParameterName]; } 64 64 } 65 public IFixedValueParameter< IntValue> ConsecutiveSamplesParameter {66 get { return (IFixedValueParameter< IntValue>)Parameters[ConsecutiveSamplesParameterName]; }65 public IFixedValueParameter<PercentValue> ConsecutiveSamplesParameter { 66 get { return (IFixedValueParameter<PercentValue>)Parameters[ConsecutiveSamplesParameterName]; } 67 67 } 68 public IFixedValueParameter< IntValue> OverlapParameter {69 get { return (IFixedValueParameter< IntValue>)Parameters[OverlapParameterName]; }68 public IFixedValueParameter<PercentValue> OverlapParameter { 69 get { return (IFixedValueParameter<PercentValue>)Parameters[OverlapParameterName]; } 70 70 } 71 71 public IValueLookupParameter<IntValue> DataMigrationIntervalParameter { … … 86 86 #region properties 87 87 88 public intConsecutiveSamples {88 public double ConsecutiveSamples { 89 89 get { return ConsecutiveSamplesParameter.Value.Value; } 90 90 set { ConsecutiveSamplesParameter.Value.Value = value; } 91 91 } 92 92 93 public intOverlap {93 public double Overlap { 94 94 get { return OverlapParameter.Value.Value; } 95 95 set { OverlapParameter.Value.Value = value; } … … 113 113 Parameters.Add(new LookupParameter<IntRange>(FitnessCalculationPartitionParameterName, "The data partition used to calculate the fitness")); 114 114 Parameters.Add(new LookupParameter<IntRange>(FixedSamplesPartitionParameterName, "The data partition which is used to calculate the fitness on the fixed samples.")); 115 Parameters.Add(new FixedValueParameter< IntValue>(ConsecutiveSamplesParameterName, "The number of consecutive samples used for fitness calculation in each island.", new IntValue()));116 Parameters.Add(new FixedValueParameter< IntValue>(OverlapParameterName, "The overlap for the consecutive samples used for every island.", new IntValue()));115 Parameters.Add(new FixedValueParameter<PercentValue>(ConsecutiveSamplesParameterName, "The relative number of consecutive samples used for fitness calculation in each island.", new PercentValue())); 116 Parameters.Add(new FixedValueParameter<PercentValue>(OverlapParameterName, "The relative overlap for the consecutive samples used for every island.", new PercentValue())); 117 117 Parameters.Add(new ValueLookupParameter<IntValue>(DataMigrationIntervalParameterName, "The number of generations that should pass between data migration phases.")); 118 118 Parameters.Add(new LookupParameter<IntValue>(IslandIndexParameterName, "The index of the current island.")); … … 139 139 var islandIndex = IslandIndexParameter.ActualValue.Value; 140 140 var iteration = islandIndex + (generation / dataMigrationInterval); 141 var consecutiveRows = GenerateRows(samples, fixedSamples, ConsecutiveSamples, Overlap, iteration); 141 var consecutiveSamples = (int)ConsecutiveSamples * samples.Size; 142 var overlap = (int)Overlap * consecutiveSamples; 143 var consecutiveRows = GenerateRows(samples, fixedSamples, consecutiveSamples, overlap, iteration); 142 144 rows = rows.Concat(consecutiveRows); 143 145 } -
branches/DataAnalysis.IslandAlgorithms/HeuristicLab.Algorithms.DataAnalysis.Symbolic/3.3/RandomSamplesEvaluator .cs
r10230 r10353 68 68 get { return (IValueLookupParameter<IntValue>)Parameters[DataMigrationIntervalParameterName]; } 69 69 } 70 public IFixedValueParameter< IntValue> RandomSamplesParameter {71 get { return (IFixedValueParameter< IntValue>)Parameters[RandomSamplesParameterName]; }70 public IFixedValueParameter<PercentValue> RandomSamplesParameter { 71 get { return (IFixedValueParameter<PercentValue>)Parameters[RandomSamplesParameterName]; } 72 72 } 73 73 public ILookupParameter<IntValue> IterationsParameter { … … 81 81 #region properties 82 82 83 public intRandomSamples {83 public double RandomSamples { 84 84 get { return RandomSamplesParameter.Value.Value; } 85 85 set { RandomSamplesParameter.Value.Value = value; } … … 104 104 Parameters.Add(new LookupParameter<IntRange>(FitnessCalculationPartitionParameterName, "The data partition used to calculate the fitness")); 105 105 Parameters.Add(new LookupParameter<IntRange>(FixedSamplesPartitionParameterName, "The data partition which is used to calculate the fitness on the fixed samples.")); 106 Parameters.Add(new FixedValueParameter< IntValue>(RandomSamplesParameterName, "The number of random samples used for fitness calculation in each island.", new IntValue()));106 Parameters.Add(new FixedValueParameter<PercentValue>(RandomSamplesParameterName, "The number of random samples used for fitness calculation in each island.", new PercentValue())); 107 107 Parameters.Add(new ValueLookupParameter<IntValue>(DataMigrationIntervalParameterName, "The number of generations that should pass between data migration phases.")); 108 108 Parameters.Add(new LookupParameter<IntValue>(IterationsParameterName, "The number of performed iterations.")); … … 116 116 var samples = FitnessCalculationPartitionParameter.ActualValue; 117 117 var fixedSamples = FixedSamplesPartitionParameter.ActualValue; 118 var randomSamples = RandomSamples;118 var randomSamples = (int)RandomSamples * samples.Size; 119 119 120 120 var dataMigrationInterval = DataMigrationIntervalParameter.ActualValue.Value; -
branches/DataAnalysis.IslandAlgorithms/HeuristicLab.Algorithms.DataAnalysis.Symbolic/3.3/SymbolicDataAnalysisIslandGeneticAlgorithm.cs
r10230 r10353 56 56 57 57 #region parameters 58 public IFixedValueParameter< IntValue> FixedSamplesParameter {59 get { return (IFixedValueParameter< IntValue>)Parameters[FixedSamplesParameterName]; }58 public IFixedValueParameter<PercentValue> FixedSamplesParameter { 59 get { return (IFixedValueParameter<PercentValue>)Parameters[FixedSamplesParameterName]; } 60 60 } 61 61 public IValueParameter<ItemArray<IntRange>> FixedSamplesPartitionsParameter { … … 71 71 72 72 #region properties 73 public intFixedSamples {73 public double FixedSamples { 74 74 get { return FixedSamplesParameter.Value.Value; } 75 75 set { FixedSamplesParameter.Value.Value = value; } … … 97 97 public SymbolicDataAnalysisIslandGeneticAlgorithm() 98 98 : base() { 99 Parameters.Add(new FixedValueParameter< IntValue>(FixedSamplesParameterName, "The number of fixed samples used for fitness calculation in each island.", new IntValue(0)));99 Parameters.Add(new FixedValueParameter<PercentValue>(FixedSamplesParameterName, "The number of fixed samples used for fitness calculation in each island.", new PercentValue(0.2))); 100 100 Parameters.Add(new ValueParameter<ItemArray<IntRange>>(FixedSamplesPartitionsParameterName, "The fixed samples partitions used for fitness calculation for every island.")); 101 101 Parameters.Add(new OptionalValueParameter<ISymbolicDataAnalysisIslandGeneticAlgorithmEvaluator>(EvaluatorParameterName, "The evaluator of the algorithm.")); … … 174 174 } 175 175 176 protected override void Problem_Reset(object sender, EventArgs e) {177 FixedSamples = Problem.FitnessCalculationPartition.Size / NumberOfIslands.Value;178 base.Problem_Reset(sender, e);179 }180 181 176 protected override void OnProblemChanged() { 182 177 Problem.FitnessCalculationPartition.ValueChanged += Problem_Reset; 183 FixedSamples = Problem.FitnessCalculationPartition.Size / NumberOfIslands.Value;184 178 185 179 if (Problem != null && EvaluatorParameter.Value == null) { … … 201 195 var samplesEnd = Problem.FitnessCalculationPartition.End; 202 196 var totalSamples = Problem.FitnessCalculationPartition.Size; 203 var fixedSamples = FixedSamples;197 var fixedSamples = (int)(FixedSamples * totalSamples); 204 198 var islands = NumberOfIslands.Value; 205 199 206 int offset = (int)Math.Ceiling(((double)(totalSamples - fixedSamples)) / (islands - 1)); 200 double shift = (double)((totalSamples - fixedSamples)) / (islands - 1); 201 int offset = (int)Math.Floor(shift); 202 double remainder = shift - offset; 203 207 204 List<IntRange> partitions = new List<IntRange>(); 208 205 for (int i = 0; i < islands; i++) { 209 var partitionStart = samplesStart + offset * i ;206 var partitionStart = samplesStart + offset * i + (int)(remainder * i); 210 207 partitions.Add(new IntRange(partitionStart, partitionStart + fixedSamples)); 211 208 } 212 209 213 //it can be the case that the last partitions exceeds the allowed samples 214 //move the last partition forward. 210 //if the last partitions exceeds the allowed samples move the last partition forward. 215 211 int exceedsSamples = partitions[partitions.Count - 1].End - samplesEnd; 216 212 if (exceedsSamples > 0) { -
branches/DataAnalysis.IslandAlgorithms/HeuristicLab.Algorithms.DataAnalysis.Symbolic/3.3/SymbolicDataAnalysisIslandOffspringSelectionGeneticAlgorithm.cs
r10230 r10353 56 56 57 57 #region parameters 58 public IFixedValueParameter< IntValue> FixedSamplesParameter {59 get { return (IFixedValueParameter< IntValue>)Parameters[FixedSamplesParameterName]; }58 public IFixedValueParameter<PercentValue> FixedSamplesParameter { 59 get { return (IFixedValueParameter<PercentValue>)Parameters[FixedSamplesParameterName]; } 60 60 } 61 61 public IValueParameter<ItemArray<IntRange>> FixedSamplesPartitionsParameter { … … 71 71 72 72 #region properties 73 public intFixedSamples {73 public double FixedSamples { 74 74 get { return FixedSamplesParameter.Value.Value; } 75 75 set { FixedSamplesParameter.Value.Value = value; } … … 97 97 public SymbolicDataAnalysisIslandOffspringSelectionGeneticAlgorithm() 98 98 : base() { 99 Parameters.Add(new FixedValueParameter< IntValue>(FixedSamplesParameterName, "The number of fixed samples used for fitness calculation in each island.", new IntValue(0)));99 Parameters.Add(new FixedValueParameter<PercentValue>(FixedSamplesParameterName, "The number of fixed samples used for fitness calculation in each island.", new PercentValue(0.2))); 100 100 Parameters.Add(new ValueParameter<ItemArray<IntRange>>(FixedSamplesPartitionsParameterName, "The fixed samples partitions used for fitness calculation for every island.")); 101 101 Parameters.Add(new OptionalValueParameter<ISymbolicDataAnalysisIslandGeneticAlgorithmEvaluator>(EvaluatorParameterName, "The evaluator of the algorithm.")); … … 170 170 } 171 171 172 protected override void Problem_Reset(object sender, EventArgs e) {173 FixedSamples = Problem.FitnessCalculationPartition.Size / NumberOfIslands.Value;174 base.Problem_Reset(sender, e);175 }176 177 172 protected override void OnProblemChanged() { 178 173 Problem.FitnessCalculationPartition.ValueChanged += Problem_Reset; 179 FixedSamples = Problem.FitnessCalculationPartition.Size / NumberOfIslands.Value;180 174 181 175 if (Problem != null && EvaluatorParameter.Value == null) { … … 197 191 var samplesEnd = Problem.FitnessCalculationPartition.End; 198 192 var totalSamples = Problem.FitnessCalculationPartition.Size; 199 var fixedSamples = FixedSamples;193 var fixedSamples = (int)(FixedSamples * totalSamples); 200 194 var islands = NumberOfIslands.Value; 201 195 202 int offset = (int)Math.Ceiling(((double)(totalSamples - fixedSamples)) / (islands - 1)); 196 double shift = (double)((totalSamples - fixedSamples)) / (islands - 1); 197 int offset = (int)Math.Floor(shift); 198 double remainder = shift - offset; 199 203 200 List<IntRange> partitions = new List<IntRange>(); 204 201 for (int i = 0; i < islands; i++) { 205 var partitionStart = samplesStart + offset * i ;202 var partitionStart = samplesStart + offset * i + (int)(remainder * i); 206 203 partitions.Add(new IntRange(partitionStart, partitionStart + fixedSamples)); 207 204 }
Note: See TracChangeset
for help on using the changeset viewer.