Changeset 5014 for trunk/sources
- Timestamp:
- 12/03/10 14:11:02 (14 years ago)
- Location:
- trunk/sources
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Crossovers/SubtreeCrossover.cs
r4722 r5014 66 66 SymbolicExpressionTreeNode crossoverPoint0; 67 67 int replacedSubtreeIndex; 68 SelectCrossoverPoint(random, parent0, internalCrossoverPointProbability, maxTreeSize - 1, maxTreeHeight - 1, out crossoverPoint0, out replacedSubtreeIndex);68 SelectCrossoverPoint(random, parent0, internalCrossoverPointProbability, maxTreeSize, maxTreeHeight, out crossoverPoint0, out replacedSubtreeIndex); 69 69 70 70 // calculate the max size and height that the inserted branch can have -
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Manipulators/ReplaceBranchManipulation.cs
r4722 r5014 53 53 from subtree in parent.SubTrees 54 54 select new { Parent = parent, Node = subtree, Index = parent.SubTrees.IndexOf(subtree) }).SelectRandom(random); 55 56 int maxSize = maxTreeSize - symbolicExpressionTree.Size + manipulationPoint.Node.GetSize(); 57 int maxHeight = maxTreeHeight - symbolicExpressionTree.Height + manipulationPoint.Node.GetHeight(); 55 58 // find possible symbols for the node (also considering the existing branches below it) 56 var allowedSymbols = from symbol in manipulationPoint.Parent.GetAllowedSymbols(manipulationPoint.Index )59 var allowedSymbols = from symbol in manipulationPoint.Parent.GetAllowedSymbols(manipulationPoint.Index, maxHeight) 57 60 select symbol; 61 if (allowedSymbols.Count() <= 1) return; 58 62 59 if (allowedSymbols.Count() <= 1) { 60 return; 61 } 62 var oldBranch = manipulationPoint.Node; 63 int oldBranchSize = manipulationPoint.Node.GetSize(); 64 65 var seedSymbol = SelectRandomSymbol(random, allowedSymbols); 66 67 // replace the old node with the new node 63 var seedSymbol = SelectRandomSymbol(random, allowedSymbols); // replace the old node with the new node 68 64 var seedNode = seedSymbol.CreateTreeNode(); 69 65 if (seedNode.HasLocalParameters) … … 72 68 manipulationPoint.Parent.RemoveSubTree(manipulationPoint.Index); 73 69 manipulationPoint.Parent.InsertSubTree(manipulationPoint.Index, seedNode); 74 int maxSize = Math.Max(oldBranchSize, seedNode.Grammar.GetMinExpressionLength(seedNode.Symbol)) * 2; 75 var bla = ProbabilisticTreeCreator.PTC2(random, seedNode, maxSize, maxSize, 0, 0); 70 seedNode = ProbabilisticTreeCreator.PTC2(random, seedNode, maxSize, maxHeight, 0, 0); 76 71 success = true; 77 72 } -
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/SymbolicExpressionTreeNode.cs
r4722 r5014 178 178 return Grammar.Symbols.Where(s => Grammar.IsAllowedChild(Symbol, s, argumentIndex)); 179 179 } 180 public IEnumerable<Symbol> GetAllowedSymbols(int argumentIndex, int maxExpressionDepth) { 181 return Grammar.Symbols.Where(s => Grammar.IsAllowedChild(Symbol, s, argumentIndex) && Grammar.GetMinExpressionDepth(s) <= maxExpressionDepth); 182 } 183 180 184 public int GetMinSubtreeCount() { 181 185 return Grammar.GetMinSubtreeCount(Symbol); -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/SymbolicRegressionProblemBase.cs
r4801 r5014 156 156 : base(original, cloner) { 157 157 operators = original.operators.Select(x => (IOperator)cloner.Clone(x)).ToList(); 158 RegisterParameterValueEvents(); 158 159 RegisterParameterEvents(); 159 RegisterParameterValueEvents();160 160 } 161 161 public SymbolicRegressionProblemBase() … … 171 171 Parameters.Add(new ValueParameter<ISymbolicExpressionGrammar>("FunctionTreeGrammar", "The grammar that should be used for symbolic regression models.", globalGrammar)); 172 172 Parameters.Add(new ValueParameter<IntValue>("MaxExpressionLength", "Maximal length of the symbolic expression.", new IntValue(100))); 173 Parameters.Add(new ValueParameter<IntValue>("MaxExpressionDepth", "Maximal depth of the symbolic expression. ", new IntValue(10)));173 Parameters.Add(new ValueParameter<IntValue>("MaxExpressionDepth", "Maximal depth of the symbolic expression. The minimum depth needed for the algorithm is 3 because two levels are reserved for the ProgramRoot and the Start symbol.", new IntValue(10))); 174 174 Parameters.Add(new ValueParameter<IntValue>("MaxFunctionDefiningBranches", "Maximal number of automatically defined functions.", (IntValue)new IntValue(0).AsReadOnly())); 175 175 Parameters.Add(new ValueParameter<IntValue>("MaxFunctionArguments", "Maximal number of arguments of automatically defined functions.", (IntValue)new IntValue(0).AsReadOnly())); … … 182 182 UpdateEstimationLimits(); 183 183 InitializeOperators(); 184 RegisterParameterValueEvents(); 184 185 RegisterParameterEvents(); 185 RegisterParameterValueEvents(); 186 } 187 188 private void RegisterParameterValueEvents() { 186 } 187 188 private void RegisterParameterEvents() { 189 189 MaxFunctionArgumentsParameter.ValueChanged += new EventHandler(ArchitectureParameter_ValueChanged); 190 190 MaxFunctionDefiningBranchesParameter.ValueChanged += new EventHandler(ArchitectureParameter_ValueChanged); 191 MaxExpressionDepthParameter.ValueChanged += new EventHandler(MaxExpressionDepthParameter_ValueChanged); 191 192 SolutionCreatorParameter.ValueChanged += new EventHandler(SolutionCreatorParameter_ValueChanged); 192 193 FunctionTreeGrammarParameter.ValueChanged += new EventHandler(FunctionTreeGrammarParameter_ValueChanged); 193 } 194 195 private void RegisterParameterEvents() { 194 SolutionCreator.SymbolicExpressionTreeParameter.ActualNameChanged += new EventHandler(SolutionCreator_SymbolicExpressionTreeParameter_ActualNameChanged); 195 } 196 197 private void RegisterParameterValueEvents() { 196 198 MaxFunctionArgumentsParameter.Value.ValueChanged += new EventHandler(ArchitectureParameterValue_ValueChanged); 197 199 MaxFunctionDefiningBranchesParameter.Value.ValueChanged += new EventHandler(ArchitectureParameterValue_ValueChanged); 198 SolutionCreator.SymbolicExpressionTreeParameter.ActualNameChanged += new EventHandler(SolutionCreator_SymbolicExpressionTreeParameter_ActualNameChanged);200 MaxExpressionDepthParameter.Value.ValueChanged += new EventHandler(MaxExpressionDepthParameterValue_ValueChanged); 199 201 } 200 202 … … 252 254 OnArchitectureParameterChanged(e); 253 255 } 256 257 private void MaxExpressionDepthParameter_ValueChanged(object sender, EventArgs e) { 258 MaxExpressionDepthParameterValue_ValueChanged(sender, e); 259 MaxExpressionDepthParameter.Value.ValueChanged += MaxExpressionDepthParameterValue_ValueChanged; 260 } 261 private void MaxExpressionDepthParameterValue_ValueChanged(object sender, EventArgs e) { 262 if (MaxExpressionDepth != null && MaxExpressionDepth.Value < 3) 263 MaxExpressionDepth.Value = 3; 264 } 254 265 #endregion 255 266 … … 261 272 if (operators == null) InitializeOperators(); 262 273 #endregion 274 RegisterParameterValueEvents(); 263 275 RegisterParameterEvents(); 264 RegisterParameterValueEvents();265 276 } 266 277 -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.3/EstimatedValuesView.cs
r4068 r5014 47 47 InitializeComponent(); 48 48 matrixView = new StringConvertibleMatrixView(); 49 matrixView.ShowRowsAndColumnsTextBox = false; 50 matrixView.ShowStatisticalInformation = false; 49 51 matrixView.Dock = DockStyle.Fill; 50 52 this.Controls.Add(matrixView); … … 82 84 DoubleMatrix matrix = null; 83 85 if (Content != null) { 84 double[,] values = 85 MatrixExtensions<double>.Create( 86 Content.ProblemData.Dataset.GetVariableValues(Content.ProblemData.TargetVariable.Value), 87 Content.EstimatedValues.ToArray()); 86 double[,] values = new double[Content.ProblemData.Dataset.Rows, 4]; 87 88 double[] target = Content.ProblemData.Dataset.GetVariableValues(Content.ProblemData.TargetVariable.Value); 89 double[] estimated = Content.EstimatedValues.ToArray(); 90 for (int row = 0; row < target.Length; row++) { 91 values[row, 0] = target[row]; 92 values[row, 1] = estimated[row]; 93 values[row, 2] = estimated[row] - target[row]; 94 values[row, 3] = estimated[row] / target[row] - 1; 95 } 96 88 97 matrix = new DoubleMatrix(values); 89 matrix.ColumnNames = new string[] { "Original", "Estimated" };98 matrix.ColumnNames = new string[] { "Original", "Estimated", "Error", "Rel. Error" }; 90 99 } 91 100 matrixView.Content = matrix;
Note: See TracChangeset
for help on using the changeset viewer.