Changeset 10177 for branches/DataAnalysis.IslandAlgorithms/HeuristicLab.Algorithms.DataAnalysis.Symbolic/3.3/SymbolicDataAnalysisIslandGeneticAlgorithm.cs
- Timestamp:
- 12/03/13 14:52:41 (11 years ago)
- Location:
- branches/DataAnalysis.IslandAlgorithms
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataAnalysis.IslandAlgorithms
- Property svn:ignore
-
old new 1 1 *.suo 2 bin
-
- Property svn:ignore
-
branches/DataAnalysis.IslandAlgorithms/HeuristicLab.Algorithms.DataAnalysis.Symbolic/3.3
- Property svn:ignore
-
old new 1 *.user 1 2 Plugin.cs 2 3 bin
-
- Property svn:ignore
-
branches/DataAnalysis.IslandAlgorithms/HeuristicLab.Algorithms.DataAnalysis.Symbolic/3.3/SymbolicDataAnalysisIslandGeneticAlgorithm.cs
r10156 r10177 27 27 using HeuristicLab.Core; 28 28 using HeuristicLab.Data; 29 using HeuristicLab.Operators; 29 30 using HeuristicLab.Optimization; 30 31 using HeuristicLab.Parameters; 31 32 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 32 33 using HeuristicLab.Problems.DataAnalysis.Symbolic; 33 using HeuristicLab.Random;34 34 35 35 namespace HeuristicLab.Algorithms.DataAnalysis.Symbolic { … … 41 41 private const string FixedSamplesPartitionParameterName = "FixedSamplesPartition"; 42 42 private const string FixedSamplesPartitionsParameterName = "FixedSamplesPartitions"; 43 private const string RandomSamplesParameterName = "NumberOfRandomSamples";44 43 private const string EvaluatorParameterName = "IslandEvaluator"; 44 private const string IslandIndexParameterName = "IslandIndex"; 45 45 private const string ProblemEvaluatorParameterName = "ProblemEvaluator"; 46 46 … … 62 62 get { return (IValueParameter<ItemArray<IntRange>>)Parameters[FixedSamplesPartitionsParameterName]; } 63 63 } 64 public IFixedValueParameter<IntValue> RandomSamplesParameter { 65 get { return (IFixedValueParameter<IntValue>)Parameters[RandomSamplesParameterName]; } 66 } 67 public IValueParameter<ISymbolicDataAnalysisIslandGAEvaluator> EvaluatorParameter { 68 get { return (IValueParameter<ISymbolicDataAnalysisIslandGAEvaluator>)Parameters[EvaluatorParameterName]; } 64 public IValueParameter<ISymbolicDataAnalysisIslandGeneticAlgorithmEvaluator> EvaluatorParameter { 65 get { return (IValueParameter<ISymbolicDataAnalysisIslandGeneticAlgorithmEvaluator>)Parameters[EvaluatorParameterName]; } 69 66 } 70 67 private ILookupParameter<ISingleObjectiveEvaluator> ProblemEvaluatorParameter { … … 81 78 get { return FixedSamplesPartitionsParameter.Value; } 82 79 set { FixedSamplesPartitionsParameter.Value = value; } 83 }84 public int RandomSamples {85 get { return RandomSamplesParameter.Value.Value; }86 set { RandomSamplesParameter.Value.Value = value; }87 80 } 88 81 #endregion … … 106 99 Parameters.Add(new FixedValueParameter<IntValue>(FixedSamplesParameterName, "The number of fixed samples used for fitness calculation in each island.", new IntValue(0))); 107 100 Parameters.Add(new ValueParameter<ItemArray<IntRange>>(FixedSamplesPartitionsParameterName, "The fixed samples partitions used for fitness calculation for every island.")); 108 Parameters.Add(new FixedValueParameter<IntValue>(RandomSamplesParameterName, "The number of random samples used for fitness calculation in each island.", new IntValue(0))); 109 Parameters.Add(new OptionalValueParameter<ISymbolicDataAnalysisIslandGAEvaluator>(EvaluatorParameterName, "The evaluator of the algorithm.")); 101 Parameters.Add(new OptionalValueParameter<ISymbolicDataAnalysisIslandGeneticAlgorithmEvaluator>(EvaluatorParameterName, "The evaluator of the algorithm.")); 110 102 Parameters.Add(new LookupParameter<ISingleObjectiveEvaluator>(ProblemEvaluatorParameterName, "Internal parameter for name translation", "Evaluator")); 103 104 ScopeTreeAssigner<IntValue> islandIndexAssigner = new ScopeTreeAssigner<IntValue>(); 105 islandIndexAssigner.Name = "Insert island index"; 106 islandIndexAssigner.LeftSideParameter.ActualName = IslandIndexParameterName; 107 var readonlyIslandIndexes = Enumerable.Range(0, NumberOfIslands.Value).Select(x => (IntValue)new IntValue(x).AsReadOnly()); 108 islandIndexAssigner.RightSideParameter.Value = new ItemArray<IntValue>(readonlyIslandIndexes); 111 109 112 110 ScopeTreeAssigner<IntRange> fixedSamplesPartitionCreator = new ScopeTreeAssigner<IntRange>(); … … 115 113 fixedSamplesPartitionCreator.RightSideParameter.ActualName = FixedSamplesPartitionsParameterName; 116 114 117 RandomCreator insertionPoint = OperatorGraph.Iterate().OfType<RandomCreator>().Skip(1).First(); 115 SubScopesCreator insertionPoint = OperatorGraph.Iterate().OfType<SubScopesCreator>().First(); 116 islandIndexAssigner.Successor = fixedSamplesPartitionCreator; 118 117 fixedSamplesPartitionCreator.Successor = insertionPoint.Successor; 119 insertionPoint.Successor = fixedSamplesPartitionCreator; 118 insertionPoint.Successor = islandIndexAssigner; 119 120 //RandomCreator insertionPoint = OperatorGraph.Iterate().OfType<RandomCreator>().Skip(1).First(); 121 //fixedSamplesPartitionCreator.Successor = insertionPoint.Successor; 122 //insertionPoint.Successor = fixedSamplesPartitionCreator; 120 123 121 124 RegisterParameterEvents(); … … 131 134 ReevaluateImmigrants = FixedSamples >= Problem.FitnessCalculationPartition.Size; 132 135 }; 133 RandomSamplesParameter.Value.ValueChanged += (o, e) => { ReevaluteElites = RandomSamples != 0; };134 136 Analyzer.Operators.PropertyChanged += (o, e) => ParameterizeAnalyzers(); 135 137 EvaluatorParameter.ValueChanged += (o, e) => ParameterizeEvaluator(); … … 160 162 private void ParameterizeEvaluator() { 161 163 var evaluator = EvaluatorParameter.Value; 162 var islandGAEvaluator = evaluator as SymbolicDataAnalysisIslandGAEvaluator; 163 if (islandGAEvaluator != null) { 164 islandGAEvaluator.RandomSamplesParameter.ActualName = RandomSamplesParameterName; 164 165 var randomEvaluator = evaluator as RandomSamplesEvaluator; 166 if (randomEvaluator != null) { 167 ReevaluteElites = randomEvaluator.RandomSamples != 0; 168 } 169 170 var consecutiveEvaluator = evaluator as ConsecutiveSamplesEvaluator; 171 if (consecutiveEvaluator != null) { 172 consecutiveEvaluator.DataMigrationIntervalParameter.ActualName = MigrationIntervalParameter.Name; 165 173 } 166 174 } … … 181 189 182 190 if (Problem != null && EvaluatorParameter.Value == null) { 183 EvaluatorParameter.Value = new SymbolicDataAnalysisIslandGAEvaluator();191 EvaluatorParameter.Value = new RandomSamplesEvaluator(); 184 192 } else if (Problem == null) 185 193 EvaluatorParameter.Value = null;
Note: See TracChangeset
for help on using the changeset viewer.