Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/16/18 15:19:58 (6 years ago)
Author:
lkammere
Message:

#2886: Changes in search heuristic for solving Poly-10 problem. Adapt tree evaluation to cover non-terminal symbols.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/GrammarEnumeration/GrammarEnumerationAlgorithm.cs

    r15883 r15907  
    186186
    187187              // Is the best solution found? (only if RSquaredEvaluator is activated)
    188               if (Results.ContainsKey(RSquaredEvaluator.BestTrainingQualityResultName) && ((DoubleValue)Results[RSquaredEvaluator.BestTrainingQualityResultName].Value).Value == 1.0) {
    189                 UpdateView(force: true);
    190                 return;
     188              if (Results.ContainsKey(RSquaredEvaluator.BestTrainingQualityResultName)) {
     189                double r2 = ((DoubleValue)Results[RSquaredEvaluator.BestTrainingQualityResultName].Value).Value;
     190                if (r2.IsAlmost(1.0)) {
     191                  UpdateView(force: true);
     192                  return;
     193                }
    191194              }
    192195
     
    210213
    211214    protected double GetPriority(SymbolString phrase) {
    212       return 1.0 - Grammar.EvaluatePhrase(phrase, Problem.ProblemData, OptimizeConstants);
     215      double complexity = (double)Grammar.GetComplexity(phrase);
     216
     217      double length = phrase.Count();
     218      double relLength = (length - 2) / (MaxComplexity * 7);
     219      double r2 = Grammar.EvaluatePhrase(phrase, Problem.ProblemData, OptimizeConstants);
     220      double error = 1.0 - r2;
     221
     222      double variables = 0;
     223      for (int i = 0; i < phrase.Count(); i++) {
     224        if (phrase[i] is VariableTerminalSymbol) variables++;
     225      }
     226
     227      double variableRatio = 1.0 - variables / complexity;
     228
     229      return 1.5*relLength + error;
    213230    }
    214231
Note: See TracChangeset for help on using the changeset viewer.