[mathicgb] 14/393: Moved grobner basis tests from testing all combinations to testing only all pairs of combinations. This drastically reduces the time taken to run the tests.

Doug Torrance dtorrance-guest at moszumanska.debian.org
Fri Apr 3 15:58:23 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 5322a2e4fc86e4b13414299f68d3ef64d45b58d5
Author: Bjarke Hammersholt Roune <bjarkehr.code at gmail.com>
Date:   Sun Aug 5 18:04:10 2012 -0400

    Moved grobner basis tests from testing all combinations to testing only all pairs of combinations. This drastically reduces the time taken to run the tests.
---
 src/mathicgb/stdinc.h |   3 +
 src/test/gb-test.cpp  | 224 ++++++++++++++++++++++++++++++++++++++++++++------
 src/test/pict.in      |  52 ++++++++++++
 3 files changed, 256 insertions(+), 23 deletions(-)

diff --git a/src/mathicgb/stdinc.h b/src/mathicgb/stdinc.h
index 7ebdd64..a30b48d 100755
--- a/src/mathicgb/stdinc.h
+++ b/src/mathicgb/stdinc.h
@@ -50,6 +50,9 @@
 #define ASSERT(X)
 #define IF_DEBUG(X)
 #endif
+// todo: eventually move all ASSERTs to MATHICGB_ASSERTs and then remove
+// ASSERT.
+#define MATHICGB_ASSERT(X) ASSERT(X)
 
 static const size_t BitsPerByte = 8;
 static const size_t MemoryAlignment = sizeof(void*);
diff --git a/src/test/gb-test.cpp b/src/test/gb-test.cpp
index 9aec9d8..1678163 100755
--- a/src/test/gb-test.cpp
+++ b/src/test/gb-test.cpp
@@ -44,33 +44,211 @@ void testGB(int freeModuleOrder,
             std::string initialIdealStr,
             size_t nonSingularReductions)
 {
-  for (int spairQueue = 0; spairQueue <= 3; ++spairQueue)
-  for (int reducerType = 0; reducerType <= 30; ++reducerType)
-  for (int divLookup = 1; divLookup <= 2; ++divLookup)
-  for (int monTable = 0; monTable <= 2; ++monTable)
-  for (int signatureBasis = 0; signatureBasis <= 1; ++signatureBasis)
-  for (int buchberger = 0; buchberger <= 1; ++buchberger)
-  for (int postponeKoszul = 0; postponeKoszul <= 1; ++postponeKoszul)
-  for (int useBaseDivisors = 0; useBaseDivisors <= 1; ++useBaseDivisors)
-  for (int autoTailReduce = 0; autoTailReduce <= 1; ++autoTailReduce)
-  for (int autoTopReduce = 0; autoTopReduce <= 1; ++autoTopReduce)
-  for (int preferSparseReducers = 0; preferSparseReducers <= 1;
-    ++preferSparseReducers)
-  for (int useSingularCriterionEarly = 0; useSingularCriterionEarly <= 1;
-    ++useSingularCriterionEarly)
+  // 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
+  // all pairs of parameters are covered by at least one test. See
+  // pict.in for details.
+#define MATHICGB_ESCAPE_MULTILINE_STRING(str) #str
+  char const allPairsTests[] = MATHICGB_ESCAPE_MULTILINE_STRING(
+spairQueue	reducerType	divLookup	monTable	signatureBasis	buchberger	postponeKoszul	useBaseDivisors	autoTailReduce	autoTopReduce	preferSparseReducers	useSingularCriterionEarly
+1	13	1	0	1	0	0	0	0	0	1	0
+1	18	2	2	0	0	1	1	0	0	0	1
+2	2	2	1	0	1	0	0	1	1	0	0
+2	18	1	1	1	0	0	1	0	0	1	1
+3	16	1	2	0	1	0	0	1	1	1	0
+0	13	2	0	1	0	1	1	0	0	0	1
+1	11	2	0	0	1	0	0	1	1	1	0
+1	17	2	1	0	1	0	0	1	0	1	0
+1	15	1	0	0	1	0	0	0	1	0	0
+0	21	1	1	0	1	0	0	1	1	1	0
+2	0	2	0	0	1	0	0	1	0	1	0
+1	24	1	1	1	0	1	1	0	0	1	0
+1	6	1	2	1	0	1	0	0	0	0	1
+2	16	2	1	1	0	1	1	0	0	0	1
+3	22	2	1	1	0	1	1	0	0	0	1
+2	8	1	2	0	0	1	1	0	0	1	1
+0	12	2	2	0	0	1	1	0	0	1	1
+0	17	1	0	1	0	1	1	0	0	0	1
+2	6	2	0	0	1	0	0	1	1	1	0
+0	9	1	0	1	0	0	0	0	0	1	1
+3	3	2	0	0	1	0	0	0	1	0	0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	1
+);
+  std::istringstream tests(allPairsTests);
+  // skip the initial line with the parameter names.
   {
-    //std::cout << reducerType << ' ' << divLookup << ' ' << monTable << ' ' << signatureBasis << ' ' << buchberger << ' ' << postponeKoszul << ' ' << useBaseDivisors << ' ' << autoTailReduce << ' ' << autoTopReduce << ' ' << preferSparseReducers << std::endl;
-    if (!buchberger && (autoTopReduce || autoTailReduce))
-      continue;
-    if (buchberger && (postponeKoszul || useBaseDivisors || signatureBasis || useSingularCriterionEarly))
-      continue;
+      char const* params[] = {
+        "spairQueue", "reducerType", "divLookup", "monTable", "signatureBasis",
+        "buchberger", "postponeKoszul", "useBaseDivisors", "autoTailReduce",
+        "autoTopReduce", "preferSparseReducers", "useSingularCriterionEarly"};
 
+    std::string paramName;
+    size_t const paramCount = sizeof(params) / sizeof(*params);
+    for (size_t i = 0; i < paramCount; ++i) {
+      tests >> paramName;
+      // This assert will fire if you changed the order of the
+      // parameters, renamed a parameter, removed a parameter or added
+      // a parameter. Unless all you did was to rename a parameter,
+      // don't just update the params array that the assert is based
+      // on - you also need to update the code below that parses the
+      // pict output because it depends on the order of the
+      // parameters.
+      MATHICGB_ASSERT(paramName == params[i]);
+    }
+  }
+
+  while (true) {
+    // parse a line of the pict file
+
+    int spairQueue;
+    tests >> spairQueue;
+    if (!tests)
+      break; // no more tests
+    MATHICGB_ASSERT(0 <= spairQueue && spairQueue <= 3);
+
+    int reducerType;
+    tests >> reducerType;
+    MATHICGB_ASSERT(0 <= reducerType && reducerType <= 30);
+
+    int divLookup;
+    tests >> divLookup;
+    MATHICGB_ASSERT(1 <= divLookup && divLookup <= 2);
+
+    int monTable;
+    tests >> monTable;
+    MATHICGB_ASSERT(0 <= monTable && monTable <= 2);
+    
+    int signatureBasis;
+    tests >> signatureBasis;
+    MATHICGB_ASSERT(0 <= signatureBasis && signatureBasis <= 1);
+
+    int buchberger;
+    tests >> buchberger;
+    MATHICGB_ASSERT(0 <= buchberger && buchberger <= 1);
+
+    int postponeKoszul;
+    tests >> postponeKoszul;
+    MATHICGB_ASSERT(0 <= postponeKoszul && postponeKoszul <= 1);
+
+    int useBaseDivisors;
+    tests >> useBaseDivisors;
+    MATHICGB_ASSERT(0 <= useBaseDivisors && useBaseDivisors <= 1);
+
+    int autoTailReduce;
+    tests >> autoTailReduce;
+    MATHICGB_ASSERT(0 <= autoTailReduce && autoTailReduce <= 1);
+
+    int autoTopReduce;
+    tests >> autoTopReduce;
+    MATHICGB_ASSERT(0 <= autoTopReduce && autoTopReduce <= 1);
+
+    int preferSparseReducers;
+    tests >> preferSparseReducers;
+    MATHICGB_ASSERT(0 <= preferSparseReducers && preferSparseReducers <= 1);
+
+    int useSingularCriterionEarly;
+    tests >> useSingularCriterionEarly;
+    MATHICGB_ASSERT(0 <= useSingularCriterionEarly);
+    MATHICGB_ASSERT(useSingularCriterionEarly <= 1);
+
+    // Rule out combinations of parameter values that do not make sense.
+    // These are asserts because pict should have already removed these
+    // combinations.
+    MATHICGB_ASSERT(buchberger || !autoTopReduce);
+    MATHICGB_ASSERT(buchberger || !autoTailReduce);
+    MATHICGB_ASSERT(!buchberger || !postponeKoszul);
+    MATHICGB_ASSERT(!buchberger || !useBaseDivisors);
+    MATHICGB_ASSERT(!buchberger || !signatureBasis);
+    MATHICGB_ASSERT(!buchberger || !useSingularCriterionEarly);
+
+    // check that we have a valid reducer type
     Reducer::ReducerType red = Reducer::ReducerType(reducerType);
-    if ((buchberger && signatureBasis) || static_cast<int>(red) != reducerType)
-      continue;
+    MATHICGB_ASSERT(static_cast<int>(red) == reducerType);
     std::auto_ptr<Ideal> I(idealParseFromString(idealStr));
-    if (Reducer::makeReducerNullOnUnknown(red, I->ring()).get() == 0)
-      continue;
+    MATHICGB_ASSERT
+      (Reducer::makeReducerNullOnUnknown(red, I->ring()).get() != 0);
 
     if (buchberger) {
       ASSERT(!signatureBasis);
diff --git a/src/test/pict.in b/src/test/pict.in
new file mode 100755
index 0000000..09d5bd9
--- /dev/null
+++ b/src/test/pict.in
@@ -0,0 +1,52 @@
+# The purpose of this file is to generate a set of test configurations
+# where every pair of parameter values is present at least once. See
+# the Wikipedia page on all pairs testing:
+#
+#  http://en.wikipedia.org/wiki/All-pairs_testing
+#
+# This file is an input file for the Microsoft testing tool PICT.
+# The tool is available at
+#
+#   http://download.microsoft.com/download/f/5/5/f55484df-8494-48fa-8dbd-8c6f76cc014b/pict33.msi 
+#
+# You will need to run this program on Windows. It is a closed source
+# utility. There are open sources alternatives but they are not as good.
+#
+# To update the test in gb-test.cpp, update this file, run pict and
+# place the output into the string allPairsTest in gb-test.cpp.
+
+##############################################################
+# This is the PICT model specifying all parameters and their values
+#
+spairQueue: 0,1,2,3
+reducerType: 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24
+divLookup: 1, 2
+monTable: 0, 1, 2
+signatureBasis: 0, 1
+buchberger: 0, 1
+postponeKoszul: 0, 1
+useBaseDivisors: 0, 1
+autoTailReduce: 0,1
+autoTopReduce: 0,1
+preferSparseReducers: 0,1
+useSingularCriterionEarly: 0, 1
+
+##############################################################
+# PICT submodels go here.
+#
+
+# we are not currently using PICT submodels
+
+##############################################################
+# This is the set of PICT constraints that rule out some combinations
+# of parameter values.
+#
+IF [buchberger] = 0 THEN
+  [autoTopReduce] = 0 AND
+  [autoTailReduce] = 0;
+
+IF [buchberger] = 1 THEN
+  [postponeKoszul] = 0 AND
+  [useBaseDivisors] = 0 AND
+  [signatureBasis] = 0 AND
+  [usesingularCriterionEarly] = 0;

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