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