Frobby  0.9.5
StatisticsStrategy.h
Go to the documentation of this file.
1 /* Frobby: Software for monomial ideal computations.
2  Copyright (C) 2007 Bjarke Hammersholt Roune (www.broune.com)
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program. If not, see http://www.gnu.org/licenses/.
16 */
17 #ifndef STATISTICS_STRATEGY
18 #define STATISTICS_STRATEGY
19 
20 #include "SliceStrategy.h"
21 
22 #include <map>
23 
27 class StatisticsStrategy : public SliceStrategy {
28  public:
31  StatisticsStrategy(SliceStrategy* strategy, FILE* out);
32  virtual ~StatisticsStrategy();
33 
34  virtual void run(const Ideal& ideal);
35 
36  virtual bool processSlice(TaskEngine& tasks, auto_ptr<Slice> slice);
37 
38  virtual void setUseIndependence(bool use);
39  virtual void setUseSimplification(bool use);
40  virtual bool getUseSimplification() const;
41 
42  virtual void freeSlice(auto_ptr<Slice> slice);
43 
44  private:
46  FILE* _out;
47 
49  struct StatTracker {
53  StatTracker(const string& title);
54 
58  void preliminaryRecord(const Slice& slice);
59 
62  void commitRecord();
63 
66  void printReport(FILE* out) const;
67 
68  const mpz_class& getNodeCount() const;
69  double getAvgIdealGenCount() const;
70  double getAvgSubGenCount() const;
71  double getAvgVarCount() const;
72 
73  private:
74  string _title;
75 
79 
80  mpz_class _nodeCount;
81  mpz_class _idealGenSum;
82  mpz_class _subGenSum;
83  mpz_class _varSum;
84 
87  map<size_t, mpz_class> _nodesByGenCount;
88  };
89 
92 };
93 
94 #endif
Represents a monomial ideal with int exponents.
Definition: Ideal.h:27
This class describes the interface of a strategy object for the Slice Algorithm.
Definition: SliceStrategy.h:33
virtual void setUseSimplification(bool use)=0
This method should only be called before calling run().
virtual void freeSlice(auto_ptr< Slice > slice)=0
It is allowed to delete returned slices directly, but it is better to use freeSlice.
virtual void setUseIndependence(bool use)=0
This method should only be called before calling run().
virtual bool processSlice(TaskEngine &tasks, auto_ptr< Slice > slice)=0
Process the parameter slice.
virtual bool getUseSimplification() const =0
virtual void run(const Ideal &ideal)=0
Run the Slice algorithm.
This class represents a slice, which is the central data structure of the Slice Algorithm.
Definition: Slice.h:77
StatisticsStrategy(SliceStrategy *strategy, FILE *out)
Statistics are written to out, and every call is delegated to strategy.
StatTracker _internalTracker
SliceStrategy * _strategy
TaskEngine handles a list of tasks that are to be carried out.
Definition: TaskEngine.h:40
Tracks statistics on slices.
void printReport(FILE *out) const
Print a report on statistics of the recorded slices to the file out.
StatTracker(const string &title)
The title parameter indicates what is to be printed when calling printReport().
const mpz_class & getNodeCount() const
void commitRecord()
Commit the most recent argument to preliminaryTrack permanently to the record.
map< size_t, mpz_class > _nodesByGenCount
_nodesByGenCount[l] records how many slices have been recorded whose ideal has approximately 2^l gene...
void preliminaryRecord(const Slice &slice)
Record information about slice, but store it only until this method is next called on this object.