Changeset 12891 for branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Crossovers
- Timestamp:
- 08/22/15 14:27:37 (9 years ago)
- Location:
- branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic
- Property svn:mergeinfo changed
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Crossovers/MultiSymbolicDataAnalysisExpressionCrossover.cs
r12155 r12891 35 35 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { 36 36 [Item("MultiSymbolicDataAnalysisExpressionCrossover", "Randomly selects and applies one of its crossovers every time it is called.")] 37 [StorableClass] 37 38 public class MultiSymbolicDataAnalysisExpressionCrossover<T> : StochasticMultiBranch<ISymbolicExpressionTreeCrossover>, 38 39 ISymbolicDataAnalysisExpressionCrossover<T> where T : class, IDataAnalysisProblemData { 39 40 private const string ParentsParameterName = "Parents"; 40 private const string ChildParameterName = "Child";41 private const string SymbolicExpressionTreeParameterName = "SymbolicExpressionTree"; 41 42 private const string MaximumSymbolicExpressionTreeLengthParameterName = "MaximumSymbolicExpressionTreeLength"; 42 43 private const string MaximumSymbolicExpressionTreeDepthParameterName = "MaximumSymbolicExpressionTreeDepth"; … … 62 63 get { return (ScopeTreeLookupParameter<ISymbolicExpressionTree>)Parameters[ParentsParameterName]; } 63 64 } 64 public ILookupParameter<ISymbolicExpressionTree> ChildParameter {65 get { return (ILookupParameter<ISymbolicExpressionTree>)Parameters[ ChildParameterName]; }65 public ILookupParameter<ISymbolicExpressionTree> SymbolicExpressionTreeParameter { 66 get { return (ILookupParameter<ISymbolicExpressionTree>)Parameters[SymbolicExpressionTreeParameterName]; } 66 67 } 67 68 public IValueLookupParameter<IntValue> MaximumSymbolicExpressionTreeLengthParameter { … … 99 100 Parameters.Add(new ValueLookupParameter<IntRange>(SymbolicDataAnalysisEvaluationPartitionParameterName, "The start index of the dataset partition on which the symbolic data analysis solution should be evaluated.")); 100 101 Parameters.Add(new ScopeTreeLookupParameter<ISymbolicExpressionTree>(ParentsParameterName, "The parent symbolic expression trees which should be crossed.")); 101 Parameters.Add(new LookupParameter<ISymbolicExpressionTree>( ChildParameterName, "The child symbolic expression tree resulting from the crossover."));102 Parameters.Add(new LookupParameter<ISymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The child symbolic expression tree resulting from the crossover.")); 102 103 103 104 EvaluatorParameter.Hidden = true; … … 111 112 112 113 SelectedOperatorParameter.ActualName = "SelectedCrossoverOperator"; 114 } 115 116 [StorableHook(HookType.AfterDeserialization)] 117 private void AfterDeserialization() { 118 // BackwardsCompatibility3.3 119 #region Backwards compatible code, remove with 3.4 120 if (!Parameters.ContainsKey(SymbolicExpressionTreeParameterName)) 121 Parameters.Add(new LookupParameter<ISymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic expression tree on which the operator should be applied.")); 122 #endregion 113 123 } 114 124 … … 155 165 private void ParameterizeCrossovers() { 156 166 foreach (ISymbolicExpressionTreeCrossover op in Operators) { 157 op. ChildParameter.ActualName = ChildParameter.Name;167 op.SymbolicExpressionTreeParameter.ActualName = SymbolicExpressionTreeParameter.Name; 158 168 op.ParentsParameter.ActualName = ParentsParameter.Name; 159 169 } -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Crossovers/SymbolicDataAnalysisExpressionContextAwareCrossover.cs
r12155 r12891 27 27 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 28 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 using HeuristicLab.Random; 29 30 30 31 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { … … 68 69 possibleChildren.Add(n); 69 70 }); 70 var selectedChild = possibleChildren.SelectRandom(random); 71 72 var selectedChild = possibleChildren.SampleRandom(random); 71 73 var crossoverPoints = new List<CutPoint>(); 72 74 var qualities = new List<Tuple<CutPoint, double>>(); -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Crossovers/SymbolicDataAnalysisExpressionDepthConstrainedCrossover.cs
r12155 r12891 29 29 using HeuristicLab.Parameters; 30 30 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 31 using HeuristicLab.Random; 31 32 32 33 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { … … 115 116 throw new Exception("No crossover points available in the first parent"); 116 117 117 var crossoverPoint0 = crossoverPoints0.SelectRandom(random); 118 118 var crossoverPoint0 = crossoverPoints0.SampleRandom(random); 119 119 int level = parent0.Root.GetBranchLevel(crossoverPoint0.Child); 120 120 int length = parent0.Root.GetLength() - crossoverPoint0.Child.GetLength(); … … 126 126 select s).ToList(); 127 127 if (allowedBranches.Count == 0) return parent0; 128 var selectedBranch = allowedBranches.SelectRandom(random); 128 129 var selectedBranch = allowedBranches.SampleRandom(random); 129 130 Swap(crossoverPoint0, selectedBranch); 130 131 return parent0; -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Crossovers/SymbolicDataAnalysisExpressionDeterministicBestCrossover.cs
r12155 r12891 27 27 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 28 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 using HeuristicLab.Random; 29 30 30 31 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { … … 67 68 crossoverPoints0.Add(new CutPoint(n.Parent, n)); 68 69 }); 69 CutPoint crossoverPoint0 = crossoverPoints0.SelectRandom(random); 70 71 CutPoint crossoverPoint0 = crossoverPoints0.SampleRandom(random); 70 72 int level = parent0.Root.GetBranchLevel(crossoverPoint0.Child); 71 73 int length = parent0.Root.GetLength() - crossoverPoint0.Child.GetLength(); -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Crossovers/SymbolicDataAnalysisExpressionProbabilisticFunctionalCrossover.cs
r12155 r12891 27 27 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 28 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 using HeuristicLab.Random; 29 30 30 31 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { … … 69 70 } 70 71 }); 71 var crossoverPoint0 = crossoverPoints0.SelectRandom(random); 72 73 var crossoverPoint0 = crossoverPoints0.SampleRandom(random); 72 74 int level = parent0.Root.GetBranchLevel(crossoverPoint0.Child); 73 75 int length = parent0.Root.GetLength() - crossoverPoint0.Child.GetLength(); … … 137 139 weights[i] /= sum; 138 140 141 #pragma warning disable 612, 618 139 142 selectedBranch = allowedBranches.SelectRandom(weights, random); 143 #pragma warning restore 612, 618 140 144 } 141 145 Swap(crossoverPoint0, selectedBranch); -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Crossovers/SymbolicDataAnalysisExpressionSemanticSimilarityCrossover.cs
r12155 r12891 28 28 using HeuristicLab.Parameters; 29 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 30 using HeuristicLab.Random; 30 31 31 32 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { … … 81 82 crossoverPoints0.Add(new CutPoint(n.Parent, n)); 82 83 }); 83 var crossoverPoint0 = crossoverPoints0.SelectRandom(random); 84 85 var crossoverPoint0 = crossoverPoints0.SampleRandom(random); 84 86 int level = parent0.Root.GetBranchLevel(crossoverPoint0.Child); 85 87 int length = parent0.Root.GetLength() - crossoverPoint0.Child.GetLength();
Note: See TracChangeset
for help on using the changeset viewer.