Ignore:
Timestamp:
04/04/18 16:23:55 (3 years ago)
Author:
lkammere
Message:

#2886: Priorize phrases whose (fully expanded) terms result in high R².

File:
1 edited

Legend:

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

    r15861 r15883  
    153153      #endregion
    154154
    155       OpenPhrases.Store(phrase0Hash, phrase0);
     155      OpenPhrases.Store(phrase0Hash, 0.0, phrase0);
    156156      while (OpenPhrases.Count > 0) {
    157157        if (cancellationToken.IsCancellationRequested) break;
     
    185185              OnSentenceGenerated(fetchedPhrase.Hash, fetchedPhrase.SymbolString, phraseHash, newPhrase, expandedSymbol, appliedProductions[i]);
    186186
     187              // 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;
     191              }
     192
    187193              if (!DistinctSentencesComplexity.ContainsKey(phraseHash) || DistinctSentencesComplexity[phraseHash] > newPhraseComplexity) {
    188194                if (DistinctSentencesComplexity.ContainsKey(phraseHash)) OverwrittenSentencesCount++; // for analysis only
     
    194200
    195201            } else if (!OpenPhrases.Contains(phraseHash) && !ArchivedPhrases.Contains(phraseHash)) {
    196               OpenPhrases.Store(phraseHash, newPhrase);
     202              double phrasePriority = GetPriority(newPhrase);
     203              OpenPhrases.Store(phraseHash, phrasePriority, newPhrase);
    197204            }
    198205          }
     
    200207      }
    201208      UpdateView(force: true);
     209    }
     210
     211    protected double GetPriority(SymbolString phrase) {
     212      return 1.0 - Grammar.EvaluatePhrase(phrase, Problem.ProblemData, OptimizeConstants);
    202213    }
    203214
Note: See TracChangeset for help on using the changeset viewer.