StatisticsStrategy.h
Go to the documentation of this file.
/* Frobby: Software for monomial ideal computations.
Copyright (C) 2007 Bjarke Hammersholt Roune (www.broune.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see http://www.gnu.org/licenses/.
*/
#ifndef STATISTICS_STRATEGY
#define STATISTICS_STRATEGY
#include "SliceStrategy.h"
#include <map>
class StatisticsStrategy : public SliceStrategy {
public:
StatisticsStrategy(SliceStrategy* strategy, FILE* out);
virtual ~StatisticsStrategy();
virtual void run(const Ideal& ideal);
virtual bool processSlice(TaskEngine& tasks, unique_ptr<Slice> slice);
virtual void setUseIndependence(bool use);
virtual void setUseSimplification(bool use);
virtual bool getUseSimplification() const;
virtual void freeSlice(unique_ptr<Slice> slice);
private:
SliceStrategy* _strategy;
FILE* _out;
struct StatTracker {
StatTracker(const string& title);
void preliminaryRecord(const Slice& slice);
void commitRecord();
void printReport(FILE* out) const;
const mpz_class& getNodeCount() const;
double getAvgIdealGenCount() const;
double getAvgSubGenCount() const;
double getAvgVarCount() const;
private:
string _title;
size_t _prelimIdealGenCount;
size_t _prelimSubGenCount;
size_t _prelimVarCount;
mpz_class _nodeCount;
mpz_class _idealGenSum;
mpz_class _subGenSum;
mpz_class _varSum;
map<size_t, mpz_class> _nodesByGenCount;
};
StatTracker _internalTracker;
StatTracker _leafTracker;
};
#endif
SliceStrategy.h
Ideal
Represents a monomial ideal with int exponents.
Definition Ideal.h:27
SliceStrategy
This class describes the interface of a strategy object for the Slice Algorithm.
Definition SliceStrategy.h:33
Slice
This class represents a slice, which is the central data structure of the Slice Algorithm.
Definition Slice.h:77
StatisticsStrategy::_leafTracker
StatTracker _leafTracker
Definition StatisticsStrategy.h:91
StatisticsStrategy::setUseSimplification
virtual void setUseSimplification(bool use)
This method should only be called before calling run().
Definition StatisticsStrategy.cpp:62
StatisticsStrategy::freeSlice
virtual void freeSlice(unique_ptr< Slice > slice)
It is allowed to delete returned slices directly, but it is better to use freeSlice.
Definition StatisticsStrategy.cpp:70
StatisticsStrategy::run
virtual void run(const Ideal &ideal)
Run the Slice algorithm.
Definition StatisticsStrategy.cpp:35
StatisticsStrategy::processSlice
virtual bool processSlice(TaskEngine &tasks, unique_ptr< Slice > slice)
Process the parameter slice.
Definition StatisticsStrategy.cpp:44
StatisticsStrategy::StatisticsStrategy
StatisticsStrategy(SliceStrategy *strategy, FILE *out)
Statistics are written to out, and every call is delegated to strategy.
Definition StatisticsStrategy.cpp:24
StatisticsStrategy::getUseSimplification
virtual bool getUseSimplification() const
Definition StatisticsStrategy.cpp:66
StatisticsStrategy::_internalTracker
StatTracker _internalTracker
Definition StatisticsStrategy.h:90
StatisticsStrategy::setUseIndependence
virtual void setUseIndependence(bool use)
This method should only be called before calling run().
Definition StatisticsStrategy.cpp:58
StatisticsStrategy::_out
FILE * _out
Definition StatisticsStrategy.h:46
StatisticsStrategy::_strategy
SliceStrategy * _strategy
Definition StatisticsStrategy.h:45
TaskEngine
TaskEngine handles a list of tasks that are to be carried out.
Definition TaskEngine.h:40
StatisticsStrategy::StatTracker::printReport
void printReport(FILE *out) const
Print a report on statistics of the recorded slices to the file out.
Definition StatisticsStrategy.cpp:97
StatisticsStrategy::StatTracker::_nodeCount
mpz_class _nodeCount
Definition StatisticsStrategy.h:80
StatisticsStrategy::StatTracker::StatTracker
StatTracker(const string &title)
The title parameter indicates what is to be printed when calling printReport().
Definition StatisticsStrategy.cpp:74
StatisticsStrategy::StatTracker::_varSum
mpz_class _varSum
Definition StatisticsStrategy.h:83
StatisticsStrategy::StatTracker::getAvgVarCount
double getAvgVarCount() const
Definition StatisticsStrategy.cpp:148
StatisticsStrategy::StatTracker::_subGenSum
mpz_class _subGenSum
Definition StatisticsStrategy.h:82
StatisticsStrategy::StatTracker::_prelimSubGenCount
size_t _prelimSubGenCount
Definition StatisticsStrategy.h:77
StatisticsStrategy::StatTracker::_prelimVarCount
size_t _prelimVarCount
Definition StatisticsStrategy.h:78
StatisticsStrategy::StatTracker::_idealGenSum
mpz_class _idealGenSum
Definition StatisticsStrategy.h:81
StatisticsStrategy::StatTracker::getNodeCount
const mpz_class & getNodeCount() const
Definition StatisticsStrategy.cpp:126
StatisticsStrategy::StatTracker::getAvgSubGenCount
double getAvgSubGenCount() const
Definition StatisticsStrategy.cpp:139
StatisticsStrategy::StatTracker::commitRecord
void commitRecord()
Commit the most recent argument to preliminaryTrack permanently to the record.
Definition StatisticsStrategy.cpp:84
StatisticsStrategy::StatTracker::_nodesByGenCount
map< size_t, mpz_class > _nodesByGenCount
_nodesByGenCount[l] records how many slices have been recorded whose ideal has approximately 2^l gene...
Definition StatisticsStrategy.h:87
StatisticsStrategy::StatTracker::getAvgIdealGenCount
double getAvgIdealGenCount() const
Definition StatisticsStrategy.cpp:130
StatisticsStrategy::StatTracker::_title
string _title
Definition StatisticsStrategy.h:74
StatisticsStrategy::StatTracker::_prelimIdealGenCount
size_t _prelimIdealGenCount
Definition StatisticsStrategy.h:76
StatisticsStrategy::StatTracker::preliminaryRecord
void preliminaryRecord(const Slice &slice)
Record information about slice, but store it only until this method is next called on this object.
Definition StatisticsStrategy.cpp:78