[mathicgb] 239/393: SPairGroupSize is now set to something appropriate by default for both the CLI and library interfaces.

Doug Torrance dtorrance-guest at moszumanska.debian.org
Fri Apr 3 15:59:10 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 c1867bcdd56a50c4a131e214992fcbbd91e2da6d
Author: Bjarke Hammersholt Roune <bjarkehr.code at gmail.com>
Date:   Fri Apr 12 16:33:13 2013 -0400

    SPairGroupSize is now set to something appropriate by default for both the CLI and library interfaces.
---
 src/cli/GBAction.cpp            |  3 +--
 src/mathicgb.cpp                |  1 -
 src/mathicgb/BuchbergerAlg.cpp  | 12 ++++++++++--
 src/mathicgb/BuchbergerAlg.hpp  |  6 +++---
 src/mathicgb/F4Reducer.cpp      |  4 ++++
 src/mathicgb/F4Reducer.hpp      |  2 ++
 src/mathicgb/Reducer.hpp        |  7 +++++++
 src/mathicgb/TypicalReducer.cpp |  4 ++++
 src/mathicgb/TypicalReducer.hpp |  2 ++
 9 files changed, 33 insertions(+), 8 deletions(-)

diff --git a/src/cli/GBAction.cpp b/src/cli/GBAction.cpp
old mode 100644
new mode 100755
index 0e91719..e2d428a
--- a/src/cli/GBAction.cpp
+++ b/src/cli/GBAction.cpp
@@ -28,8 +28,7 @@ GBAction::GBAction():
 
   mSPairGroupSize("sPairGroupSize",
     "Specifies how many S-pair to reduce at one time. A value of 0 "
-    "indicates not to group S-pairs together. Only currently relevant "
-    "for the classic Buchberger algorithm.",
+    "indicates to use an appropriate default.",
     0),
 
  mMinMatrixToStore("storeMatrices",
diff --git a/src/mathicgb.cpp b/src/mathicgb.cpp
index 6f28e6c..dc723be 100755
--- a/src/mathicgb.cpp
+++ b/src/mathicgb.cpp
@@ -647,7 +647,6 @@ namespace mgbi {
 
     // Set up and configure algorithm
     BuchbergerAlg alg(ideal, 4, *reducer, 2, true, 0);
-    alg.setSPairGroupSize(10000);
     alg.setReducerMemoryQuantum(100 * 1024);
     alg.setUseAutoTopReduction(true);
     alg.setUseAutoTailReduction(false);
diff --git a/src/mathicgb/BuchbergerAlg.cpp b/src/mathicgb/BuchbergerAlg.cpp
index af180fd..0354cad 100755
--- a/src/mathicgb/BuchbergerAlg.cpp
+++ b/src/mathicgb/BuchbergerAlg.cpp
@@ -14,7 +14,7 @@ BuchbergerAlg::BuchbergerAlg(
 ):
   mBreakAfter(0),
   mPrintInterval(0),
-  mSPairGroupSize(0),
+  mSPairGroupSize(reducer.preferredSetSize()),
   mUseAutoTopReduction(true),
   mUseAutoTailReduction(false),
   mRing(*ideal.getPolyRing()),
@@ -35,6 +35,13 @@ BuchbergerAlg::BuchbergerAlg(
   insertPolys(polys);
 }
 
+void BuchbergerAlg::setSPairGroupSize(unsigned int groupSize) {
+  if (groupSize == 0)
+    groupSize = mReducer.preferredSetSize();
+  else
+    mSPairGroupSize = groupSize;
+}
+
 void BuchbergerAlg::insertPolys
 (std::vector<std::unique_ptr<Poly> >& polynomials)
 {
@@ -221,7 +228,8 @@ void BuchbergerAlg::step() {
   if (tracingLevel > 30)
     std::cerr << "Determining next S-pair" << std::endl;
 
-  if (mSPairGroupSize == 0) {
+  MATHICGB_ASSERT(mSPairGroupSize >= 1);
+  if (mSPairGroupSize == 1) {
     std::pair<size_t, size_t> p = mSPairs.pop();
     if (p.first == static_cast<size_t>(-1)) {
       MATHICGB_ASSERT(p.second == static_cast<size_t>(-1));
diff --git a/src/mathicgb/BuchbergerAlg.hpp b/src/mathicgb/BuchbergerAlg.hpp
index 712d90a..39277ae 100755
--- a/src/mathicgb/BuchbergerAlg.hpp
+++ b/src/mathicgb/BuchbergerAlg.hpp
@@ -46,9 +46,9 @@ public:
     mPrintInterval = reductions;
   }
 
-  void setSPairGroupSize(unsigned int groupSize) {
-    mSPairGroupSize = groupSize;
-  }
+  /// A value of zero means to let the algorithm decide a reasonable
+  /// value based on the other settings.
+  void setSPairGroupSize(unsigned int groupSize);
 
   void setReducerMemoryQuantum(size_t memoryQuantum) {
     mReducer.setMemoryQuantum(memoryQuantum);
diff --git a/src/mathicgb/F4Reducer.cpp b/src/mathicgb/F4Reducer.cpp
index 6be1f39..16e9e19 100755
--- a/src/mathicgb/F4Reducer.cpp
+++ b/src/mathicgb/F4Reducer.cpp
@@ -45,6 +45,10 @@ F4Reducer::F4Reducer(const PolyRing& ring, Type type):
   mMatrixSaveCount(0) {
 }
 
+size_t F4Reducer::preferredSetSize() const {
+  return 100000;
+}
+
 void F4Reducer::writeMatricesTo(std::string file, size_t minEntries) {
   mStoreToFile = std::move(file);
   mMinEntryCountForStore = minEntries;
diff --git a/src/mathicgb/F4Reducer.hpp b/src/mathicgb/F4Reducer.hpp
index 1d23de7..f607dd9 100755
--- a/src/mathicgb/F4Reducer.hpp
+++ b/src/mathicgb/F4Reducer.hpp
@@ -15,6 +15,8 @@ public:
 
   F4Reducer(const PolyRing& ring, Type type);
 
+  virtual size_t preferredSetSize() const;
+
   /// Store all future matrices to file-1.mat, file-2.mat and so on.
   /// Matrices with less than minEntries non-zero entries are not stored.
   /// If file is an empty string then no matrices are stored. If this method
diff --git a/src/mathicgb/Reducer.hpp b/src/mathicgb/Reducer.hpp
index 23f351b..0700609 100755
--- a/src/mathicgb/Reducer.hpp
+++ b/src/mathicgb/Reducer.hpp
@@ -19,6 +19,13 @@ class Reducer {
 public:
   virtual ~Reducer();
 
+  /// Returns the preferred number of reductions to do at a time. A classic
+  /// serial reducer will have no particular benefit from doing more than
+  /// one reduction at a time, so it should say that. A matrix-based or
+  /// parallel reducer will have benefit from being presented with
+  /// larger sets of reductions at a time.
+  virtual size_t preferredSetSize() const = 0;
+
   // ***** Methods that do reduction
 
   /** Clasically reduces poly by the basis elements of basis. The reduction
diff --git a/src/mathicgb/TypicalReducer.cpp b/src/mathicgb/TypicalReducer.cpp
index 3c54cea..9fb2365 100755
--- a/src/mathicgb/TypicalReducer.cpp
+++ b/src/mathicgb/TypicalReducer.cpp
@@ -5,6 +5,10 @@
 #include "PolyBasis.hpp"
 #include <iostream>
 
+size_t TypicalReducer::preferredSetSize() const {
+  return 1;
+}
+
 void TypicalReducer::reset()
 {
   mArena.freeAllAllocs();
diff --git a/src/mathicgb/TypicalReducer.hpp b/src/mathicgb/TypicalReducer.hpp
index 401e4b7..d7c0414 100755
--- a/src/mathicgb/TypicalReducer.hpp
+++ b/src/mathicgb/TypicalReducer.hpp
@@ -18,6 +18,8 @@ class PolyBasis;
 */
 class TypicalReducer : public Reducer {
 public:
+  virtual size_t preferredSetSize() const;
+
   virtual Poly* regularReduce(
     const_monomial sig,
     const_monomial multiple,

-- 
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