Free cookie consent management tool by TermsFeed Policy Generator

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

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

Location:
branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/GrammarEnumeration
Files:
2 edited

Legend:

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

    r15800 r15803  
    1111  public class Grammar {
    1212
    13     public Symbol StartSymbol;
     13    public Symbol StartSymbol { get; }
    1414
    1515    #region Symbols
    16 
    1716    public VariableSymbol Var;
    1817
     
    4342    #endregion
    4443
    45 
    4644    #region HL Symbols for Parsing ExpressionTrees
    47 
    4845    private TypeCoherentExpressionGrammar symbolicExpressionGrammar;
    4946
     
    6057    private ISymbol rootSy;
    6158    private ISymbol startSy;
    62 
    6359    #endregion
    6460
     
    9086      ClosingBracket = new TerminalSymbol(")");
    9187      #endregion
    92 
    9388
    9489      #region Production rules
     
    179174        }
    180175
    181         var result = uniqueChildHashes.ToList();
    182         result.Sort();
    183         return result.ToArray();
     176        var result = uniqueChildHashes.ToArray();
     177        Array.Sort(result);
     178        return result;
    184179      }
    185180
     
    266261      return hashesArray.Aggregate(start, (result, ti) => ((result << 5) + result) ^ ti.GetHashCode());
    267262    }
    268 
    269     /*
    270     private void CancelOutCompoundInverse(Stack<Symbol> parseStack) {
    271       // Resolve compound divisions
    272       int compoundFractionsCount = 0;
    273 
    274       while (ReferenceEquals(parseStack.Peek(), Inv)) {
    275         compoundFractionsCount++;
    276         parseStack.Pop();
    277       }
    278 
    279       if (compoundFractionsCount % 2 != 0) {
    280         // Compound division are reduced to a single division.
    281         parseStack.Push(Inv);
    282       } // else: compound divisions fully cancel out each other.
    283     } */
    284263    #endregion
    285264
  • 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} + &rarr; {productionAlternative}\"];");
     145              LogSearchGraph(dotFileTrace, $"{fetchedPhrase.Hash} -> {phraseHash} [label=\"{expandedSymbol.StringRepresentation} + &rarr; {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.