- Timestamp:
- 11/26/13 15:32:09 (11 years ago)
- Location:
- branches/DataAnalysis.IslandAlgorithms/HeuristicLab.Algorithms.DataAnalysis.Symbolic/3.3
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataAnalysis.IslandAlgorithms/HeuristicLab.Algorithms.DataAnalysis.Symbolic/3.3/SymbolicDataAnalysisIslandGAEvaluator.cs
r10152 r10156 34 34 namespace HeuristicLab.Algorithms.DataAnalysis.Symbolic { 35 35 [StorableClass] 36 public sealed class SymbolicDataAnalysisIslandGAEvaluator<T> : SingleSuccessorOperator, IStochasticOperator, ISymbolicDataAnalysisIslandGAEvaluator 37 where T : class,IDataAnalysisProblemData { 36 public sealed class SymbolicDataAnalysisIslandGAEvaluator : SingleSuccessorOperator, IStochasticOperator, ISymbolicDataAnalysisIslandGAEvaluator { 38 37 private const string RandomParameterName = "Random"; 39 38 private const string ProblemDataParameterName = "ProblemData"; … … 48 47 get { return (ILookupParameter<IRandom>)Parameters[RandomParameterName]; } 49 48 } 50 public ILookupParameter< T> ProblemDataParameter {51 get { return (ILookupParameter< T>)Parameters[ProblemDataParameterName]; }49 public ILookupParameter<IDataAnalysisProblemData> ProblemDataParameter { 50 get { return (ILookupParameter<IDataAnalysisProblemData>)Parameters[ProblemDataParameterName]; } 52 51 } 53 public ILookupParameter<I SymbolicDataAnalysisSingleObjectiveEvaluator<T>> EvaluatorParameter {54 get { return (ILookupParameter<I SymbolicDataAnalysisSingleObjectiveEvaluator<T>>)Parameters[EvaluatorParameterName]; }52 public ILookupParameter<IOperator> EvaluatorParameter { 53 get { return (ILookupParameter<IOperator>)Parameters[EvaluatorParameterName]; } 55 54 } 56 55 public ILookupParameter<DoubleValue> QualityParameter { … … 68 67 #endregion 69 68 70 71 69 [StorableConstructor] 72 70 private SymbolicDataAnalysisIslandGAEvaluator(bool deserializing) : base(deserializing) { } 73 private SymbolicDataAnalysisIslandGAEvaluator(SymbolicDataAnalysisIslandGAEvaluator <T>original, Cloner cloner)71 private SymbolicDataAnalysisIslandGAEvaluator(SymbolicDataAnalysisIslandGAEvaluator original, Cloner cloner) 74 72 : base(original, cloner) { 75 73 } 76 74 public override IDeepCloneable Clone(Cloner cloner) { 77 return new SymbolicDataAnalysisIslandGAEvaluator <T>(this, cloner);75 return new SymbolicDataAnalysisIslandGAEvaluator(this, cloner); 78 76 } 79 77 … … 81 79 : base() { 82 80 Parameters.Add(new LookupParameter<IRandom>(RandomParameterName, "The random generator to use.")); 83 Parameters.Add(new LookupParameter< T>(ProblemDataParameterName, "The problem data on which the symbolic data analysis solution should be evaluated."));84 Parameters.Add(new LookupParameter<I SymbolicDataAnalysisSingleObjectiveEvaluator<T>>(EvaluatorParameterName, "The evaluator provided by the symbolic data analysis problem."));81 Parameters.Add(new LookupParameter<IDataAnalysisProblemData>(ProblemDataParameterName, "The problem data on which the symbolic data analysis solution should be evaluated.")); 82 Parameters.Add(new LookupParameter<IOperator>(EvaluatorParameterName, "The evaluator provided by the symbolic data analysis problem.")); 85 83 Parameters.Add(new LookupParameter<DoubleValue>(QualityParameterName, "The quality which is calculated by the encapsulated evaluator.")); 86 84 Parameters.Add(new ValueLookupParameter<IntRange>(FitnessCalculationPartitionParameterName, "The data partition used to calculate the fitness")); -
branches/DataAnalysis.IslandAlgorithms/HeuristicLab.Algorithms.DataAnalysis.Symbolic/3.3/SymbolicDataAnalysisIslandGeneticAlgorithm.cs
r10142 r10156 30 30 using HeuristicLab.Parameters; 31 31 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 32 using HeuristicLab.Problems.DataAnalysis;33 32 using HeuristicLab.Problems.DataAnalysis.Symbolic; 34 33 using HeuristicLab.Random; … … 128 127 NumberOfIslandsParameter.ValueChanged += NumberOfIslandsParameter_ValueChanged; 129 128 NumberOfIslandsParameter.Value.ValueChanged += (o, ev) => RecalculateFixedSamplesPartitions(); 130 FixedSamplesParameter.Value.ValueChanged += (o, e) => RecalculateFixedSamplesPartitions(); 129 FixedSamplesParameter.Value.ValueChanged += (o, e) => { 130 RecalculateFixedSamplesPartitions(); 131 ReevaluateImmigrants = FixedSamples >= Problem.FitnessCalculationPartition.Size; 132 }; 131 133 RandomSamplesParameter.Value.ValueChanged += (o, e) => { ReevaluteElites = RandomSamples != 0; }; 132 134 Analyzer.Operators.PropertyChanged += (o, e) => ParameterizeAnalyzers(); 135 EvaluatorParameter.ValueChanged += (o, e) => ParameterizeEvaluator(); 133 136 } 134 137 … … 155 158 } 156 159 160 private void ParameterizeEvaluator() { 161 var evaluator = EvaluatorParameter.Value; 162 var islandGAEvaluator = evaluator as SymbolicDataAnalysisIslandGAEvaluator; 163 if (islandGAEvaluator != null) { 164 islandGAEvaluator.RandomSamplesParameter.ActualName = RandomSamplesParameterName; 165 } 166 } 167 157 168 private void NumberOfIslandsParameter_ValueChanged(object sender, EventArgs e) { 158 169 NumberOfIslands.ValueChanged += (o, ev) => RecalculateFixedSamplesPartitions(); … … 162 173 protected override void Problem_Reset(object sender, EventArgs e) { 163 174 FixedSamples = Problem.FitnessCalculationPartition.Size / NumberOfIslands.Value; 164 RandomSamples = Problem.FitnessCalculationPartition.Size / NumberOfIslands.Value;165 RecalculateFixedSamplesPartitions();166 175 base.Problem_Reset(sender, e); 167 176 } … … 170 179 Problem.FitnessCalculationPartition.ValueChanged += Problem_Reset; 171 180 FixedSamples = Problem.FitnessCalculationPartition.Size / NumberOfIslands.Value; 172 RandomSamples = Problem.FitnessCalculationPartition.Size / NumberOfIslands.Value; 173 174 if (Problem is IRegressionProblem) { 175 var evaluator = new SymbolicDataAnalysisIslandGAEvaluator<IRegressionProblemData>(); 176 evaluator.RandomSamplesParameter.ActualName = RandomSamplesParameterName; 177 EvaluatorParameter.Value = evaluator; 178 } else if (Problem is IClassificationProblem) { 179 var evaluator = new SymbolicDataAnalysisIslandGAEvaluator<IClassificationProblemData>(); 180 evaluator.RandomSamplesParameter.ActualName = RandomSamplesParameterName; 181 EvaluatorParameter.Value = evaluator; 182 } else 181 182 if (Problem != null && EvaluatorParameter.Value == null) { 183 EvaluatorParameter.Value = new SymbolicDataAnalysisIslandGAEvaluator(); 184 } else if (Problem == null) 183 185 EvaluatorParameter.Value = null; 184 186 185 ParameterizeStochasticOperatorForIsland(EvaluatorParameter.Value); 186 187 ParameterizeStochasticOperator(EvaluatorParameter.Value); 187 188 RecalculateFixedSamplesPartitions(); 188 189 base.OnProblemChanged(); -
branches/DataAnalysis.IslandAlgorithms/HeuristicLab.Algorithms.DataAnalysis.Symbolic/3.3/SymbolicDataAnalysisIslandOffspringSelectionGeneticAlgorithm.cs
r10152 r10156 31 31 using HeuristicLab.Parameters; 32 32 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 33 using HeuristicLab.Problems.DataAnalysis;34 33 using HeuristicLab.Problems.DataAnalysis.Symbolic; 35 34 … … 128 127 NumberOfIslandsParameter.ValueChanged += NumberOfIslandsParameter_ValueChanged; 129 128 NumberOfIslandsParameter.Value.ValueChanged += (o, ev) => RecalculateFixedSamplesPartitions(); 130 FixedSamplesParameter.Value.ValueChanged += (o, e) => RecalculateFixedSamplesPartitions(); 129 FixedSamplesParameter.Value.ValueChanged += (o, e) => { 130 RecalculateFixedSamplesPartitions(); 131 ReevaluateImmigrants = FixedSamples >= Problem.FitnessCalculationPartition.Size; 132 }; 131 133 RandomSamplesParameter.Value.ValueChanged += (o, e) => { ReevaluteElites = RandomSamples != 0; }; 132 134 Analyzer.Operators.PropertyChanged += (o, e) => ParameterizeAnalyzers(); 135 EvaluatorParameter.ValueChanged += (o, e) => ParameterizeEvaluator(); 133 136 } 134 137 … … 155 158 } 156 159 160 private void ParameterizeEvaluator() { 161 var evaluator = EvaluatorParameter.Value; 162 var islandGAEvaluator = evaluator as SymbolicDataAnalysisIslandGAEvaluator; 163 if (islandGAEvaluator != null) { 164 islandGAEvaluator.RandomSamplesParameter.ActualName = RandomSamplesParameterName; 165 } 166 } 167 157 168 private void NumberOfIslandsParameter_ValueChanged(object sender, EventArgs e) { 158 169 NumberOfIslands.ValueChanged += (o, ev) => RecalculateFixedSamplesPartitions(); … … 162 173 protected override void Problem_Reset(object sender, EventArgs e) { 163 174 FixedSamples = Problem.FitnessCalculationPartition.Size / NumberOfIslands.Value; 164 RandomSamples = Problem.FitnessCalculationPartition.Size / NumberOfIslands.Value;165 RecalculateFixedSamplesPartitions();166 175 base.Problem_Reset(sender, e); 167 176 } … … 170 179 Problem.FitnessCalculationPartition.ValueChanged += Problem_Reset; 171 180 FixedSamples = Problem.FitnessCalculationPartition.Size / NumberOfIslands.Value; 172 RandomSamples = Problem.FitnessCalculationPartition.Size / NumberOfIslands.Value; 173 174 if (Problem is IRegressionProblem) { 175 var evaluator = new SymbolicDataAnalysisIslandGAEvaluator<IRegressionProblemData>(); 176 evaluator.RandomSamplesParameter.ActualName = RandomSamplesParameterName; 177 EvaluatorParameter.Value = evaluator; 178 } else if (Problem is IClassificationProblem) { 179 var evaluator = new SymbolicDataAnalysisIslandGAEvaluator<IClassificationProblemData>(); 180 evaluator.RandomSamplesParameter.ActualName = RandomSamplesParameterName; 181 EvaluatorParameter.Value = evaluator; 182 } else 181 182 if (Problem != null && EvaluatorParameter.Value == null) { 183 EvaluatorParameter.Value = new SymbolicDataAnalysisIslandGAEvaluator(); 184 } else if (Problem == null) 183 185 EvaluatorParameter.Value = null; 184 186
Note: See TracChangeset
for help on using the changeset viewer.