27 BigattiPivotStrategy::BigattiPivotStrategy() {
39 size_t var = _counts.getFirstMaxExponent();
46 virtual const char*
getName()
const {
47 return staticGetName();
50 static const char* staticGetName() {
75 virtual void driveMe() = 0;
77 void considerTypical() {
78 size_t count = _ideal->getTypicalExponent(_var, _exp);
83 void considerMostNonGeneric() {
84 _ideal->getMostNonGenericExponent(_var, _exp);
87 void considerTypicalNonGeneric() {
88 _ideal->getTypicalNonGenericExponent(_var, _exp);
91 void considerSomeNonGeneric() {
92 _ideal->getNonGenericExponent(_var, _exp);
95 void selectPurePower() {
99 _pivot.reset(_ideal->getVarCount());
106 _pivot = getMedian();
108 _pivot.reset(_ideal->getVarCount());
109 _ideal->getGcdAtExponent(_pivot, _var, _exp);
110 ASSERT(!_pivot.isIdentity());
116 _pivot = getMedian();
120 _ideal->singleDegreeSort(_var);
124 ASSERT(blockBegin != stop);
127 while ((*blockBegin)[_var] != _exp) {
129 ASSERT(blockBegin != stop);
131 ASSERT((*blockBegin)[_var] == _exp);
136 }
while (blockEnd != stop && (*blockEnd)[_var] == _exp);
142 _pivot.reset(_ideal->getVarCount());
144 Term lcm(_ideal->getVarCount());
145 for (; blockBegin != blockEnd; ++blockBegin) {
147 for (++it; it != blockEnd; ++it) {
148 lcm.lcm(*blockBegin, *it);
149 if (!_ideal->strictlyContains(
lcm)) {
156 _pivot.gcd(*blockBegin, *it);
158 _pivot.gcd(_pivot, *blockBegin);
159 _pivot.gcd(_pivot, *it);
169 ASSERT(!_pivot.isIdentity());
186 const Term& getMedian() {
187 return _median.getPivot(*_state);
194 class MostNGPurePivot :
public GenericPivotCommon {
196 virtual void driveMe() {
197 considerMostNonGeneric();
201 virtual const char* getName()
const {
202 return staticGetName();
205 static const char* staticGetName() {
210 class MostNGGcdPivot :
public GenericPivotCommon {
212 virtual void driveMe() {
213 considerMostNonGeneric();
217 virtual const char* getName()
const {
218 return staticGetName();
221 static const char* staticGetName() {
226 class MostNGTightPivot :
public GenericPivotCommon {
228 virtual void driveMe() {
229 considerMostNonGeneric();
233 virtual const char* getName()
const {
234 return staticGetName();
237 static const char* staticGetName() {
238 return "mostNGTight";
242 class TypicalNGPurePivot :
public GenericPivotCommon {
244 virtual void driveMe() {
245 considerTypicalNonGeneric();
249 virtual const char* getName()
const {
250 return staticGetName();
253 static const char* staticGetName() {
254 return "typicalNGPure";
258 class TypicalNGGcdPivot :
public GenericPivotCommon {
260 virtual void driveMe() {
261 considerTypicalNonGeneric();
265 virtual const char* getName()
const {
266 return staticGetName();
269 static const char* staticGetName() {
270 return "typicalNGGcd";
274 class TypicalNGTightPivot :
public GenericPivotCommon {
276 virtual void driveMe() {
277 considerTypicalNonGeneric();
281 virtual const char* getName()
const {
282 return staticGetName();
285 static const char* staticGetName() {
286 return "typicalNGTight";
290 class TypicalPurePivot :
public GenericPivotCommon {
292 virtual void driveMe() {
297 virtual const char* getName()
const {
298 return staticGetName();
301 static const char* staticGetName() {
302 return "typicalPure";
306 class TypicalGcdPivot :
public GenericPivotCommon {
308 virtual void driveMe() {
313 virtual const char* getName()
const {
314 return staticGetName();
317 static const char* staticGetName() {
322 class TypicalTightPivot :
public GenericPivotCommon {
324 virtual void driveMe() {
329 virtual const char* getName()
const {
330 return staticGetName();
333 static const char* staticGetName() {
334 return "typicalTight";
338 class SomeNGPurePivot :
public GenericPivotCommon {
340 virtual void driveMe() {
341 considerSomeNonGeneric();
345 virtual const char* getName()
const {
346 return staticGetName();
349 static const char* staticGetName() {
354 class SomeNGGcdPivot :
public GenericPivotCommon {
356 virtual void driveMe() {
357 considerSomeNonGeneric();
361 virtual const char* getName()
const {
362 return staticGetName();
365 static const char* staticGetName() {
370 class SomeNGTightPivot :
public GenericPivotCommon {
372 virtual void driveMe() {
373 considerSomeNonGeneric();
377 virtual const char* getName()
const {
378 return staticGetName();
381 static const char* staticGetName() {
382 return "someNGTight";
390 WidenPivot(auto_ptr<BigattiPivotStrategy> strategy):
391 _strategy(strategy) {
392 _name = _strategy->getName();
397 const Term& pivot = _strategy->getPivot(state);
403 virtual const char*
getName()
const {
404 return _name.c_str();
408 auto_ptr<BigattiPivotStrategy> _strategy;
415 StrategyFactory makeStrategyFactory() {
416 StrategyFactory factory(
"Bigatti et.al. pivot strategy");
418 nameFactoryRegister<MedianPivot>(factory);
420 nameFactoryRegister<TypicalPurePivot>(factory);
421 nameFactoryRegister<TypicalNGPurePivot>(factory);
422 nameFactoryRegister<MostNGPurePivot>(factory);
423 nameFactoryRegister<SomeNGPurePivot>(factory);
425 nameFactoryRegister<TypicalGcdPivot>(factory);
426 nameFactoryRegister<TypicalNGGcdPivot>(factory);
427 nameFactoryRegister<MostNGGcdPivot>(factory);
428 nameFactoryRegister<SomeNGGcdPivot>(factory);
430 nameFactoryRegister<TypicalTightPivot>(factory);
431 nameFactoryRegister<TypicalNGTightPivot>(factory);
432 nameFactoryRegister<MostNGTightPivot>(factory);
433 nameFactoryRegister<SomeNGTightPivot>(factory);
439 auto_ptr<BigattiPivotStrategy> BigattiPivotStrategy::
440 createStrategy(
const string& prefix,
bool widen) {
441 auto_ptr<BigattiPivotStrategy> strategy =
443 ASSERT(strategy.get() != 0);
446 strategy = auto_ptr<BigattiPivotStrategy>(
new WidenPivot(strategy));
auto_ptr< AbstractProduct > createWithPrefix(const NameFactory< AbstractProduct > &factory, const string &prefix)
Creates the unique product that has the indicated prefix, or create the actual product that has name ...
A BigattiPivotStrategy is an implementation of a pivot selection strategy for the Hilbert series algo...
virtual const Term & getPivot(BigattiState &state)=0
Returns the pivot of a pivot split of state.
virtual ~BigattiPivotStrategy()
virtual const char * getName() const =0
Returns the name of the strategy.
size_t getVarCount() const
const Ideal & getIdeal() const
Exponent getMedianPositiveExponentOf(size_t var)
Represents a monomial ideal with int exponents.
void getGcdOfMultiplesOf(Exponent *gcd, const Exponent *divisor)
Sets gcd to the greatest common divisor of those generators that are divisible by divisor.
Cont::const_iterator const_iterator
void getSupportCounts(Exponent *counts) const
counts[var] will be the number of generators divisible by var.
A NameFactory takes a name and then creates an instance of a class that has been previously registere...
Term represents a product of variables which does not include a coefficient.
void reset(size_t newVarCount)
void lcm(Word *res, const Word *resEnd, const Word *a, const Word *b)