Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/11/11 15:03:46 (13 years ago)
Author:
gkronber
Message:

Merged changes from trunk to data analysis exploration branch and added fractional distance metric evaluator. #1142

File:
1 edited

Legend:

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

    r4341 r5275  
    125125    }
    126126    public IntValue TrainingSamplesStart {
    127       get { return new IntValue(DataAnalysisProblemData.TrainingSamplesStart.Value); }
     127      get { return new IntValue(DataAnalysisProblemData.TrainingIndizes.First()); }
    128128    }
    129129    public IntValue TrainingSamplesEnd {
    130130      get {
    131         return new IntValue((DataAnalysisProblemData.TrainingSamplesStart.Value +
    132           DataAnalysisProblemData.TrainingSamplesEnd.Value) / 2);
     131        int endIndex = (int)(DataAnalysisProblemData.TrainingIndizes.Count() * (1.0 - DataAnalysisProblemData.ValidationPercentage.Value) - 1);
     132        if (endIndex < 0) endIndex = 0;
     133        return new IntValue(DataAnalysisProblemData.TrainingIndizes.ElementAt(endIndex));
    133134      }
    134135    }
     
    137138    }
    138139    public IntValue ValidationSamplesEnd {
    139       get { return new IntValue(DataAnalysisProblemData.TrainingSamplesEnd.Value); }
     140      get { return new IntValue(DataAnalysisProblemData.TrainingIndizes.Last() + 1); }
    140141    }
    141142    public IntValue TestSamplesStart {
     
    152153    [StorableConstructor]
    153154    protected SymbolicRegressionProblemBase(bool deserializing) : base(deserializing) { }
     155    protected SymbolicRegressionProblemBase(SymbolicRegressionProblemBase original, Cloner cloner)
     156      : base(original, cloner) {
     157      operators = original.operators.Select(x => (IOperator)cloner.Clone(x)).ToList();
     158      RegisterParameterValueEvents();
     159      RegisterParameterEvents();
     160    }
    154161    public SymbolicRegressionProblemBase()
    155162      : base() {
     
    164171      Parameters.Add(new ValueParameter<ISymbolicExpressionGrammar>("FunctionTreeGrammar", "The grammar that should be used for symbolic regression models.", globalGrammar));
    165172      Parameters.Add(new ValueParameter<IntValue>("MaxExpressionLength", "Maximal length of the symbolic expression.", new IntValue(100)));
    166       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)));
    167174      Parameters.Add(new ValueParameter<IntValue>("MaxFunctionDefiningBranches", "Maximal number of automatically defined functions.", (IntValue)new IntValue(0).AsReadOnly()));
    168175      Parameters.Add(new ValueParameter<IntValue>("MaxFunctionArguments", "Maximal number of arguments of automatically defined functions.", (IntValue)new IntValue(0).AsReadOnly()));
    169 
    170       creator.SymbolicExpressionTreeParameter.ActualName = "SymbolicRegressionModel";
    171176
    172177      ParameterizeSolutionCreator();
     
    175180      UpdateEstimationLimits();
    176181      InitializeOperators();
     182      RegisterParameterValueEvents();
    177183      RegisterParameterEvents();
    178       RegisterParameterValueEvents();
    179     }
    180 
    181     public override IDeepCloneable Clone(Cloner cloner) {
    182       SymbolicRegressionProblemBase clone = (SymbolicRegressionProblemBase)base.Clone(cloner);
    183       clone.operators = operators.Select(x => (IOperator)cloner.Clone(x)).ToList();
    184       clone.RegisterParameterEvents();
    185       clone.RegisterParameterValueEvents();
    186       return clone;
    187     }
    188 
    189     private void RegisterParameterValueEvents() {
     184    }
     185
     186    private void RegisterParameterEvents() {
    190187      MaxFunctionArgumentsParameter.ValueChanged += new EventHandler(ArchitectureParameter_ValueChanged);
    191188      MaxFunctionDefiningBranchesParameter.ValueChanged += new EventHandler(ArchitectureParameter_ValueChanged);
     189      MaxExpressionDepthParameter.ValueChanged += new EventHandler(MaxExpressionDepthParameter_ValueChanged);
    192190      SolutionCreatorParameter.ValueChanged += new EventHandler(SolutionCreatorParameter_ValueChanged);
    193191      FunctionTreeGrammarParameter.ValueChanged += new EventHandler(FunctionTreeGrammarParameter_ValueChanged);
    194     }
    195 
    196     private void RegisterParameterEvents() {
     192      SolutionCreator.SymbolicExpressionTreeParameter.ActualNameChanged += new EventHandler(SolutionCreator_SymbolicExpressionTreeParameter_ActualNameChanged);
     193    }
     194
     195    private void RegisterParameterValueEvents() {
    197196      MaxFunctionArgumentsParameter.Value.ValueChanged += new EventHandler(ArchitectureParameterValue_ValueChanged);
    198197      MaxFunctionDefiningBranchesParameter.Value.ValueChanged += new EventHandler(ArchitectureParameterValue_ValueChanged);
    199       SolutionCreator.SymbolicExpressionTreeParameter.ActualNameChanged += new EventHandler(SolutionCreator_SymbolicExpressionTreeParameter_ActualNameChanged);
     198      MaxExpressionDepthParameter.Value.ValueChanged += new EventHandler(MaxExpressionDepthParameterValue_ValueChanged);
    200199    }
    201200
     
    253252      OnArchitectureParameterChanged(e);
    254253    }
     254
     255    private void MaxExpressionDepthParameter_ValueChanged(object sender, EventArgs e) {
     256      MaxExpressionDepthParameterValue_ValueChanged(sender, e);
     257      MaxExpressionDepthParameter.Value.ValueChanged += MaxExpressionDepthParameterValue_ValueChanged;
     258    }
     259    private void MaxExpressionDepthParameterValue_ValueChanged(object sender, EventArgs e) {
     260      if (MaxExpressionDepth != null && MaxExpressionDepth.Value < 3)
     261        MaxExpressionDepth.Value = 3;
     262    }
    255263    #endregion
    256264
     
    262270      if (operators == null) InitializeOperators();
    263271      #endregion
     272      RegisterParameterValueEvents();
    264273      RegisterParameterEvents();
    265       RegisterParameterValueEvents();
    266274    }
    267275
     
    325333          varFreqAnalyzer.ProblemDataParameter.ActualName = DataAnalysisProblemDataParameter.Name;
    326334        }
    327         var pruningOperator = analyzer as SymbolicRegressionTournamentPruning;
    328         if (pruningOperator != null) {
    329           pruningOperator.SamplesStartParameter.Value = TrainingSamplesStart;
    330           pruningOperator.SamplesEndParameter.Value = TrainingSamplesEnd;
    331           pruningOperator.DataAnalysisProblemDataParameter.ActualName = DataAnalysisProblemDataParameter.Name;
    332           pruningOperator.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
    333           pruningOperator.SymbolicExpressionTreeInterpreterParameter.ActualName = SymbolicExpressionTreeInterpreterParameter.Name;
    334           pruningOperator.LowerEstimationLimitParameter.ActualName = LowerEstimationLimitParameter.Name;
    335           pruningOperator.UpperEstimationLimitParameter.ActualName = UpperEstimationLimitParameter.Name;
    336         }
    337335      }
    338336      foreach (ISymbolicExpressionTreeAnalyzer analyzer in Operators.OfType<ISymbolicExpressionTreeAnalyzer>()) {
Note: See TracChangeset for help on using the changeset viewer.