Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/03/10 14:11:02 (14 years ago)
Author:
mkommend
Message:

Corrected SubTreeCrossover and ReplaceBranchManipulation to handle MaxExpressionDepth correctly. Additionally MaxExpressionDepth < 3 is not allowed.
(ticket #1315).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/SymbolicRegressionProblemBase.cs

    r4801 r5014  
    156156      : base(original, cloner) {
    157157      operators = original.operators.Select(x => (IOperator)cloner.Clone(x)).ToList();
     158      RegisterParameterValueEvents();
    158159      RegisterParameterEvents();
    159       RegisterParameterValueEvents();
    160160    }
    161161    public SymbolicRegressionProblemBase()
     
    171171      Parameters.Add(new ValueParameter<ISymbolicExpressionGrammar>("FunctionTreeGrammar", "The grammar that should be used for symbolic regression models.", globalGrammar));
    172172      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)));
    174174      Parameters.Add(new ValueParameter<IntValue>("MaxFunctionDefiningBranches", "Maximal number of automatically defined functions.", (IntValue)new IntValue(0).AsReadOnly()));
    175175      Parameters.Add(new ValueParameter<IntValue>("MaxFunctionArguments", "Maximal number of arguments of automatically defined functions.", (IntValue)new IntValue(0).AsReadOnly()));
     
    182182      UpdateEstimationLimits();
    183183      InitializeOperators();
     184      RegisterParameterValueEvents();
    184185      RegisterParameterEvents();
    185       RegisterParameterValueEvents();
    186     }
    187 
    188     private void RegisterParameterValueEvents() {
     186    }
     187
     188    private void RegisterParameterEvents() {
    189189      MaxFunctionArgumentsParameter.ValueChanged += new EventHandler(ArchitectureParameter_ValueChanged);
    190190      MaxFunctionDefiningBranchesParameter.ValueChanged += new EventHandler(ArchitectureParameter_ValueChanged);
     191      MaxExpressionDepthParameter.ValueChanged += new EventHandler(MaxExpressionDepthParameter_ValueChanged);
    191192      SolutionCreatorParameter.ValueChanged += new EventHandler(SolutionCreatorParameter_ValueChanged);
    192193      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() {
    196198      MaxFunctionArgumentsParameter.Value.ValueChanged += new EventHandler(ArchitectureParameterValue_ValueChanged);
    197199      MaxFunctionDefiningBranchesParameter.Value.ValueChanged += new EventHandler(ArchitectureParameterValue_ValueChanged);
    198       SolutionCreator.SymbolicExpressionTreeParameter.ActualNameChanged += new EventHandler(SolutionCreator_SymbolicExpressionTreeParameter_ActualNameChanged);
     200      MaxExpressionDepthParameter.Value.ValueChanged += new EventHandler(MaxExpressionDepthParameterValue_ValueChanged);
    199201    }
    200202
     
    252254      OnArchitectureParameterChanged(e);
    253255    }
     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    }
    254265    #endregion
    255266
     
    261272      if (operators == null) InitializeOperators();
    262273      #endregion
     274      RegisterParameterValueEvents();
    263275      RegisterParameterEvents();
    264       RegisterParameterValueEvents();
    265276    }
    266277
Note: See TracChangeset for help on using the changeset viewer.