Google OR-Tools v9.14
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
operations_research::DistributionStat Class Referenceabstract

#include <stats.h>

Inheritance diagram for operations_research::DistributionStat:
operations_research::Stat operations_research::DoubleDistribution operations_research::IntegerDistribution operations_research::RatioDistribution operations_research::TimeDistribution

Public Member Functions

 DistributionStat (absl::string_view name)
 DistributionStat ()
 DistributionStat (absl::string_view name, StatsGroup *group)
 ~DistributionStat () override
void Reset () override
 Reset this statistic to the same state as if it was newly created.
bool WorthPrinting () const override
 Is this stat worth printing? Usually false if nothing was measured.
std::string ValueAsString () const override=0
 Implemented by the subclasses.
double Sum () const override
 Trivial statistics on all the values added so far.
double Max () const
double Min () const
int64_t Num () const
double Average () const
 Get the average of the distribution or 0.0 if empty.
double StdDeviation () const
Public Member Functions inherited from operations_research::Stat
 Stat (absl::string_view name)
 Stat (absl::string_view name, StatsGroup *group)
 Also add this stat to the given group.
virtual ~Stat ()
std::string Name () const
 Only used for display purposes.
std::string StatString () const
virtual int Priority () const

Protected Member Functions

void AddToDistribution (double value)
 Adds a value to this sequence and updates the stats.

Protected Attributes

double sum_
double average_
double sum_squares_from_average_
double min_
double max_
int64_t num_

Detailed Description

Base class to track and compute statistics about the distribution of a sequence of double. We provide a few sub-classes below that differ in the way the values are added to the sequence and in the way the stats are printed.

Definition at line 178 of file stats.h.

Constructor & Destructor Documentation

◆ DistributionStat() [1/3]

operations_research::DistributionStat::DistributionStat ( absl::string_view name)
explicit

Definition at line 130 of file stats.cc.

◆ DistributionStat() [2/3]

operations_research::DistributionStat::DistributionStat ( )
inline

Definition at line 181 of file stats.h.

◆ DistributionStat() [3/3]

operations_research::DistributionStat::DistributionStat ( absl::string_view name,
StatsGroup * group )

Definition at line 139 of file stats.cc.

◆ ~DistributionStat()

operations_research::DistributionStat::~DistributionStat ( )
inlineoverride

Definition at line 183 of file stats.h.

Member Function Documentation

◆ AddToDistribution()

void operations_research::DistributionStat::AddToDistribution ( double value)
protected

Adds a value to this sequence and updates the stats.

Definition at line 157 of file stats.cc.

◆ Average()

double operations_research::DistributionStat::Average ( ) const

Get the average of the distribution or 0.0 if empty.

Definition at line 175 of file stats.cc.

◆ Max()

double operations_research::DistributionStat::Max ( ) const
inline

Definition at line 192 of file stats.h.

◆ Min()

double operations_research::DistributionStat::Min ( ) const
inline

Definition at line 193 of file stats.h.

◆ Num()

int64_t operations_research::DistributionStat::Num ( ) const
inline

Definition at line 194 of file stats.h.

◆ Reset()

void operations_research::DistributionStat::Reset ( )
overridevirtual

Reset this statistic to the same state as if it was newly created.

Implements operations_research::Stat.

Definition at line 148 of file stats.cc.

◆ StdDeviation()

double operations_research::DistributionStat::StdDeviation ( ) const

Get the standard deviation of the distribution or 0.0 if empty. We use the on-line algorithm of Welford described at http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance

Todo
(user): We could also use on top the Kahan summation algorithm to be even more precise but a bit slower too.

Definition at line 177 of file stats.cc.

◆ Sum()

double operations_research::DistributionStat::Sum ( ) const
inlineoverridevirtual

Trivial statistics on all the values added so far.

Reimplemented from operations_research::Stat.

Definition at line 191 of file stats.h.

◆ ValueAsString()

std::string operations_research::DistributionStat::ValueAsString ( ) const
overridepure virtual

◆ WorthPrinting()

bool operations_research::DistributionStat::WorthPrinting ( ) const
inlineoverridevirtual

Is this stat worth printing? Usually false if nothing was measured.

Implements operations_research::Stat.

Definition at line 185 of file stats.h.

Member Data Documentation

◆ average_

double operations_research::DistributionStat::average_
protected

Definition at line 210 of file stats.h.

◆ max_

double operations_research::DistributionStat::max_
protected

Definition at line 213 of file stats.h.

◆ min_

double operations_research::DistributionStat::min_
protected

Definition at line 212 of file stats.h.

◆ num_

int64_t operations_research::DistributionStat::num_
protected

Definition at line 214 of file stats.h.

◆ sum_

double operations_research::DistributionStat::sum_
protected

Definition at line 209 of file stats.h.

◆ sum_squares_from_average_

double operations_research::DistributionStat::sum_squares_from_average_
protected

Definition at line 211 of file stats.h.


The documentation for this class was generated from the following files: