| [f67817f] | 1 | /* | 
|---|
|  | 2 | * Project: MoleCuilder | 
|---|
|  | 3 | * Description: creates and alters molecular systems | 
|---|
| [0aa122] | 4 | * Copyright (C)  2010-2012 University of Bonn. All rights reserved. | 
|---|
| [5aaa43] | 5 | * Copyright (C)  2013 Frederik Heber. All rights reserved. | 
|---|
| [94d5ac6] | 6 | * | 
|---|
|  | 7 | * | 
|---|
|  | 8 | *   This file is part of MoleCuilder. | 
|---|
|  | 9 | * | 
|---|
|  | 10 | *    MoleCuilder is free software: you can redistribute it and/or modify | 
|---|
|  | 11 | *    it under the terms of the GNU General Public License as published by | 
|---|
|  | 12 | *    the Free Software Foundation, either version 2 of the License, or | 
|---|
|  | 13 | *    (at your option) any later version. | 
|---|
|  | 14 | * | 
|---|
|  | 15 | *    MoleCuilder is distributed in the hope that it will be useful, | 
|---|
|  | 16 | *    but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
|  | 17 | *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|---|
|  | 18 | *    GNU General Public License for more details. | 
|---|
|  | 19 | * | 
|---|
|  | 20 | *    You should have received a copy of the GNU General Public License | 
|---|
|  | 21 | *    along with MoleCuilder.  If not, see <http://www.gnu.org/licenses/>. | 
|---|
| [f67817f] | 22 | */ | 
|---|
|  | 23 |  | 
|---|
|  | 24 | /* | 
|---|
|  | 25 | * PowerSetGenerator.cpp | 
|---|
|  | 26 | * | 
|---|
|  | 27 | *  Created on: Oct 18, 2011 | 
|---|
|  | 28 | *      Author: heber | 
|---|
|  | 29 | */ | 
|---|
|  | 30 |  | 
|---|
|  | 31 | // include config.h | 
|---|
|  | 32 | #ifdef HAVE_CONFIG_H | 
|---|
|  | 33 | #include <config.h> | 
|---|
|  | 34 | #endif | 
|---|
|  | 35 |  | 
|---|
|  | 36 | #include "CodePatterns/MemDebug.hpp" | 
|---|
|  | 37 |  | 
|---|
|  | 38 | #include "PowerSetGenerator.hpp" | 
|---|
|  | 39 |  | 
|---|
| [47d041] | 40 | #include <sstream> | 
|---|
|  | 41 |  | 
|---|
|  | 42 | #include "CodePatterns/Info.hpp" | 
|---|
| [f67817f] | 43 | #include "CodePatterns/Log.hpp" | 
|---|
|  | 44 |  | 
|---|
| [6f0841] | 45 | #include "Atom/atom.hpp" | 
|---|
| [f67817f] | 46 | #include "Bond/bond.hpp" | 
|---|
| [f0674a] | 47 | #include "Fragmentation/KeySet.hpp" | 
|---|
| [f67817f] | 48 | #include "Fragmentation/UniqueFragments.hpp" | 
|---|
|  | 49 |  | 
|---|
|  | 50 | /** Constructor of class PowerSetGenerator. | 
|---|
|  | 51 | * | 
|---|
|  | 52 | */ | 
|---|
| [d760bb] | 53 | PowerSetGenerator::PowerSetGenerator(UniqueFragments *_FragmentSearch, int _Order) : | 
|---|
|  | 54 | BondsPerSPList(_Order), | 
|---|
| [212c179] | 55 | FragmentSearch(_FragmentSearch) | 
|---|
| [f67817f] | 56 | {} | 
|---|
|  | 57 |  | 
|---|
|  | 58 | /** Destructor of class PowerSetGenerator. | 
|---|
|  | 59 | * | 
|---|
|  | 60 | */ | 
|---|
|  | 61 | PowerSetGenerator::~PowerSetGenerator() | 
|---|
|  | 62 | { | 
|---|
|  | 63 | FragmentSearch = NULL; | 
|---|
|  | 64 | } | 
|---|
|  | 65 |  | 
|---|
|  | 66 | /** Clears the touched list | 
|---|
|  | 67 | * \param verbosity verbosity level | 
|---|
| [a1d035] | 68 | * \param &TouchedList touched list | 
|---|
| [f67817f] | 69 | * \param SubOrder current suborder | 
|---|
|  | 70 | * \param TouchedIndex currently touched | 
|---|
|  | 71 | */ | 
|---|
| [a1d035] | 72 | void PowerSetGenerator::ClearingTouched(int verbosity, TouchedList_t &TouchedList, int SubOrder, int &TouchedIndex) | 
|---|
| [f67817f] | 73 | { | 
|---|
| [47d041] | 74 | LOG(1+verbosity, "Clearing touched list."); | 
|---|
| [a1d035] | 75 | TouchedList.resize(SubOrder+1, -1); | 
|---|
| [f67817f] | 76 | for (TouchedIndex=SubOrder+1;TouchedIndex--;)  // empty touched list | 
|---|
|  | 77 | TouchedList[TouchedIndex] = -1; | 
|---|
|  | 78 | TouchedIndex = 0; | 
|---|
|  | 79 | } | 
|---|
|  | 80 |  | 
|---|
|  | 81 | /** Adds the current combination of the power set to the snake stack. | 
|---|
|  | 82 | * \param verbosity verbosity level | 
|---|
|  | 83 | * \param CurrentCombination | 
|---|
|  | 84 | * \param SetDimension maximum number of bits in power set | 
|---|
|  | 85 | * \param *FragmentSet snake stack to remove from | 
|---|
|  | 86 | * \param &BondsSet set of bonds | 
|---|
| [a1d035] | 87 | * \param &TouchedList touched list | 
|---|
| [f67817f] | 88 | * \param TouchedIndex currently touched | 
|---|
|  | 89 | * \return number of set bits | 
|---|
|  | 90 | */ | 
|---|
| [a1d035] | 91 | int PowerSetGenerator::AddPowersetToSnakeStack(int verbosity, int CurrentCombination, int SetDimension, KeySet *FragmentSet, std::vector<bond::ptr > &BondsSet, TouchedList_t &TouchedList, int &TouchedIndex) | 
|---|
| [f67817f] | 92 | { | 
|---|
|  | 93 | atom *OtherWalker = NULL; | 
|---|
|  | 94 | bool bit = false; | 
|---|
|  | 95 | KeySetTestPair TestKeySetInsert; | 
|---|
|  | 96 |  | 
|---|
|  | 97 | int Added = 0; | 
|---|
|  | 98 | for (int j=0;j<SetDimension;j++) {  // pull out every bit by shifting | 
|---|
|  | 99 | bit = ((CurrentCombination & (1 << j)) != 0);  // mask the bit for the j-th bond | 
|---|
|  | 100 | if (bit) {  // if bit is set, we add this bond partner | 
|---|
|  | 101 | OtherWalker = BondsSet[j]->rightatom;  // rightatom is always the one more distant, i.e. the one to add | 
|---|
| [47d041] | 102 | //LOG(1+verbosity, "Current Bond is " << BondsSet[j] << ", checking on " << *OtherWalker << "."); | 
|---|
|  | 103 | LOG(2+verbosity, "Adding " << *OtherWalker << " with nr " << OtherWalker->getNr() << "."); | 
|---|
| [f67817f] | 104 | TestKeySetInsert = FragmentSet->insert(OtherWalker->getNr()); | 
|---|
|  | 105 | if (TestKeySetInsert.second) { | 
|---|
|  | 106 | TouchedList[TouchedIndex++] = OtherWalker->getNr();  // note as added | 
|---|
|  | 107 | Added++; | 
|---|
|  | 108 | } else { | 
|---|
| [47d041] | 109 | LOG(2+verbosity, "This was item was already present in the keyset."); | 
|---|
| [f67817f] | 110 | } | 
|---|
|  | 111 | } else { | 
|---|
| [47d041] | 112 | LOG(2+verbosity, "Not adding."); | 
|---|
| [f67817f] | 113 | } | 
|---|
|  | 114 | } | 
|---|
|  | 115 | return Added; | 
|---|
|  | 116 | }; | 
|---|
|  | 117 |  | 
|---|
|  | 118 | /** Counts the number of elements in a power set. | 
|---|
|  | 119 | * \param SetFirst begin iterator first bond | 
|---|
|  | 120 | * \param SetLast end iterator | 
|---|
| [a1d035] | 121 | * \param &TouchedList touched list | 
|---|
| [f67817f] | 122 | * \param TouchedIndex currently touched | 
|---|
|  | 123 | * \return number of elements | 
|---|
|  | 124 | */ | 
|---|
| [a1d035] | 125 | int PowerSetGenerator::CountSetMembers(std::list<bond::ptr >::const_iterator SetFirst, std::list<bond::ptr >::const_iterator SetLast, const TouchedList_t &TouchedList, int TouchedIndex) | 
|---|
| [f67817f] | 126 | { | 
|---|
|  | 127 | int SetDimension = 0; | 
|---|
| [88c8ec] | 128 | for( std::list<bond::ptr >::const_iterator Binder = SetFirst; | 
|---|
| [f67817f] | 129 | Binder != SetLast; | 
|---|
|  | 130 | ++Binder) { | 
|---|
| [a1d035] | 131 | for (TouchedList_t::const_iterator iter = TouchedList.begin(); | 
|---|
|  | 132 | iter != TouchedList.end(); ++iter) { | 
|---|
|  | 133 | if ((*Binder)->Contains(*iter))   // if we added this very endpiece | 
|---|
| [f67817f] | 134 | SetDimension++; | 
|---|
|  | 135 | } | 
|---|
|  | 136 | } | 
|---|
|  | 137 | return SetDimension; | 
|---|
|  | 138 | }; | 
|---|
|  | 139 |  | 
|---|
|  | 140 | /** Fills a list of bonds from another | 
|---|
|  | 141 | * \param *BondsList bonds array/vector to fill | 
|---|
|  | 142 | * \param SetFirst begin iterator first bond | 
|---|
|  | 143 | * \param SetLast end iterator | 
|---|
| [a1d035] | 144 | * \param &TouchedList touched list | 
|---|
| [f67817f] | 145 | * \param TouchedIndex currently touched | 
|---|
|  | 146 | * \return number of elements | 
|---|
|  | 147 | */ | 
|---|
| [a1d035] | 148 | int PowerSetGenerator::FillBondsList(std::vector<bond::ptr > &BondsList, std::list<bond::ptr >::const_iterator SetFirst, std::list<bond::ptr >::const_iterator SetLast, const TouchedList_t &TouchedList, int TouchedIndex) | 
|---|
| [f67817f] | 149 | { | 
|---|
|  | 150 | int SetDimension = 0; | 
|---|
| [88c8ec] | 151 | for( std::list<bond::ptr >::const_iterator Binder = SetFirst; | 
|---|
| [f67817f] | 152 | Binder != SetLast; | 
|---|
|  | 153 | ++Binder) { | 
|---|
| [a1d035] | 154 | for (TouchedList_t::const_iterator iter = TouchedList.begin(); | 
|---|
|  | 155 | iter != TouchedList.end(); ++iter) { | 
|---|
|  | 156 | if ((*Binder)->leftatom->getNr() == *iter)   // leftatom is always the closer one | 
|---|
| [f67817f] | 157 | BondsList[SetDimension++] = (*Binder); | 
|---|
|  | 158 | } | 
|---|
|  | 159 | } | 
|---|
|  | 160 | return SetDimension; | 
|---|
|  | 161 | }; | 
|---|
|  | 162 |  | 
|---|
|  | 163 | /** Remove all items that were added on this SP level. | 
|---|
|  | 164 | * \param verbosity verbosity level | 
|---|
|  | 165 | * \param *FragmentSet snake stack to remove from | 
|---|
| [a1d035] | 166 | * \param &TouchedList touched list | 
|---|
| [f67817f] | 167 | * \param TouchedIndex currently touched | 
|---|
|  | 168 | */ | 
|---|
| [a1d035] | 169 | void PowerSetGenerator::RemoveAllTouchedFromSnakeStack(int verbosity, KeySet *FragmentSet, TouchedList_t &TouchedList, int &TouchedIndex) | 
|---|
| [f67817f] | 170 | { | 
|---|
| [a1d035] | 171 | for (TouchedList_t::iterator iter = TouchedList.begin(); | 
|---|
|  | 172 | iter != TouchedList.end();++iter) { | 
|---|
|  | 173 | const int Removal = *iter; | 
|---|
| [47d041] | 174 | LOG(2+verbosity, "Removing item nr. " << Removal << " from snake stack."); | 
|---|
| [f67817f] | 175 | FragmentSet->erase(Removal); | 
|---|
| [a1d035] | 176 | (*iter) = -1; | 
|---|
| [f67817f] | 177 | } | 
|---|
| [47d041] | 178 | std::stringstream output; | 
|---|
|  | 179 | output << "Remaining local nr.s on snake stack are: "; | 
|---|
| [f67817f] | 180 | for(KeySet::iterator runner = FragmentSet->begin(); runner != FragmentSet->end(); runner++) | 
|---|
| [47d041] | 181 | output << (*runner) << " "; | 
|---|
|  | 182 | LOG(2, output.str()); | 
|---|
| [f67817f] | 183 | TouchedIndex = 0; // set Index to 0 for list of atoms added on this level | 
|---|
|  | 184 | }; | 
|---|
|  | 185 |  | 
|---|
|  | 186 |  | 
|---|
|  | 187 | /** Creates a list of all unique fragments of certain vertex size from a given graph \a Fragment for a given root vertex in the context of \a this molecule. | 
|---|
|  | 188 | * -# initialises UniqueFragments structure | 
|---|
|  | 189 | * -# fills edge list via BFS | 
|---|
|  | 190 | * -# creates the fragment by calling recursive function SPFragmentGenerator with UniqueFragments structure, 0 as | 
|---|
|  | 191 | root distance, the edge set, its dimension and the current suborder | 
|---|
|  | 192 | * -# Free'ing structure | 
|---|
|  | 193 | * Note that we may use the fact that the atoms are SP-ordered on the atomstack. I.e. when popping always the last, we first get all | 
|---|
|  | 194 | * with SP of 2, then those with SP of 3, then those with SP of 4 and so on. | 
|---|
|  | 195 | * \param RestrictedKeySet Restricted vertex set to use in context of molecule | 
|---|
| [9291d04] | 196 | * \param treatment whether to treat hydrogen special or not | 
|---|
| [f67817f] | 197 | * \return number of inserted fragments | 
|---|
|  | 198 | * \note ShortestPathList in FragmentSearch structure is probably due to NumberOfAtomsSPLevel and SP not needed anymore | 
|---|
|  | 199 | */ | 
|---|
| [9291d04] | 200 | int PowerSetGenerator::operator()(KeySet &RestrictedKeySet, const enum HydrogenTreatment treatment) | 
|---|
| [f67817f] | 201 | { | 
|---|
|  | 202 | int Counter = FragmentSearch->FragmentCounter; // mark current value of counter | 
|---|
|  | 203 |  | 
|---|
| [47d041] | 204 | LOG(0, std::endl); | 
|---|
|  | 205 | LOG(0, "Begin of PowerSetGenerator with order " << BondsPerSPList.getOrder() << " at Root " << *FragmentSearch->getRoot() << "."); | 
|---|
| [f67817f] | 206 |  | 
|---|
| [212c179] | 207 | BondsPerSPList.SetSPList(FragmentSearch->getRoot()); | 
|---|
| [f67817f] | 208 |  | 
|---|
|  | 209 | // do a BFS search to fill the SP lists and label the found vertices | 
|---|
| [9291d04] | 210 | BondsPerSPList.FillSPListandLabelVertices(FragmentSearch->getRoot()->GetTrueFather()->getNr(), RestrictedKeySet, treatment); | 
|---|
| [f67817f] | 211 |  | 
|---|
|  | 212 | // outputting all list for debugging | 
|---|
| [212c179] | 213 | BondsPerSPList.OutputSPList(); | 
|---|
| [f67817f] | 214 |  | 
|---|
|  | 215 | // creating fragments with the found edge sets  (may be done in reverse order, faster) | 
|---|
| [212c179] | 216 | int SP = BondsPerSPList.CountNumbersInBondsList(); | 
|---|
| [8ac66b4] | 217 | LOG(0, "INFO: Total number of edges is " << SP << "."); | 
|---|
| [d760bb] | 218 | { | 
|---|
| [f67817f] | 219 | // start with root (push on fragment stack) | 
|---|
| [47d041] | 220 | LOG(0, "Starting fragment generation with " << *FragmentSearch->getRoot() << ", local nr is " << FragmentSearch->getRoot()->getNr() << "."); | 
|---|
| [f67817f] | 221 | FragmentSearch->FragmentSet->clear(); | 
|---|
| [47d041] | 222 | LOG(0, "Preparing subset for this root and calling generator."); | 
|---|
| [f67817f] | 223 |  | 
|---|
|  | 224 | // prepare the subset and call the generator | 
|---|
| [7d82a5] | 225 | std::vector<bond::ptr> BondsList; | 
|---|
| [212c179] | 226 | BondsList.resize(BondsPerSPList.BondsPerSPCount[0]); | 
|---|
|  | 227 | ASSERT(BondsPerSPList.BondsPerSPList[0].size() != 0, | 
|---|
|  | 228 | "molecule::PowerSetGenerator() - BondsPerSPList.BondsPerSPList[0] contains no root bond."); | 
|---|
|  | 229 | BondsList[0] = (*BondsPerSPList.BondsPerSPList[0].begin());  // on SP level 0 there's only the root bond | 
|---|
| [f67817f] | 230 |  | 
|---|
| [212c179] | 231 | SPFragmentGenerator(0, BondsList, BondsPerSPList.BondsPerSPCount[0], BondsPerSPList.getOrder()); | 
|---|
| [f67817f] | 232 | } | 
|---|
|  | 233 |  | 
|---|
|  | 234 | // as FragmentSearch structure is used only once, we don't have to clean it anymore | 
|---|
|  | 235 | // remove root from stack | 
|---|
| [47d041] | 236 | LOG(0, "Removing root again from stack."); | 
|---|
| [f67817f] | 237 | FragmentSearch->FragmentSet->erase(FragmentSearch->getRoot()->getNr()); | 
|---|
|  | 238 |  | 
|---|
|  | 239 | // free'ing the bonds lists | 
|---|
| [212c179] | 240 | BondsPerSPList.ResetSPList(); | 
|---|
| [f67817f] | 241 |  | 
|---|
|  | 242 | // return list | 
|---|
| [47d041] | 243 | LOG(0, "End of PowerSetGenerator."); | 
|---|
| [f67817f] | 244 | return (FragmentSearch->FragmentCounter - Counter); | 
|---|
|  | 245 | }; | 
|---|
|  | 246 |  | 
|---|
|  | 247 | /** From a given set of Bond sorted by Shortest Path distance, create all possible fragments of size \a SetDimension. | 
|---|
|  | 248 | * -# loops over every possible combination (2^dimension of edge set) | 
|---|
|  | 249 | *  -# inserts current set, if there's still space left | 
|---|
|  | 250 | *    -# yes: calls SPFragmentGenerator with structure, created new edge list and size respective to root dist | 
|---|
|  | 251 | ance+1 | 
|---|
|  | 252 | *    -# no: stores fragment into keyset list by calling InsertFragmentIntoGraph | 
|---|
|  | 253 | *  -# removes all items added into the snake stack (in UniqueFragments structure) added during level (root | 
|---|
|  | 254 | distance) and current set | 
|---|
|  | 255 | * \param RootDistance current shortest path level, whose set of edges is represented by **BondsSet | 
|---|
|  | 256 | * \param BondsSet array of bonds to check | 
|---|
|  | 257 | * \param SetDimension Number of possible bonds on this level (i.e. size of the array BondsSet[]) | 
|---|
|  | 258 | * \param SubOrder remaining number of allowed vertices to add | 
|---|
|  | 259 | */ | 
|---|
| [88c8ec] | 260 | void PowerSetGenerator::SPFragmentGenerator(int RootDistance, std::vector<bond::ptr > &BondsSet, int SetDimension, int SubOrder) | 
|---|
| [f67817f] | 261 | { | 
|---|
| [47d041] | 262 | Info info(__func__); | 
|---|
| [f67817f] | 263 | int verbosity = 0; //FragmentSearch->ANOVAOrder-SubOrder; | 
|---|
| [d760bb] | 264 | int TouchedIndex, SubSetDimension, Added; | 
|---|
| [f67817f] | 265 | int SpaceLeft; | 
|---|
| [a1d035] | 266 | TouchedList_t TouchedList(SubOrder + 1, -1); | 
|---|
| [f67817f] | 267 | KeySetTestPair TestKeySetInsert; | 
|---|
|  | 268 |  | 
|---|
| [d760bb] | 269 | const int NumCombinations = 1 << SetDimension; | 
|---|
| [f67817f] | 270 |  | 
|---|
|  | 271 | // here for all bonds of Walker all combinations of end pieces (from the bonds) | 
|---|
|  | 272 | // have to be added and for the remaining ANOVA order GraphCrawler be called | 
|---|
|  | 273 | // recursively for the next level | 
|---|
|  | 274 |  | 
|---|
| [47d041] | 275 | LOG(1+verbosity, "We are " << RootDistance << " away from Root, which is " << *FragmentSearch->getRoot() << ", SubOrder is " << SubOrder << ", SetDimension is " << SetDimension << " and this means " <<  NumCombinations-1 << " combination(s)."); | 
|---|
| [f67817f] | 276 |  | 
|---|
|  | 277 | // initialised touched list (stores added atoms on this level) | 
|---|
|  | 278 | ClearingTouched(verbosity, TouchedList, SubOrder, TouchedIndex); | 
|---|
|  | 279 |  | 
|---|
|  | 280 | // create every possible combination of the endpieces | 
|---|
| [47d041] | 281 | LOG(1+verbosity, "Going through all combinations of the power set."); | 
|---|
| [f67817f] | 282 | for (int i=1;i<NumCombinations;i++) {  // sweep through all power set combinations (skip empty set!) | 
|---|
|  | 283 | // count the set bit of i | 
|---|
| [d760bb] | 284 | const int bits = countBits(i, SetDimension); | 
|---|
| [f67817f] | 285 |  | 
|---|
| [47d041] | 286 | LOG(1+verbosity, "Current set is " << Binary(i | (1 << SetDimension)) << ", number of bits is " << bits << "."); | 
|---|
| [f67817f] | 287 | if (bits <= SubOrder) { // if not greater than additional atoms allowed on stack, continue | 
|---|
|  | 288 | // --1-- add this set of the power set of bond partners to the snake stack | 
|---|
|  | 289 | Added = AddPowersetToSnakeStack(verbosity, i, SetDimension, FragmentSearch->FragmentSet, BondsSet, TouchedList, TouchedIndex); | 
|---|
|  | 290 |  | 
|---|
| [d760bb] | 291 | // --2-- store the fragment | 
|---|
|  | 292 | const int order = BondsPerSPList.getOrder() - SubOrder + Added - 1; | 
|---|
|  | 293 | LOG(1+verbosity, "Storing fragment as order " << order << "."); | 
|---|
|  | 294 | // store fragment as a KeySet | 
|---|
|  | 295 | if (DoLog(2)) { | 
|---|
|  | 296 | std::stringstream output; | 
|---|
|  | 297 | output << "Found a new fragment[" << FragmentSearch->FragmentCounter << "], local nr.s are: "; | 
|---|
|  | 298 | for(KeySet::iterator runner = FragmentSearch->FragmentSet->begin(); runner != FragmentSearch->FragmentSet->end(); runner++) | 
|---|
|  | 299 | output << (*runner) << " "; | 
|---|
|  | 300 | LOG(2, output.str()); | 
|---|
|  | 301 | } | 
|---|
|  | 302 | FragmentSearch->InsertFragmentIntoGraph(order); | 
|---|
|  | 303 |  | 
|---|
|  | 304 | // --3-- if below SubOrder still, recurse | 
|---|
| [f67817f] | 305 | SpaceLeft = SubOrder - Added ;// SubOrder - bits; // due to item's maybe being already present, this does not work anymore | 
|---|
| [d760bb] | 306 | if ((SpaceLeft > 0) && (RootDistance < BondsPerSPList.getOrder())) { | 
|---|
| [47d041] | 307 | LOG(1+verbosity, "There's still some space left on stack: " << SpaceLeft << "."); | 
|---|
| [f67817f] | 308 | if (SubOrder > 1) {    // Due to Added above we have to check extra whether we're not already reaching beyond the desired Order | 
|---|
|  | 309 | // --2-- look at all added end pieces of this combination, construct bond subsets and sweep through a power set of these by recursion | 
|---|
| [d760bb] | 310 | const int SP = RootDistance+1;  // this is the next level | 
|---|
| [f67817f] | 311 |  | 
|---|
|  | 312 | // first count the members in the subset | 
|---|
| [212c179] | 313 | SubSetDimension = CountSetMembers(BondsPerSPList.BondsPerSPList[SP].begin(), BondsPerSPList.BondsPerSPList[SP].end(), TouchedList, TouchedIndex); | 
|---|
| [f67817f] | 314 |  | 
|---|
|  | 315 | // then allocate and fill the list | 
|---|
| [88c8ec] | 316 | std::vector<bond::ptr > BondsList; | 
|---|
| [f67817f] | 317 | BondsList.resize(SubSetDimension); | 
|---|
| [212c179] | 318 | SubSetDimension = FillBondsList(BondsList, BondsPerSPList.BondsPerSPList[SP].begin(), BondsPerSPList.BondsPerSPList[SP].end(), TouchedList, TouchedIndex); | 
|---|
| [f67817f] | 319 |  | 
|---|
|  | 320 | // then iterate | 
|---|
| [47d041] | 321 | LOG(2+verbosity, "Calling subset generator " << SP << " away from root " << *FragmentSearch->getRoot() << " with sub set dimension " << SubSetDimension << "."); | 
|---|
| [f67817f] | 322 | SPFragmentGenerator(SP, BondsList, SubSetDimension, SubOrder-bits); | 
|---|
|  | 323 | } | 
|---|
|  | 324 | } else { | 
|---|
| [d760bb] | 325 | LOG(1+verbosity, "No more space or no shortest path levels, not recursing."); | 
|---|
| [f67817f] | 326 | } | 
|---|
|  | 327 |  | 
|---|
|  | 328 | // --3-- remove all added items in this level from snake stack | 
|---|
| [47d041] | 329 | LOG(1+verbosity, "Removing all items that were added on this SP level " << RootDistance << "."); | 
|---|
| [f67817f] | 330 | RemoveAllTouchedFromSnakeStack(verbosity, FragmentSearch->FragmentSet, TouchedList, TouchedIndex); | 
|---|
|  | 331 | } else { | 
|---|
| [47d041] | 332 | LOG(2+verbosity, "More atoms to add for this set (" << bits << ") than space left on stack " << SubOrder << ", skipping this set."); | 
|---|
| [f67817f] | 333 | } | 
|---|
|  | 334 | } | 
|---|
| [47d041] | 335 | LOG(1+verbosity, "End of SPFragmentGenerator, " << RootDistance << " away from Root " << *FragmentSearch->getRoot() << " and SubOrder is " << SubOrder << "."); | 
|---|
| [f67817f] | 336 | }; | 
|---|