Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/22/18 13:11:40 (6 years ago)
Author:
lkammere
Message:

#2886: Deactivate generation of dot file for visualizing search tree.

File:
1 edited

Legend:

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

    r15800 r15803  
    2525    private readonly string BestTrainingQualityName = "Best R² (Training)";
    2626    private readonly string BestTrainingSolutionName = "Best solution (Training)";
     27    private readonly string SearchStructureSizeName = "Search Structure Size";
     28    private readonly string GeneratedPhrasesName = "Generated/Archived Phrases";
    2729    private readonly string GeneratedSentencesName = "Generated Sentences";
    2830    private readonly string DistinctSentencesName = "Distinct Sentences";
     
    115117
    116118      using (TextWriterTraceListener dotFileTrace = new TextWriterTraceListener(new FileStream(dotFileName, FileMode.Create))) {
    117         dotFileTrace.Write("digraph searchgraph {");
     119        LogSearchGraph(dotFileTrace, "digraph searchgraph {");
    118120
    119121        OpenPhrases.Store(phrase0Hash, phrase0);
     
    124126          SymbolString currPhrase = fetchedPhrase.SymbolString;
    125127
    126           dotFileTrace.Write(
    127             $"{fetchedPhrase.Hash} [label=\"{Grammar.PostfixToInfixParser(fetchedPhrase.SymbolString)}\"];");
     128          LogSearchGraph(dotFileTrace, $"{fetchedPhrase.Hash} [label=\"{Grammar.PostfixToInfixParser(fetchedPhrase.SymbolString)}\"];");
    128129
    129130          ArchivedPhrases.Add(fetchedPhrase.Hash, currPhrase);
     
    142143              var phraseHash = Grammar.CalcHashCode(newPhrase);
    143144
    144               dotFileTrace.Write(
    145                 $"{fetchedPhrase.Hash} -> {phraseHash} [label=\"{expandedSymbol.StringRepresentation} + → {productionAlternative}\"];");
     145              LogSearchGraph(dotFileTrace, $"{fetchedPhrase.Hash} -> {phraseHash} [label=\"{expandedSymbol.StringRepresentation} + → {productionAlternative}\"];");
    146146
    147147              if (newPhrase.IsSentence()) {
     
    155155                  EvaluateSentence(newPhrase);
    156156
    157                   dotFileTrace.Write(
    158                     $"{phraseHash} [label=\"{Grammar.PostfixToInfixParser(newPhrase)}\", style=\"filled\"];");
     157                  LogSearchGraph(dotFileTrace, $"{phraseHash} [label=\"{Grammar.PostfixToInfixParser(newPhrase)}\", style=\"filled\"];");
    159158                }
    160159                UpdateView(AllSentences, DistinctSentences);
     
    168167
    169168        // Overwrite formatting of start search node and best found solution.
    170         dotFileTrace.Write(
    171           $"{Grammar.CalcHashCode(BestTrainingSentence)} [label=\"{Grammar.PostfixToInfixParser(BestTrainingSentence)}\", shape=Mcircle, style=\"filled,bold\"];");
    172         dotFileTrace.Write($"{phrase0Hash} [label=\"{Grammar.PostfixToInfixParser(phrase0)}\", shape=doublecircle];}}");
     169        LogSearchGraph(dotFileTrace, $"{Grammar.CalcHashCode(BestTrainingSentence)} [label=\"{Grammar.PostfixToInfixParser(BestTrainingSentence)}\", shape=Mcircle, style=\"filled,bold\"];");
     170        LogSearchGraph(dotFileTrace, $"{phrase0Hash} [label=\"{Grammar.PostfixToInfixParser(phrase0)}\", shape=doublecircle];}}");
    173171        dotFileTrace.Flush();
    174172      }
     
    219217      Results.Add(new Result(BestTrainingQualityName, new DoubleValue(-1.0)));
    220218
     219      Results.Add(new Result(GeneratedPhrasesName, new IntValue(0)));
     220      Results.Add(new Result(SearchStructureSizeName, new IntValue(0)));
    221221      Results.Add(new Result(GeneratedSentencesName, new IntValue(0)));
    222222      Results.Add(new Result(DistinctSentencesName, new IntValue(0)));
     
    234234      if (force || updates % GuiUpdateInterval == 0) {
    235235        var allGeneratedEnum = allGenerated.Values.SelectMany(x => x).ToArray();
     236        ((IntValue)Results[GeneratedPhrasesName].Value).Value = ArchivedPhrases.Count;
     237        ((IntValue)Results[SearchStructureSizeName].Value).Value = OpenPhrases.Count;
    236238        ((IntValue)Results[GeneratedSentencesName].Value).Value = allGeneratedEnum.Length;
    237239        ((IntValue)Results[DistinctSentencesName].Value).Value = distinctGenerated.Count;
     
    277279      Results.Add(new Result("Distinct generated sentences", new StringMatrix(distinctSentencesMatrix)));
    278280    }
     281   
     282    private void LogSearchGraph(TraceListener listener, String msg) {
     283#if false
     284      listener.Write(msg);
     285#endif
     286    }
    279287    #endregion
    280288
Note: See TracChangeset for help on using the changeset viewer.