Changeset 7481
- Timestamp:
- 02/17/12 14:25:51 (13 years ago)
- Location:
- branches/HeuristicLab.Crossovers
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Crossovers/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Crossovers/SubtreeCrossover.cs
r7477 r7481 28 28 using HeuristicLab.Parameters; 29 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 30 using HeuristicLab.PluginInfrastructure;31 30 32 31 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding { … … 37 36 /// until a valid configuration is found. 38 37 /// </summary> 39 [Item("SubtreeCrossover", "An operator which performs subtree swapping crossover.")] 40 [NonDiscoverableType] 38 [Item("SubtreeSwappingCrossover", "An operator which performs subtree swapping crossover.")] 41 39 [StorableClass] 42 40 public class SubtreeCrossover : SymbolicExpressionTreeCrossover, ISymbolicExpressionTreeSizeConstraintOperator { … … 44 42 private const string MaximumSymbolicExpressionTreeLengthParameterName = "MaximumSymbolicExpressionTreeLength"; 45 43 private const string MaximumSymbolicExpressionTreeDepthParameterName = "MaximumSymbolicExpressionTreeDepth"; 46 private const string SymbolicDataAnalysisEvaluationPartitionParameterName = "EvaluationPartition";47 44 48 45 #region Parameter Properties … … 55 52 public IValueLookupParameter<IntValue> MaximumSymbolicExpressionTreeDepthParameter { 56 53 get { return (IValueLookupParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeDepthParameterName]; } 57 }58 public IValueLookupParameter<IntRange> SymbolicDataAnalysisEvaluationPartitionParameter {59 get { return (IValueLookupParameter<IntRange>)Parameters[SymbolicDataAnalysisEvaluationPartitionParameterName]; }60 54 } 61 55 #endregion … … 79 73 Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeDepthParameterName, "The maximal depth of the symbolic expression tree (a tree with one node has depth = 0).")); 80 74 Parameters.Add(new ValueLookupParameter<PercentValue>(InternalCrossoverPointProbabilityParameterName, "The probability to select an internal crossover point (instead of a leaf node).", new PercentValue(0.9))); 81 Parameters.Add(new ValueLookupParameter<IntRange>(SymbolicDataAnalysisEvaluationPartitionParameterName, "The start index of the dataset partition on which the symbolic data analysis solution should be evaluated."));82 75 } 83 76 … … 86 79 } 87 80 88 p rotected override ISymbolicExpressionTree Cross(IRandom random,81 public override ISymbolicExpressionTree Crossover(IRandom random, 89 82 ISymbolicExpressionTree parent0, ISymbolicExpressionTree parent1) { 90 83 return Cross(random, parent0, parent1, InternalCrossoverPointProbability.Value, 91 84 MaximumSymbolicExpressionTreeLength.Value, MaximumSymbolicExpressionTreeDepth.Value); 92 }93 94 public ISymbolicExpressionTree Crossover(IRandom random, ISymbolicExpressionTree parent0, ISymbolicExpressionTree parent1) {95 return Cross(random, parent0, parent1);96 85 } 97 86 -
branches/HeuristicLab.Crossovers/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Crossovers/SymbolicExpressionTreeCrossover.cs
r7259 r7481 23 23 using HeuristicLab.Common; 24 24 using HeuristicLab.Core; 25 using HeuristicLab.Data;26 25 using HeuristicLab.Parameters; 27 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 66 65 throw new ArgumentException("Number of parents must be exactly two for symbolic expression tree crossover operators."); 67 66 68 ISymbolicExpressionTree result = Cross (Random, Parents[0], Parents[1]);67 ISymbolicExpressionTree result = Crossover(Random, Parents[0], Parents[1]); 69 68 70 69 Child = result; … … 72 71 } 73 72 74 protected abstract ISymbolicExpressionTree Cross(IRandom random, 75 ISymbolicExpressionTree parent0, ISymbolicExpressionTree parent1); 73 public abstract ISymbolicExpressionTree Crossover(IRandom random, ISymbolicExpressionTree parent0, ISymbolicExpressionTree parent1); 76 74 } 77 75 } -
branches/HeuristicLab.Crossovers/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/Operators/ISymbolicExpressionTreeCrossover.cs
r7259 r7481 30 30 ILookupParameter<ItemArray<ISymbolicExpressionTree>> ParentsParameter { get; } 31 31 ILookupParameter<ISymbolicExpressionTree> ChildParameter { get; } 32 ISymbolicExpressionTree Crossover(IRandom random, ISymbolicExpressionTree parent0, ISymbolicExpressionTree parent1); 32 33 } 33 34 } -
branches/HeuristicLab.Crossovers/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Crossovers/MultiSymbolicDataAnalysisExpressionCrossover.cs
r7476 r7481 21 21 22 22 using System; 23 using System.Collections.Generic;24 23 using System.Linq; 25 24 using HeuristicLab.Collections; … … 35 34 36 35 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Crossovers { 37 public class MultiSymbolicDataAnalysisExpressionCrossover<T> : StochasticMultiBranch<ISymbolicDataAnalysisExpressionCrossover<T>>, 36 [Item("MultiSymbolicDataAnalysisExpressionCrossover", "Randomly selects and applies one of its crossovers every time it is called.")] 37 public class MultiSymbolicDataAnalysisExpressionCrossover<T> : StochasticMultiBranch<ISymbolicExpressionTreeCrossover>, 38 38 ISymbolicDataAnalysisExpressionCrossover<T>, 39 39 ISymbolicExpressionTreeSizeConstraintOperator, … … 97 97 Parameters.Add(new LookupParameter<ISymbolicExpressionTree>(ChildParameterName, "The child symbolic expression tree resulting from the crossover.")); 98 98 99 var list = (from type in ApplicationManager.Manager.GetTypes(typeof(ISymbolicDataAnalysisExpressionCrossover<T>)) 100 where this.GetType().Assembly == type.Assembly 101 where !typeof(IMultiOperator<ISymbolicDataAnalysisExpressionCrossover<T>>).IsAssignableFrom(type) 102 select (ISymbolicDataAnalysisExpressionCrossover<T>)Activator.CreateInstance(type)).ToList(); 99 var list = ApplicationManager.Manager.GetInstances<ISymbolicExpressionTreeCrossover>().ToList(); 100 var dataAnalysisCrossovers = from type in ApplicationManager.Manager.GetTypes(typeof(ISymbolicDataAnalysisExpressionCrossover<T>)) 101 where this.GetType().Assembly == type.Assembly 102 where !typeof(IMultiOperator<ISymbolicExpressionTreeCrossover>).IsAssignableFrom(type) 103 select (ISymbolicDataAnalysisExpressionCrossover<T>)Activator.CreateInstance(type); 104 list.AddRange(dataAnalysisCrossovers); 103 105 104 var checkedItemList = new CheckedItemList<ISymbolic DataAnalysisExpressionCrossover<T>>();106 var checkedItemList = new CheckedItemList<ISymbolicExpressionTreeCrossover>(); 105 107 checkedItemList.AddRange(list.OrderBy(op => op.Name)); 106 108 Operators = checkedItemList.AsReadOnly(); 107 Operators_ItemsAdded(this, new CollectionItemsChangedEventArgs<IndexedItem<ISymbolicDataAnalysisExpressionCrossover<T>>>(Operators.CheckedItems)); 108 Name = "MultiCrossover"; 109 Operators_ItemsAdded(this, new CollectionItemsChangedEventArgs<IndexedItem<ISymbolicExpressionTreeCrossover>>(Operators.CheckedItems)); 109 110 } 110 111 … … 137 138 } 138 139 139 protected override void Operators_ItemsReplaced(object sender, CollectionItemsChangedEventArgs<IndexedItem<ISymbolic DataAnalysisExpressionCrossover<T>>> e) {140 protected override void Operators_ItemsReplaced(object sender, CollectionItemsChangedEventArgs<IndexedItem<ISymbolicExpressionTreeCrossover>> e) { 140 141 base.Operators_ItemsReplaced(sender, e); 141 142 ParameterizeCrossovers(); 142 143 } 143 144 144 protected override void Operators_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<ISymbolic DataAnalysisExpressionCrossover<T>>> e) {145 protected override void Operators_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<ISymbolicExpressionTreeCrossover>> e) { 145 146 base.Operators_ItemsAdded(sender, e); 146 147 ParameterizeCrossovers(); -
branches/HeuristicLab.Crossovers/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Crossovers/SymbolicDataAnalysisExpressionContextAwareCrossover.cs
r7476 r7481 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;26 25 using HeuristicLab.Common; 27 26 using HeuristicLab.Core; 28 27 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 29 30 30 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { … … 44 44 return new SymbolicDataAnalysisExpressionContextAwareCrossover<T>(this, cloner); 45 45 } 46 p rotected override ISymbolicExpressionTree Cross(IRandom random, ISymbolicExpressionTree parent0, ISymbolicExpressionTree parent1) {46 public override ISymbolicExpressionTree Crossover(IRandom random, ISymbolicExpressionTree parent0, ISymbolicExpressionTree parent1) { 47 47 if (this.ExecutionContext == null) 48 48 throw new InvalidOperationException("ExecutionContext not set."); … … 52 52 53 53 return Cross(random, parent0, parent1, this.ExecutionContext, evaluator, problemData, rows, MaximumSymbolicExpressionTreeDepth.Value, MaximumSymbolicExpressionTreeLength.Value); 54 }55 56 public override ISymbolicExpressionTree Crossover(IRandom random, ISymbolicExpressionTree parent0, ISymbolicExpressionTree parent1) {57 return Cross(random, parent0, parent1);58 54 } 59 55 -
branches/HeuristicLab.Crossovers/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Crossovers/SymbolicDataAnalysisExpressionCrossover.cs
r7476 r7481 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using System.Text;25 using HeuristicLab.Common; 26 26 using HeuristicLab.Core; 27 using HeuristicLab.Data; 27 28 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 28 using HeuristicLab.Data;29 29 using HeuristicLab.Parameters; 30 30 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 31 using HeuristicLab.Common;32 31 using HeuristicLab.Random; 33 32 … … 150 149 return rows.Where(i => i < testPartitionStart || testPartitionEnd <= i); 151 150 } 152 153 protected abstract override ISymbolicExpressionTree Cross(IRandom random, ISymbolicExpressionTree parent0, ISymbolicExpressionTree parent1);154 public abstract ISymbolicExpressionTree Crossover(IRandom random, ISymbolicExpressionTree parent0, ISymbolicExpressionTree parent1);155 151 } 156 152 } -
branches/HeuristicLab.Crossovers/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Crossovers/SymbolicDataAnalysisExpressionDepthConstrainedCrossover.cs
r7476 r7481 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;26 25 using HeuristicLab.Common; 27 26 using HeuristicLab.Core; 27 using HeuristicLab.Data; 28 28 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 29 using HeuristicLab.Data;30 29 using HeuristicLab.Parameters; 30 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 31 31 32 32 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { … … 64 64 public override IDeepCloneable Clone(Cloner cloner) { return new SymbolicDataAnalysisExpressionDepthConstrainedCrossover<T>(this, cloner); } 65 65 66 p rotected override ISymbolicExpressionTree Cross(IRandom random, ISymbolicExpressionTree parent0, ISymbolicExpressionTree parent1) {66 public override ISymbolicExpressionTree Crossover(IRandom random, ISymbolicExpressionTree parent0, ISymbolicExpressionTree parent1) { 67 67 return Cross(random, parent0, parent1, MaximumSymbolicExpressionTreeDepth.Value, MaximumSymbolicExpressionTreeLength.Value, DepthRange.Value); 68 68 } 69 69 70 public override ISymbolicExpressionTree Crossover(IRandom random, ISymbolicExpressionTree parent0, ISymbolicExpressionTree parent1) {71 return Cross(random, parent0, parent1);72 }73 70 74 71 /// <summary> -
branches/HeuristicLab.Crossovers/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Crossovers/SymbolicDataAnalysisExpressionDeterministicBestCrossover.cs
r7476 r7481 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;26 25 using HeuristicLab.Common; 27 26 using HeuristicLab.Core; 28 27 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 29 30 30 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { … … 44 44 return new SymbolicDataAnalysisExpressionDeterministicBestCrossover<T>(this, cloner); 45 45 } 46 p rotected override ISymbolicExpressionTree Cross(IRandom random, ISymbolicExpressionTree parent0, ISymbolicExpressionTree parent1) {46 public override ISymbolicExpressionTree Crossover(IRandom random, ISymbolicExpressionTree parent0, ISymbolicExpressionTree parent1) { 47 47 if (this.ExecutionContext == null) 48 48 throw new InvalidOperationException("ExecutionContext not set."); … … 54 54 } 55 55 56 public override ISymbolicExpressionTree Crossover(IRandom random, ISymbolicExpressionTree parent0, ISymbolicExpressionTree parent1) {57 return Cross(random, parent0, parent1);58 }59 56 /// <summary> 60 57 /// Takes two parent individuals P0 and P1. -
branches/HeuristicLab.Crossovers/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Crossovers/SymbolicDataAnalysisExpressionProbabilisticFunctionalCrossover.cs
r7476 r7481 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;26 25 using HeuristicLab.Common; 27 26 using HeuristicLab.Core; 28 27 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 29 30 30 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { … … 38 38 public SymbolicDataAnalysisExpressionProbabilisticFunctionalCrossover() 39 39 : base() { 40 Name = "ProbabilisticFunctionalCrossover";41 40 } 42 41 public override IDeepCloneable Clone(Cloner cloner) { return new SymbolicDataAnalysisExpressionProbabilisticFunctionalCrossover<T>(this, cloner); } 43 42 44 p rotected override ISymbolicExpressionTree Cross(IRandom random, ISymbolicExpressionTree parent0, ISymbolicExpressionTree parent1) {43 public override ISymbolicExpressionTree Crossover(IRandom random, ISymbolicExpressionTree parent0, ISymbolicExpressionTree parent1) { 45 44 ISymbolicDataAnalysisExpressionTreeInterpreter interpreter = SymbolicDataAnalysisTreeInterpreterParameter.ActualValue; 46 45 List<int> rows = GenerateRowsToEvaluate().ToList(); … … 48 47 return Cross(random, parent0, parent1, interpreter, problemData, 49 48 rows, MaximumSymbolicExpressionTreeDepth.Value, MaximumSymbolicExpressionTreeLength.Value); 50 }51 52 public override ISymbolicExpressionTree Crossover(IRandom random, ISymbolicExpressionTree parent0, ISymbolicExpressionTree parent1) {53 return Cross(random, parent0, parent1);54 49 } 55 50 -
branches/HeuristicLab.Crossovers/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Crossovers/SymbolicDataAnalysisExpressionSemanticSimilarityCrossover.cs
r7476 r7481 22 22 using System.Collections.Generic; 23 23 using System.Linq; 24 using HeuristicLab.Common; 25 using HeuristicLab.Core; 26 using HeuristicLab.Data; 27 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 24 28 using HeuristicLab.Parameters; 25 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 using HeuristicLab.Common;27 using HeuristicLab.Core;28 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;29 using HeuristicLab.Data;30 30 31 31 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { … … 57 57 public override IDeepCloneable Clone(Cloner cloner) { return new SymbolicDataAnalysisExpressionSemanticSimilarityCrossover<T>(this, cloner); } 58 58 59 p rotected override ISymbolicExpressionTree Cross(IRandom random, ISymbolicExpressionTree parent0, ISymbolicExpressionTree parent1) {59 public override ISymbolicExpressionTree Crossover(IRandom random, ISymbolicExpressionTree parent0, ISymbolicExpressionTree parent1) { 60 60 ISymbolicDataAnalysisExpressionTreeInterpreter interpreter = SymbolicDataAnalysisTreeInterpreterParameter.ActualValue; 61 61 List<int> rows = GenerateRowsToEvaluate().ToList(); 62 62 T problemData = ProblemDataParameter.ActualValue; 63 63 return Cross(random, parent0, parent1, interpreter, problemData, rows, MaximumSymbolicExpressionTreeDepth.Value, MaximumSymbolicExpressionTreeLength.Value, SemanticSimilarityRange); 64 }65 66 public override ISymbolicExpressionTree Crossover(IRandom random, ISymbolicExpressionTree parent0, ISymbolicExpressionTree parent1) {67 return Cross(random, parent0, parent1);68 64 } 69 65 -
branches/HeuristicLab.Crossovers/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj
r7477 r7481 175 175 <Compile Include="Crossovers\SymbolicDataAnalysisExpressionProbabilisticFunctionalCrossover.cs" /> 176 176 <Compile Include="Crossovers\SymbolicDataAnalysisExpressionSemanticSimilarityCrossover.cs" /> 177 <Compile Include="Crossovers\SymbolicDataAnalysisExpressionSizefairCrossover.cs" />178 177 <Compile Include="Interfaces\ISymbolicDataAnalysisExpressionCrossover.cs" /> 179 178 <Compile Include="Plugin.cs" /> -
branches/HeuristicLab.Crossovers/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interfaces/ISymbolicDataAnalysisExpressionCrossover.cs
r7477 r7481 20 20 #endregion 21 21 22 using System.Collections.Generic;23 22 using HeuristicLab.Core; 23 using HeuristicLab.Data; 24 24 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 25 using HeuristicLab.Parameters;26 using HeuristicLab.Data;27 25 28 26 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { 29 27 public interface ISymbolicDataAnalysisExpressionCrossover<T> : ISymbolicExpressionTreeCrossover { 30 28 IValueLookupParameter<IntRange> SymbolicDataAnalysisEvaluationPartitionParameter { get; } 31 ISymbolicExpressionTree Crossover(IRandom random, ISymbolicExpressionTree parent0, ISymbolicExpressionTree parent1);32 29 } 33 30 } -
branches/HeuristicLab.Crossovers/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisProblem.cs
r7477 r7481 32 32 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 33 33 using HeuristicLab.PluginInfrastructure; 34 using HeuristicLab.Problems.DataAnalysis.Symbolic.Crossovers;35 34 36 35 namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
Note: See TracChangeset
for help on using the changeset viewer.