[mathicgb] 20/393: Removed support for stopping siggb computations early on a Grobner basis since if turning that option on was a win, then using classic buchberger was better in all our experiments and the feature was complex.

Doug Torrance dtorrance-guest at moszumanska.debian.org
Fri Apr 3 15:58:25 UTC 2015


This is an automated email from the git hooks/post-receive script.

dtorrance-guest pushed a commit to branch upstream
in repository mathicgb.

commit a35d196598b5100ec80ec7bb6fd84781ec8f3435
Author: Bjarke Hammersholt Roune <bjarkehr.code at gmail.com>
Date:   Tue Aug 7 17:56:23 2012 -0400

    Removed support for stopping siggb computations early on a Grobner basis since if turning that option on was a win, then using classic buchberger was better in all our experiments and the feature was complex.
---
 src/cli/GBMain.cpp            |  10 --
 src/mathicgb/SPairHandler.cpp | 238 ------------------------------------------
 src/mathicgb/SPairHandler.hpp |  27 -----
 src/mathicgb/SignatureGB.cpp  |   9 +-
 src/mathicgb/SignatureGB.hpp  |   5 -
 src/test/gb-test.cpp          |  37 +++----
 6 files changed, 16 insertions(+), 310 deletions(-)

diff --git a/src/cli/GBMain.cpp b/src/cli/GBMain.cpp
index bb4be44..7be7e50 100755
--- a/src/cli/GBMain.cpp
+++ b/src/cli/GBMain.cpp
@@ -55,12 +55,6 @@ public:
       "Postpone the construction of Koszul syzygy signatures.",
       true),
 
-    mComputeSignatureBasis("computeSignatureBasis",
-      "Compute a signature basis. If false and using the signature "
-      "algorithm, stop the computation early when detecting "
-      "a grobner basis.",
-      true),
-
     mUseBaseDivisors("useBaseDivisors",
       "Use high ratio and low ratio base divisors to eliminate "
       "S-spairs quickly based on signature.",
@@ -153,7 +147,6 @@ public:
     case 8: mStrategy.processArgument(tokens[6]);
       mClassicBuchbergerAlgorithm.setValue((mStrategy.value() &  1) == 1);
       mPostponeKoszul.setValue((mStrategy.value() &  2) != 0);
-      mComputeSignatureBasis.setValue((mStrategy.value() &  8) != 0);
       mUseBaseDivisors.setValue((mStrategy.value() & 16) != 0);
     case 7: mTracingLevel.processArgument(tokens[5]);
     case 6: // ignore this value
@@ -216,7 +209,6 @@ public:
         mSPairQueue.value());
       alg.setBreakAfter(mBreakAfter.value());
       alg.setPrintInterval(mPrintInterval.value());
-      alg.setComputeSignatureBasis(mComputeSignatureBasis.value());
       alg.computeGrobnerBasis();
 
       // print statistics
@@ -268,7 +260,6 @@ public:
     parameters.push_back(&mAutoTopReduce);
     parameters.push_back(&mClassicBuchbergerAlgorithm);
     parameters.push_back(&mPostponeKoszul);
-    parameters.push_back(&mComputeSignatureBasis);
     parameters.push_back(&mUseBaseDivisors);
     parameters.push_back(&mSPairQueue);
     parameters.push_back(&mTracingLevel);
@@ -292,7 +283,6 @@ private:
   mic::BoolParameter mAutoTopReduce;
   mic::BoolParameter mClassicBuchbergerAlgorithm;
   mic::BoolParameter mPostponeKoszul;
-  mic::BoolParameter mComputeSignatureBasis;
   mic::BoolParameter mUseBaseDivisors;
   mic::IntegerParameter mSPairQueue;
   mic::IntegerParameter mTracingLevel;
diff --git a/src/mathicgb/SPairHandler.cpp b/src/mathicgb/SPairHandler.cpp
index f3c4468..6df1cc3 100755
--- a/src/mathicgb/SPairHandler.cpp
+++ b/src/mathicgb/SPairHandler.cpp
@@ -44,10 +44,6 @@ SPairHandler::SPairHandler(
   bool useSingularCriterionEarly,
   size_t queueType
 ):
-  mTrackEssentialPair(false),
-  mEssentialFirst(static_cast<size_t>(-1)),
-  mEssentialSecond(static_cast<size_t>(-1)),
-  mEssentialSig(R0->allocMonomial()),
   R(R0),
   F(F0),
   mUseSingularCriterionEarly(useSingularCriterionEarly),
@@ -63,224 +59,12 @@ SPairHandler::SPairHandler(
 SPairHandler::~SPairHandler()
 {
   ASSERT(mUseBaseDivisors || mUseHighBaseDivisors || mKnownSyzygyTri.empty());
-  R->freeMonomial(mEssentialSig);
-}
-
-bool SPairHandler::hasEssentialPair() const { 
-  ASSERT(mTrackEssentialPair);
-  bool value = (mEssentialFirst < GB->size());
-  ASSERT(!value || isEssential(mEssentialFirst, mEssentialSecond));
-  return value;
 }
 
 void SPairHandler::newSyzygy(const_monomial sig) {
   ASSERT(Hsyz->member(sig));
 }
 
-bool SPairHandler::isEssential(size_t a, size_t b) const {
-  ASSERT(mTrackEssentialPair);
-  bool minA = GB->basis().leadMinimal(a);
-  bool minB = GB->basis().leadMinimal(b);
-  if (minA && minB)
-    return true;
-  if (!minA && !minB)
-    return false;
-  if (!minA)
-    std::swap(a, b);
-  ASSERT(GB->basis().leadMinimal(a));
-  ASSERT(!GB->basis().leadMinimal(b));
-  if (mDidReducingSPair[b])
-    return false;
-  return R->monomialIsDivisibleBy
-    (GB->getLeadMonomial(b), GB->getLeadMonomial(a));
-}
-
-void SPairHandler::setTrackEssentialPair(bool value) {
-  if (value == mTrackEssentialPair)
-    return;
-  mTrackEssentialPair = value;
-  if (mTrackEssentialPair) {
-    ASSERT(mEssentialPoly.get() == 0);
-    while (mDidReducingSPair.size() < GB->size())
-      mDidReducingSPair.push_back(false);
-    mEssentialFirst = 0;
-    mEssentialSecond = static_cast<size_t>(-1);
-    if (GB->size() > 0)
-      nextEssentialPair();
-  } else {
-    mEssentialPoly.reset(0);
-    mEssentialFirst = static_cast<size_t>(-1);
-    mEssentialSecond = static_cast<size_t>(-1);
-  }
-}
-
-void SPairHandler::nextEssentialPair() {
-  ASSERT(mTrackEssentialPair);
-  ASSERT(mEssentialFirst < GB->size());
-  ASSERT(mEssentialSecond == static_cast<size_t>(-1) ||
-    mEssentialSecond < mEssentialFirst);
-
-  if (mEssentialPoly.get() != 0)
-    mEssentialPoly.reset(0);
-
-  // If the queue is empty, we don't know what the next signature will be,
-  // so we don't know what has been shown to reduce to zero, which means
-  // we can't proceed. The queue can be empty without the computation
-  // being done if the last S-pair does not reduce to zero, and this
-  // method gets called between the last S-pair being popped and the
-  // new basis element being inserted.
-  ASSERT(!mTri.empty());
-  const_monomial currentSig = mTri.topOrderBy();
-  const size_t basisElementCount = GB->size();
-
-  size_t& first = mEssentialFirst;
-  size_t& second = mEssentialSecond;
-  bool firstIteration = true;
-  while (true) {
-    if (!mDidReducingSPair[first] &&
-      !firstIteration &&
-      !GB->basis().leadMinimal(first)) {
-      ASSERT(R->monomialIsDivisibleBy
-        (GB->getLeadMonomial(first), GB->getLeadMonomial(second)));
-      mDidReducingSPair[first] = true;
-      second = first; // move on to next first
-    } else {
-nextIteration:
-      firstIteration = false;
-      ++second;
-    }
-    // ** move on to next S-pair
-    // Setting mEssentialSecond to -1 instructs this method to search the
-    // S-pairs with the given mEssentialFirst starting at the first one.
-    if (first == second) {
-      ++first;
-      if (first == basisElementCount) {
-        second = static_cast<size_t>(-1); // start at zero next time
-        break; // no more S-pairs to check for now
-      }
-      second = 0;
-    }
-
-    // Let
-    //   A = the set of basis elements with minimal lead term
-    //   B = the set of basis elements with non-minimal lead term
-    //   G = the union of A and B
-    //   P' = the set of pairs (a,b) in AxB such that lead(a)|lead(b)
-    //   P = The union of AxA and P'
-    // We say that an S-pair is essential if it is a member of P.
-
-    // Skip pair if not a member of P since we only need the S-polynomials of
-    // members of P to reduce to zero. We can skip all the other S-pairs in GxG
-    // due to Buchberger's second criterion (lcm criterion).
-
-    if (!GB->basis().leadMinimal(first)) {
-      if (mDidReducingSPair[first]) {
-        second = first - 1;
-        continue;
-      }
-      for (; second < first; ++second) {
-        if (GB->basis().leadMinimal(second) &&
-          R->monomialIsDivisibleBy
-          (GB->getLeadMonomial(first), GB->getLeadMonomial(second))) {
-          ASSERT(isEssential(first, second));
-          break;
-        }
-        ASSERT(!isEssential(first, second));
-      }
-    } else {
-      for (; second < first; ++second) {
-        if (GB->basis().leadMinimal(second))
-          break;
-        if (!mDidReducingSPair[second] &&
-          R->monomialIsDivisibleBy
-            (GB->getLeadMonomial(second), GB->getLeadMonomial(first))) {
-          ASSERT(isEssential(first, second));
-          break;
-        }
-        ASSERT(!isEssential(first, second));
-      }
-    }
-
-    if (second == first) {
-      --second; // as it is incremented at top of loop
-      goto nextIteration; // todo: we really need to improve the code structure here
-    }
-    ASSERT(isEssential(first, second));
-
-    ASSERT(mTrackEssentialPair);
-    bool minFirst = GB->basis().leadMinimal(first);
-    bool minSecond = GB->basis().leadMinimal(second);
-    if (minFirst) {
-      if (!minSecond) {
-        if (!R->monomialIsDivisibleBy
-          (GB->getLeadMonomial(second), GB->getLeadMonomial(first))) {
-          ASSERT(!isEssential(first, second));
-          continue;
-        }
-      }
-    } else {
-      if (!minSecond) {
-        ASSERT(!isEssential(first, second));
-        continue;
-      }
-      if (!R->monomialIsDivisibleBy
-        (GB->getLeadMonomial(first), GB->getLeadMonomial(second))) {
-        ASSERT(!isEssential(first, second));
-        continue;
-      }
-    }
-    ASSERT(isEssential(first, second));
-    //if (!isEssential(first, second))
-    //  continue;
-
-    // Use buchberger's first criterion: skip S-pairs whose leading terms
-    // are relatively prime.
-    if (R->monomialRelativelyPrime(
-      GB->getLeadMonomial(first),
-      GB->getLeadMonomial(second)))
-      continue;
-
-    // Use Buchberger's second criterion (lcm criterion).
-    if (GB->basis().buchbergerLcmCriterion(first, second))
-      continue;
-
-    // Skip pair if signature less than or equal to current signature, as
-    // then the S-polynomial has been reduced to zero. Note that it is not
-    // relevant if the signature of the S-pair is an element of the initial
-    // syzygy submodule, as that only implies that the S-pair will reduce to
-    // once we get to its signature. It does not imply that the S-pair reduces
-    // to zero right now.
-    //
-    // Usually in the Signature Buchberger Algorithm, it is not OK for
-    // the signature of the two halves of the S-pair to be equal.
-    // So those S-pairs are usually discarded. We can't do that here.
-    size_t greater = first;
-    size_t smaller = second;
-    if (GB->ratioCompare(greater, smaller) == LT)
-      std::swap(greater, smaller);
-    R->monomialFindSignature(
-      GB->getLeadMonomial(greater),
-      GB->getLeadMonomial(smaller),
-      GB->getSignature(greater),
-      mEssentialSig); // Set mEssentialSig to signature of S-pair
-
-    if (F->signatureCompare(mEssentialSig, currentSig) == LT)
-      continue;
-
-    mEssentialPoly = mReducer->classicReduceSPoly
-      (GB->poly(first), GB->poly(second), GB->basis());
-    ASSERT(mEssentialPoly.get() != 0);
-    if (mEssentialPoly->isZero()) {
-      mEssentialPoly.reset(0);
-      continue;
-    }
-
-    // (first, second) is an essential pair that we cannot prove reduces
-    // to zero.
-    break; 
-  }
-}
-
 SPairHandler::Stats SPairHandler::getStats() const
 {
   F->getStats(mStats.comparisons, mStats.precomparisons);
@@ -324,28 +108,6 @@ void SPairHandler::newPairs(size_t newGen)
   makePreSPairs(newGen);
   mTri.endColumn();
 
-  if (mTrackEssentialPair) {
-    ASSERT(mDidReducingSPair.size() == newGen);
-    mDidReducingSPair.push_back(false);
-    if (!mTri.empty()) {
-      ASSERT(mEssentialFirst < newGen ||
-        mEssentialSecond == static_cast<size_t>(-1));
-      if (mEssentialPoly.get() == 0 ||
-        R->monomialIsDivisibleBy
-          (mEssentialPoly->getLeadMonomial(), GB->getLeadMonomial(newGen))) {
-        if (mEssentialFirst < newGen)
-          --mEssentialSecond;
-        nextEssentialPair();
-      }
-#ifdef DEBUG
-      else {
-        ASSERT(GB->basis().divisor(mEssentialPoly->getLeadMonomial()) ==
-          static_cast<size_t>(-1));
-      }
-#endif
-    }
-  }
-
   ASSERT((!mUseBaseDivisors && !mUseHighBaseDivisors) ||
     mKnownSyzygyTri.columnCount() == newGen + 1);
 }
diff --git a/src/mathicgb/SPairHandler.hpp b/src/mathicgb/SPairHandler.hpp
index 6f69c69..adc699f 100755
--- a/src/mathicgb/SPairHandler.hpp
+++ b/src/mathicgb/SPairHandler.hpp
@@ -21,7 +21,6 @@ class GroebnerBasis;
 class FreeModuleOrder;
 class Reducer;
 
-
 class SPairHandler
 {
 public:
@@ -44,13 +43,6 @@ public:
   // fills in all the S-pairs with i.
   void newPairs(size_t i);
 
-  // Set to true to enable hasEssentialPair().
-  void setTrackEssentialPair(bool value);
-
-  // Returns true if any essential pairs are yet to be popped. Requires
-  // tracking of essential pairs to be turned on.
-  bool hasEssentialPair() const;
-
   // Inform the S-pair handler that there is a new syzygy signature in play.
   void newSyzygy(const_monomial sig);
 
@@ -101,25 +93,6 @@ public:
   std::string name();
 
 private:
-  void nextEssentialPair();
-  bool isEssential(size_t a, size_t b) const;
-
-  // If there is no essential pair, then essentialFirst == GB->size().
-  // Otherwise (a,b)=(essentialFirst, essentialSecond) is an essential
-  // S-pair such that a > b. Among all essential S-pairs, a is minimal
-  // and b is maximal.
-  bool mTrackEssentialPair; // whether to keep track of an essential pair
-  size_t mEssentialFirst; // first generator of the essential pair
-  size_t mEssentialSecond; // second generator of the essential pair
-  monomial mEssentialSig; // signature of the essential pair
-  // classic reduced S-pair of the essential pair
-  std::auto_ptr<Poly> mEssentialPoly;
-
-  // Value at be is true if we have reduced an S-pair (be,div) where
-  // div is the index of a basis element whose lead term divides the
-  // lead term of div. Only used if mTrackEssentialPair is true.
-  std::vector<char> mDidReducingSPair;
-
   void makePreSPairs(size_t newGen);
 
   struct BaseDivisor { // a low ratio base divisor
diff --git a/src/mathicgb/SignatureGB.cpp b/src/mathicgb/SignatureGB.cpp
index dd54f30..f3eb8dd 100755
--- a/src/mathicgb/SignatureGB.cpp
+++ b/src/mathicgb/SignatureGB.cpp
@@ -21,14 +21,9 @@ void SignatureGB::computeGrobnerBasis()
   R->resetCoefficientStats();
   std::ostream& out = std::cout;
 
-  if (!mComputeSignatureBasis)
-    SP->setTrackEssentialPair(true);
-
   while (true) {
     if (SP->empty())
       break;
-    if (!mComputeSignatureBasis && !SP->hasEssentialPair())
-      break;
     step();
 
     if (mBreakAfter > 0 && GB->size() > mBreakAfter) {
@@ -85,7 +80,6 @@ SignatureGB::SignatureGB(
 ):
   mBreakAfter(0),
   mPrintInterval(0),
-  mComputeSignatureBasis(true),
   R(ideal.getPolyRing()),
   F(FreeModuleOrder::makeOrder(typ, &ideal)),
   mPostponeKoszul(postponeKoszul),
@@ -319,8 +313,7 @@ void SignatureGB::displayStats(std::ostream &o) const
   o << "-- stats: -- \n";
   o << " strategy: signature"
     << (mPostponeKoszul ? "-postpone" : "")
-    << (mUseBaseDivisors ? "-basediv" : "")
-    << (mComputeSignatureBasis ? "-full" : "-stopGB") << '\n';
+    << (mUseBaseDivisors ? "-basediv" : "") << '\n';
   o << " sig-order:      " << F->description() << '\n';
   o << " reduction type: " << reducer->description() << '\n';
   o << " divisor tab type: " << GB->basis().divisorLookup().getName() << '\n';
diff --git a/src/mathicgb/SignatureGB.hpp b/src/mathicgb/SignatureGB.hpp
old mode 100644
new mode 100755
index dc0ff8c..e1d0fbd
--- a/src/mathicgb/SignatureGB.hpp
+++ b/src/mathicgb/SignatureGB.hpp
@@ -61,14 +61,9 @@ public:
     mPrintInterval = reductions;
   }
 
-  void setComputeSignatureBasis(bool value) {
-    mComputeSignatureBasis = value;
-  }
-
 private:
   unsigned int mBreakAfter;
   unsigned int mPrintInterval;
-  bool mComputeSignatureBasis;
 
   bool processSPair(monomial sig, const SPairHandler::PairContainer& pairs);
   void step();
diff --git a/src/test/gb-test.cpp b/src/test/gb-test.cpp
index 1678163..cc42525 100755
--- a/src/test/gb-test.cpp
+++ b/src/test/gb-test.cpp
@@ -44,6 +44,9 @@ void testGB(int freeModuleOrder,
             std::string initialIdealStr,
             size_t nonSingularReductions)
 {
+  // todo: signatureBasis no longer does anything, rerun pict to get rid
+  // of that variable.
+  //
   // Put the contents of pict.out into allPairsTest as a string. This
   // works because pict.out does not have any commas and we do not
   // care about whitespace. pict.out contains a set of tests such that
@@ -251,7 +254,6 @@ spairQueue	reducerType	divLookup	monTable	signatureBasis	buchberger	postponeKosz
       (Reducer::makeReducerNullOnUnknown(red, I->ring()).get() != 0);
 
     if (buchberger) {
-      ASSERT(!signatureBasis);
       BuchbergerAlg alg(
         *I, freeModuleOrder, Reducer::reducerType(reducerType), divLookup, preferSparseReducers, spairQueue);
       alg.setUseAutoTopReduction(autoTopReduce);
@@ -266,28 +268,19 @@ spairQueue	reducerType	divLookup	monTable	signatureBasis	buchberger	postponeKosz
       SignatureGB basis
         (*I, freeModuleOrder, Reducer::reducerType(reducerType),
           divLookup, monTable, postponeKoszul, useBaseDivisors, preferSparseReducers, useSingularCriterionEarly, spairQueue);
-      basis.setComputeSignatureBasis(signatureBasis);
       basis.computeGrobnerBasis();
-      if (!signatureBasis) {
-        std::auto_ptr<Ideal> initialIdeal =
-          basis.getGB()->basis().initialIdeal();
-        EXPECT_EQ(initialIdealStr, toString(initialIdeal.get()))
-          << reducerType << ' ' << divLookup << ' '
-          << monTable << ' ' << postponeKoszul << ' ' << useBaseDivisors;
-      } else {
-        EXPECT_EQ(sigBasisStr, toString(basis.getGB(), 1))
-          << reducerType << ' ' << divLookup << ' '
-          << monTable << ' ' << ' ' << postponeKoszul << ' '
-          << useBaseDivisors;
-        EXPECT_EQ(syzygiesStr, toString(basis.getSyzTable()))
-          << reducerType << ' ' << divLookup << ' '
-          << monTable << ' ' << ' ' << postponeKoszul << ' '
-          << useBaseDivisors;
-        EXPECT_EQ(nonSingularReductions, basis.getSigReductionCount() - basis.getSingularReductionCount())
-          << reducerType << ' ' << divLookup << ' '
-          << monTable << ' ' << ' ' << postponeKoszul << ' '
-          << useBaseDivisors;
-      }
+      EXPECT_EQ(sigBasisStr, toString(basis.getGB(), 1))
+        << reducerType << ' ' << divLookup << ' '
+        << monTable << ' ' << ' ' << postponeKoszul << ' '
+        << useBaseDivisors;
+      EXPECT_EQ(syzygiesStr, toString(basis.getSyzTable()))
+        << reducerType << ' ' << divLookup << ' '
+        << monTable << ' ' << ' ' << postponeKoszul << ' '
+        << useBaseDivisors;
+      EXPECT_EQ(nonSingularReductions, basis.getSigReductionCount() - basis.getSingularReductionCount())
+        << reducerType << ' ' << divLookup << ' '
+        << monTable << ' ' << ' ' << postponeKoszul << ' '
+        << useBaseDivisors;
     }
   }
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/mathicgb.git



More information about the debian-science-commits mailing list