Skip to content

Commit de0216f

Browse files
committed
fix bug in partition backtrack search
1 parent 390eab5 commit de0216f

File tree

2 files changed

+37
-18
lines changed

2 files changed

+37
-18
lines changed

include/permlib/search/partition/r_base.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,16 @@ typename BaseSearch<BSGSIN,TRANSRET>::PERM::ptr RBase<BSGSIN,TRANSRET>::searchCo
227227

228228
unsigned int completed = partitions.size();
229229
//BSGS<PERM,TRANS> groupL(groupK);
230-
PERM identH(this->m_bsgs.n);
231-
search(partitions.begin(), m_partition2, PERM(this->m_bsgs.n), &identH, 0, 0, completed, groupK, groupL);
230+
PERM t(this->m_bsgs.n);
231+
PERM t2(this->m_bsgs.n);
232+
BOOST_ASSERT(partitions.begin() != partitions.end());
233+
const Partition& sigma = *((*(partitions.begin())).first);
234+
if (sigma.fixPointsSize()) {
235+
updateMappingPermutation(this->m_bsgs, sigma, this->m_partition2, t);
236+
if (this->m_bsgs2)
237+
updateMappingPermutation(*this->m_bsgs2, sigma, this->m_partition2, t2);
238+
}
239+
search(partitions.begin(), m_partition2, t, &t2, 0, 0, completed, groupK, groupL);
232240

233241
return BaseSearch<BSGSIN,TRANSRET>::m_lastElement;
234242
}
@@ -268,10 +276,10 @@ unsigned int RBase<BSGSIN,TRANSRET>::search(PartitionIt pIt, Partition &pi, cons
268276
this->m_statNodesPrunedCosetMinimality += s;
269277
break;
270278
}
271-
279+
272280
--s;
273281
RefinementPtr ref2 = *rIt;
274-
282+
275283
const unsigned int oldFixPointsSize = pi.fixPointsSize();
276284
PERMLIB_DEBUG(std::cout << " refinement from " << pi << std::endl;)
277285
const unsigned int strictRefinement = ref2->apply2(pi, *tForRefinement);

test/test-search-setstabilizer.cpp

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
//
3030
// ---------------------------------------------------------------------------
3131

32-
3332
#define BOOST_TEST_DYN_LINK
3433
#define BOOST_TEST_MODULE Backtrack search test - set stabilization and set images
3534
#include <boost/test/unit_test.hpp>
@@ -42,6 +41,7 @@
4241
#include <permlib/bsgs.h>
4342
#include <permlib/construct/schreier_sims_construction.h>
4443
#include <permlib/generator/bsgs_generator.h>
44+
#include <permlib/generator/bsgs_random_generator.h>
4545
#include <permlib/transversal/schreier_tree_transversal.h>
4646
#include <permlib/construct/schreier_sims_construction.h>
4747
#include <permlib/change/conjugating_base_change.h>
@@ -117,15 +117,25 @@ void checkSetImage(const GroupInformation& info, unsigned int setSize, unsigned
117117

118118
typedef typename TRANSVERSAL::PERMtype PERM;
119119
BSGS<PERM, TRANSVERSAL> bsgs = ConstructDeterministic1<PERM, TRANSVERSAL>()(info);
120-
120+
121121
for (unsigned int i = 0; i < numberOfSets; ++i) {
122122
std::set<dom_int> testSet1;
123123
std::set<dom_int> testSet2;
124124
while (testSet1.size() < setSize) {
125125
testSet1.insert(randomInt(info.n));
126126
}
127-
while (testSet2.size() < setSize) {
128-
testSet2.insert(randomInt(info.n));
127+
if (i < numberOfSets / 2) {
128+
while (testSet2.size() < setSize) {
129+
testSet2.insert(randomInt(info.n));
130+
}
131+
} else {
132+
// Ensure that for at least have of the test cases a mapping element
133+
// exists.
134+
BSGSRandomGenerator<PERM,TRANSVERSAL> bsgsRandomGen(bsgs);
135+
const PERM p = bsgsRandomGen.next();
136+
BOOST_FOREACH(const dom_int& x, testSet1) {
137+
testSet2.insert(p / x);
138+
}
129139
}
130140

131141
// change the base so that is prefixed by the set
@@ -172,7 +182,7 @@ BOOST_AUTO_TEST_CASE( setstabilizer )
172182
typedef Permutation PERM;
173183
// and Schreier tree transversals
174184
typedef SchreierTreeTransversal<PERM> TRANSVERSAL;
175-
185+
176186
checkStabilizer<TRANSVERSAL>(info_testThesis, 3, 10);
177187
checkStabilizer<TRANSVERSAL>(info_1997, 3, 10);
178188
checkStabilizer<TRANSVERSAL>(info_cyclic10, 2, 30);
@@ -186,17 +196,18 @@ BOOST_AUTO_TEST_CASE( setimage )
186196
typedef Permutation PERM;
187197
// and Schreier tree transversals
188198
typedef SchreierTreeTransversal<PERM> TRANSVERSAL;
189-
190-
checkSetImage<TRANSVERSAL>(info_testThesis, 2, 10);
191-
checkSetImage<TRANSVERSAL>(info_testThesis, 3, 10);
192-
checkSetImage<TRANSVERSAL>(info_testThesis, 5, 10);
193-
checkSetImage<TRANSVERSAL>(info_1997, 2, 10);
194-
checkSetImage<TRANSVERSAL>(info_1997, 3, 10);
195-
checkSetImage<TRANSVERSAL>(info_1997, 5, 10);
199+
checkSetImage<TRANSVERSAL>(info_testThesis, 1, 20);
200+
checkSetImage<TRANSVERSAL>(info_testThesis, 2, 30);
201+
checkSetImage<TRANSVERSAL>(info_testThesis, 3, 30);
202+
checkSetImage<TRANSVERSAL>(info_testThesis, 5, 30);
203+
checkSetImage<TRANSVERSAL>(info_1997, 1, 30);
204+
checkSetImage<TRANSVERSAL>(info_1997, 2, 30);
205+
checkSetImage<TRANSVERSAL>(info_1997, 3, 30);
206+
checkSetImage<TRANSVERSAL>(info_1997, 5, 30);
196207
checkSetImage<TRANSVERSAL>(info_cyclic10, 2, 30);
197208
checkSetImage<TRANSVERSAL>(info_S6_3, 4, 30);
198-
checkSetImage<TRANSVERSAL>(info_e6, 4, 15);
199-
checkSetImage<TRANSVERSAL>(info_e6, 11, 3);
209+
checkSetImage<TRANSVERSAL>(info_e6, 4, 30);
210+
checkSetImage<TRANSVERSAL>(info_e6, 11, 10);
200211
}
201212

202213
BOOST_AUTO_TEST_CASE( vectorstabilizer_group )

0 commit comments

Comments
 (0)