Changeset 15765
- Timestamp:
- 02/13/18 13:01:08 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/GrammarEnumeration/GrammarEnumerationAlgorithm.cs
r15746 r15765 1 using System.Collections.Generic; 1 using System; 2 using System.Collections.Generic; 2 3 using System.Linq; 4 using System.Text; 3 5 using System.Threading; 4 6 using HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration.GrammarEnumeration; … … 32 34 private readonly string MaxTreeSizeParameterName = "Max. Tree Nodes"; 33 35 private readonly string GuiUpdateIntervalParameterName = "GUI Update Interval"; 34 36 35 37 public override bool SupportsPause { get { return false; } } 36 38 … … 74 76 public Grammar Grammar; 75 77 78 public StringBuilder dotFileBuilder; 79 76 80 #region ctors 77 81 public override IDeepCloneable Clone(Cloner cloner) { … … 99 103 #region init 100 104 InitResults(); 105 106 dotFileBuilder = new StringBuilder(); 101 107 102 108 AllSentences = new Dictionary<int, List<SymbolString>>(); … … 120 126 SymbolString currPhrase = fetchedPhrase.SymbolString; 121 127 128 if (dotFileBuilder.Length == 0) { 129 dotFileBuilder.AppendLine("digraph searchgraph {"); 130 dotFileBuilder.AppendLine(fetchedPhrase.Hash + " [label=\"" + Grammar.PostfixToInfixParser(fetchedPhrase.SymbolString) + "\", shape=doublecircle];"); 131 } else { 132 dotFileBuilder.AppendLine(fetchedPhrase.Hash + " [label=\"" + Grammar.PostfixToInfixParser(fetchedPhrase.SymbolString) + "\"];"); 133 } 134 122 135 ArchivedPhrases.Add(fetchedPhrase.Hash, currPhrase); 123 136 … … 135 148 var phraseHash = Grammar.CalcHashCode(newPhrase); 136 149 150 dotFileBuilder.AppendLine(fetchedPhrase.Hash + " -> " + phraseHash + " [label=\"" + expandedSymbol.StringRepresentation + "→" + productionAlternative + "\"];"); 151 137 152 if (newPhrase.IsSentence()) { // Sentence was generated. 138 153 SaveToAllSentences(phraseHash, newPhrase); … … 143 158 DistinctSentences[phraseHash] = newPhrase; 144 159 EvaluateSentence(newPhrase); 160 161 dotFileBuilder.AppendLine(phraseHash + " [label=\"" + Grammar.PostfixToInfixParser(newPhrase) + "\", style=\"filled\"];"); 145 162 } 146 163 UpdateView(AllSentences, DistinctSentences, Expansions); … … 152 169 } 153 170 } 171 172 dotFileBuilder.AppendLine(Grammar.CalcHashCode(BestTrainingSentence) + " [label=\"" + Grammar.PostfixToInfixParser(BestTrainingSentence) + "\", shape=Mcircle, style=\"filled,bold\"];"); 173 dotFileBuilder.AppendLine("}"); 174 175 System.IO.File.WriteAllText(Environment.GetFolderPath(System.Environment.SpecialFolder.DesktopDirectory)+ @"\searchgraph.dot", dotFileBuilder.ToString()); 154 176 155 177 UpdateView(AllSentences, DistinctSentences, Expansions, force: true); … … 257 279 } 258 280 #endregion 259 281 260 282 } 261 283 }
Note: See TracChangeset
for help on using the changeset viewer.