27 _internalTracker(
"internal nodes"),
28 _leafTracker(
"leaf nodes") {
38 fputs(
"**** Slice Algorithm Statistics ****\n",
_out);
43 bool StatisticsStrategy::processSlice
45 _internalTracker.preliminaryRecord(*slice);
46 _leafTracker.preliminaryRecord(*slice);
48 bool wasBaseCase = _strategy->processSlice(tasks, slice);
51 _leafTracker.commitRecord();
53 _internalTracker.commitRecord();
87 _idealGenSum += _prelimIdealGenCount;
88 _subGenSum += _prelimSubGenCount;
89 _varSum += _prelimVarCount;
91 size_t genCountLog2 = 0;
92 if (_prelimIdealGenCount > 0)
93 genCountLog2 = (size_t)(log((
double)_prelimIdealGenCount) / log((
double)2));
94 _nodesByGenCount[genCountLog2] += 1;
98 fprintf(out,
"|-%s:\n", _title.c_str());
100 gmp_fprintf(out,
" | %Zd nodes\n", getNodeCount().get_mpz_t());
101 fprintf(out,
" | %f generators of ideal on avg.\n", getAvgIdealGenCount());
102 fprintf(out,
" | %f generators of subtract on avg.\n", getAvgSubGenCount());
103 fprintf(out,
" | %f variables of ambient ring on avg.\n", getAvgVarCount());
105 if (!_nodesByGenCount.empty()) {
106 fputs(
" |- nodes by log base 2 of ideal generator count:\n", out);
107 size_t genCountLog2 = _nodesByGenCount.rbegin()->first;
109 mpz_class nodeCount = 0;
110 map<size_t, mpz_class>::const_iterator it =
111 _nodesByGenCount.find(genCountLog2);
112 if (it != _nodesByGenCount.end())
113 nodeCount = it->second;
115 gmp_fprintf(out,
" | %Zd nodes has log2(#gens) = %Zd.\n",
116 nodeCount.get_mpz_t(),
117 mpz_class(genCountLog2).get_mpz_t());
119 if (genCountLog2 == 0)
134 mpq_class q = mpq_class(_idealGenSum) / _nodeCount;
143 mpq_class q = mpq_class(_subGenSum) / _nodeCount;
152 mpq_class q = mpq_class(_varSum) / _nodeCount;
virtual bool getUseSimplification() const =0
void preliminaryRecord(const Slice &slice)
Record information about slice, but store it only until this method is next called on this object...
virtual void setUseSimplification(bool use)
This method should only be called before calling run().
void commitRecord()
Commit the most recent argument to preliminaryTrack permanently to the record.
double getAvgIdealGenCount() const
This class represents a slice, which is the central data structure of the Slice Algorithm.
virtual void run(const Ideal &ideal)=0
Run the Slice algorithm.
virtual void run(const Ideal &ideal)
Run the Slice algorithm.
virtual ~StatisticsStrategy()
StatisticsStrategy(SliceStrategy *strategy, FILE *out)
Statistics are written to out, and every call is delegated to strategy.
const mpz_class & getNodeCount() const
Represents a monomial ideal with int exponents.
StatTracker _internalTracker
virtual void setUseIndependence(bool use)=0
This method should only be called before calling run().
SliceStrategy * _strategy
double getAvgVarCount() const
virtual void setUseSimplification(bool use)=0
This method should only be called before calling run().
TaskEngine handles a list of tasks that are to be carried out.
void printReport(FILE *out) const
Print a report on statistics of the recorded slices to the file out.
virtual void freeSlice(auto_ptr< Slice > slice)=0
It is allowed to delete returned slices directly, but it is better to use freeSlice.
size_t getVarCount() const
Returns the number of variables in the ambient ring.
virtual bool getUseSimplification() const
virtual void freeSlice(auto_ptr< Slice > slice)
It is allowed to delete returned slices directly, but it is better to use freeSlice.
This class describes the interface of a strategy object for the Slice Algorithm.
virtual void setUseIndependence(bool use)
This method should only be called before calling run().
StatTracker(const string &title)
The title parameter indicates what is to be printed when calling printReport().
Ideal & getSubtract()
Returns for a slice .
const Ideal & getIdeal() const
Returns for a slice .
double getAvgSubGenCount() const
size_t getGeneratorCount() const