Changeset 15803 for branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/GrammarEnumeration/GrammarEnumerationAlgorithm.cs
- Timestamp:
- 02/22/18 13:11:40 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/GrammarEnumeration/GrammarEnumerationAlgorithm.cs
r15800 r15803 25 25 private readonly string BestTrainingQualityName = "Best R² (Training)"; 26 26 private readonly string BestTrainingSolutionName = "Best solution (Training)"; 27 private readonly string SearchStructureSizeName = "Search Structure Size"; 28 private readonly string GeneratedPhrasesName = "Generated/Archived Phrases"; 27 29 private readonly string GeneratedSentencesName = "Generated Sentences"; 28 30 private readonly string DistinctSentencesName = "Distinct Sentences"; … … 115 117 116 118 using (TextWriterTraceListener dotFileTrace = new TextWriterTraceListener(new FileStream(dotFileName, FileMode.Create))) { 117 dotFileTrace.Write("digraph searchgraph {");119 LogSearchGraph(dotFileTrace, "digraph searchgraph {"); 118 120 119 121 OpenPhrases.Store(phrase0Hash, phrase0); … … 124 126 SymbolString currPhrase = fetchedPhrase.SymbolString; 125 127 126 dotFileTrace.Write( 127 $"{fetchedPhrase.Hash} [label=\"{Grammar.PostfixToInfixParser(fetchedPhrase.SymbolString)}\"];"); 128 LogSearchGraph(dotFileTrace, $"{fetchedPhrase.Hash} [label=\"{Grammar.PostfixToInfixParser(fetchedPhrase.SymbolString)}\"];"); 128 129 129 130 ArchivedPhrases.Add(fetchedPhrase.Hash, currPhrase); … … 142 143 var phraseHash = Grammar.CalcHashCode(newPhrase); 143 144 144 dotFileTrace.Write( 145 $"{fetchedPhrase.Hash} -> {phraseHash} [label=\"{expandedSymbol.StringRepresentation} + → {productionAlternative}\"];"); 145 LogSearchGraph(dotFileTrace, $"{fetchedPhrase.Hash} -> {phraseHash} [label=\"{expandedSymbol.StringRepresentation} + → {productionAlternative}\"];"); 146 146 147 147 if (newPhrase.IsSentence()) { … … 155 155 EvaluateSentence(newPhrase); 156 156 157 dotFileTrace.Write( 158 $"{phraseHash} [label=\"{Grammar.PostfixToInfixParser(newPhrase)}\", style=\"filled\"];"); 157 LogSearchGraph(dotFileTrace, $"{phraseHash} [label=\"{Grammar.PostfixToInfixParser(newPhrase)}\", style=\"filled\"];"); 159 158 } 160 159 UpdateView(AllSentences, DistinctSentences); … … 168 167 169 168 // 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];}}"); 173 171 dotFileTrace.Flush(); 174 172 } … … 219 217 Results.Add(new Result(BestTrainingQualityName, new DoubleValue(-1.0))); 220 218 219 Results.Add(new Result(GeneratedPhrasesName, new IntValue(0))); 220 Results.Add(new Result(SearchStructureSizeName, new IntValue(0))); 221 221 Results.Add(new Result(GeneratedSentencesName, new IntValue(0))); 222 222 Results.Add(new Result(DistinctSentencesName, new IntValue(0))); … … 234 234 if (force || updates % GuiUpdateInterval == 0) { 235 235 var allGeneratedEnum = allGenerated.Values.SelectMany(x => x).ToArray(); 236 ((IntValue)Results[GeneratedPhrasesName].Value).Value = ArchivedPhrases.Count; 237 ((IntValue)Results[SearchStructureSizeName].Value).Value = OpenPhrases.Count; 236 238 ((IntValue)Results[GeneratedSentencesName].Value).Value = allGeneratedEnum.Length; 237 239 ((IntValue)Results[DistinctSentencesName].Value).Value = distinctGenerated.Count; … … 277 279 Results.Add(new Result("Distinct generated sentences", new StringMatrix(distinctSentencesMatrix))); 278 280 } 281 282 private void LogSearchGraph(TraceListener listener, String msg) { 283 #if false 284 listener.Write(msg); 285 #endif 286 } 279 287 #endregion 280 288
Note: See TracChangeset
for help on using the changeset viewer.