Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/SentenceSetStatistics.cs @ 11727

Last change on this file since 11727 was 11727, checked in by gkronber, 8 years ago

#2283: worked on grammatical optimization problem solvers (simple MCTS done)

File size: 1.6 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Threading.Tasks;
6
7namespace HeuristicLab.Problems.GrammaticalOptimization {
8  public class SentenceSetStatistics {
9    public int NumberOfSentences { get; private set; }
10    public string BestSentence { get; private set; }
11    public string FirstSentence { get; private set; }
12    public string LastSentence { get; private set; }
13    public double BestSentenceQuality { get; private set; }
14    public double FirstSentenceQuality { get; private set; }
15    public double LastSentenceQuality { get; private set; }
16    public double AverageQuality { get { return sumQualities / NumberOfSentences; } }
17    // public double MedianQuality { get; private set; }
18    private double sumQualities;
19
20    public void AddSentence(string sentence, double quality) {
21      if (NumberOfSentences == 0) {
22        FirstSentence = sentence;
23        FirstSentenceQuality = quality;
24      }
25
26      if (quality > BestSentenceQuality) {
27        BestSentence = sentence;
28        BestSentenceQuality = quality;
29      }
30
31      sumQualities += quality;
32      NumberOfSentences++;
33
34      LastSentence = sentence;
35      LastSentenceQuality = quality;
36    }
37
38    public override string ToString() {
39      return
40        string.Format("Sentences: {0,10} avg.-quality {1,7:F5} best {2,7:F5} {3} first {4,7:F5} {5} last {6,7:F5} {7}",
41      NumberOfSentences, AverageQuality,
42      BestSentenceQuality, BestSentence,
43      FirstSentenceQuality, FirstSentence,
44      LastSentenceQuality, LastSentence
45     );
46    }
47  }
48}
Note: See TracBrowser for help on using the repository browser.