Changeset 15843
- Timestamp:
- 03/16/18 10:41:38 (7 years ago)
- Location:
- branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/Analysis/SentenceLogger.cs
r15821 r15843 7 7 namespace HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration { 8 8 class SentenceLogger : Item, IGrammarEnumerationAnalyzer { 9 private readonly string distinctSentencesFileName = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + @"\distinctSentences.csv"; 10 private readonly string allSentencesFileName = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + @"\allSentences.csv"; 9 private readonly string workingDir = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); 11 10 private readonly string columnDelimiter = ";"; 12 private readonly string header = "infix;postfix;hash"; 11 private readonly string header = "hash;length;postfix;infix"; 12 13 private string distinctSentencesFileName; 14 private string allSentencesFileName; 15 private string shortestDistinctSentencesFileName; 13 16 14 17 private TextWriterTraceListener distinctSentencesFileTrace; … … 42 45 43 46 private void GrammarEnumerationAlgorithmOnStarted(object sender, EventArgs eventArgs) { 47 string datePostfix = $"_{DateTime.Now:yyyy-MM-dd_HH-mm}_TreeSize-{((GrammarEnumerationAlgorithm) sender).MaxTreeSize}.csv"; 48 distinctSentencesFileName = workingDir + @"\distinctSentences" + datePostfix; 49 allSentencesFileName = workingDir + @"\allSentences" + datePostfix; 50 shortestDistinctSentencesFileName = workingDir + @"\shortestDistinctSentences" + datePostfix; 51 44 52 distinctSentencesFileTrace = new TextWriterTraceListener(new FileStream(distinctSentencesFileName, FileMode.Create)); 45 53 allSentencesFileTrace = new TextWriterTraceListener(new FileStream(allSentencesFileName, FileMode.Create)); … … 47 55 ((StreamWriter)allSentencesFileTrace.Writer).AutoFlush = true; 48 56 49 distinctSentencesFileTrace.WriteLine(header);50 57 allSentencesFileTrace.WriteLine(header); 51 58 } … … 54 61 distinctSentencesFileTrace.Close(); 55 62 allSentencesFileTrace.Close(); 63 64 // Remove duplicates afterwards using bash commands from the git bash 65 string bashExecutable = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\Programs\Git\git-bash.exe"; 66 67 string commandCreate = $"echo \"{header}\" > {shortestDistinctSentencesFileName.Replace("\\", "/")}"; 68 string commandFill = $"sort -s {distinctSentencesFileName.Replace("\\", "/")} | uniq -w 10 >> {shortestDistinctSentencesFileName.Replace("\\", "/")}"; 69 70 ProcessStartInfo startInfo = new ProcessStartInfo { 71 WindowStyle = ProcessWindowStyle.Hidden, 72 UseShellExecute = false, 73 CreateNoWindow = true, 74 FileName = bashExecutable, 75 RedirectStandardError = true, 76 RedirectStandardOutput = true, 77 Arguments = $"-c '{commandCreate};{commandFill}'" 78 }; 79 Process.Start(startInfo); 56 80 } 57 81 58 82 private void DistinctSentenceGenerated(object sender, PhraseAddedEventArgs phraseAddedEventArgs) { 59 83 distinctSentencesFileTrace.WriteLine(ToCsvLine( 60 ((GrammarEnumerationAlgorithm)sender).Grammar.ToInfixString(phraseAddedEventArgs.NewPhrase), 84 ((uint)phraseAddedEventArgs.NewHash).ToString("D10"), 85 phraseAddedEventArgs.NewPhrase.Count().ToString("D3"), 61 86 phraseAddedEventArgs.NewPhrase.ToString(), 62 phraseAddedEventArgs.NewHash.ToString()));87 ((GrammarEnumerationAlgorithm)sender).Grammar.ToInfixString(phraseAddedEventArgs.NewPhrase))); 63 88 } 64 89 65 90 private void SentenceGenerated(object sender, PhraseAddedEventArgs phraseAddedEventArgs) { 66 91 allSentencesFileTrace.WriteLine(ToCsvLine( 67 ((GrammarEnumerationAlgorithm)sender).Grammar.ToInfixString(phraseAddedEventArgs.NewPhrase), 92 ((uint)phraseAddedEventArgs.NewHash).ToString("D10"), 93 phraseAddedEventArgs.NewPhrase.Count().ToString("D3"), 68 94 phraseAddedEventArgs.NewPhrase.ToString(), 69 phraseAddedEventArgs.NewHash.ToString()));95 ((GrammarEnumerationAlgorithm)sender).Grammar.ToInfixString(phraseAddedEventArgs.NewPhrase))); 70 96 } 71 97 -
branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/GrammarEnumeration/GrammarEnumerationAlgorithm.cs
r15842 r15843 98 98 99 99 Parameters.Add(new ValueParameter<IntValue>(MaxTreeSizeParameterName, "The number of clusters.", new IntValue(6))); 100 Parameters.Add(new ValueParameter<IntValue>(GuiUpdateIntervalParameterName, "Number of generated sentences, until GUI is refreshed.", new IntValue(1000 )));100 Parameters.Add(new ValueParameter<IntValue>(GuiUpdateIntervalParameterName, "Number of generated sentences, until GUI is refreshed.", new IntValue(100000))); 101 101 Parameters.Add(new ValueParameter<EnumValue<StorageType>>(SearchDataStructureParameterName, new EnumValue<StorageType>(StorageType.Stack))); 102 102 -
branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration.csproj
r15832 r15843 17 17 <DebugType>full</DebugType> 18 18 <Optimize>false</Optimize> 19 <OutputPath>..\..\ trunk\bin\</OutputPath>19 <OutputPath>..\..\..\trunk\bin\</OutputPath> 20 20 <DefineConstants>DEBUG;TRACE</DefineConstants> 21 21 <ErrorReport>prompt</ErrorReport>
Note: See TracChangeset
for help on using the changeset viewer.