Changeset 47d041 for src/Fragmentation/PowerSetGenerator.cpp
- Timestamp:
- Nov 3, 2011, 7:44:01 PM (14 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, Candidate_v1.7.0, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
- Children:
- 41a467
- Parents:
- 50e4e5
- git-author:
- Frederik Heber <heber@…> (10/27/11 11:53:58)
- git-committer:
- Frederik Heber <heber@…> (11/03/11 19:44:01)
- File:
-
- 1 edited
-
src/Fragmentation/PowerSetGenerator.cpp (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Fragmentation/PowerSetGenerator.cpp
r50e4e5 r47d041 22 22 #include "PowerSetGenerator.hpp" 23 23 24 #include <sstream> 25 26 #include "CodePatterns/Info.hpp" 24 27 #include "CodePatterns/Log.hpp" 25 28 … … 53 56 void PowerSetGenerator::ClearingTouched(int verbosity, int *&TouchedList, int SubOrder, int &TouchedIndex) 54 57 { 55 L og() << Verbose(1+verbosity) << "Clearing touched list." << endl;58 LOG(1+verbosity, "Clearing touched list."); 56 59 for (TouchedIndex=SubOrder+1;TouchedIndex--;) // empty touched list 57 60 TouchedList[TouchedIndex] = -1; … … 81 84 if (bit) { // if bit is set, we add this bond partner 82 85 OtherWalker = BondsSet[j]->rightatom; // rightatom is always the one more distant, i.e. the one to add 83 //L og() << Verbose(1+verbosity) << "Current Bond is " << BondsSet[j] << ", checking on " << *OtherWalker << "." << endl;84 L og() << Verbose(2+verbosity) << "Adding " << *OtherWalker << " with nr " << OtherWalker->getNr() << "." << endl;86 //LOG(1+verbosity, "Current Bond is " << BondsSet[j] << ", checking on " << *OtherWalker << "."); 87 LOG(2+verbosity, "Adding " << *OtherWalker << " with nr " << OtherWalker->getNr() << "."); 85 88 TestKeySetInsert = FragmentSet->insert(OtherWalker->getNr()); 86 89 if (TestKeySetInsert.second) { … … 88 91 Added++; 89 92 } else { 90 L og() << Verbose(2+verbosity) << "This was item was already present in the keyset." << endl;93 LOG(2+verbosity, "This was item was already present in the keyset."); 91 94 } 92 95 } else { 93 L og() << Verbose(2+verbosity) << "Not adding." << endl;96 LOG(2+verbosity, "Not adding."); 94 97 } 95 98 } … … 151 154 for(int j=0;j<TouchedIndex;j++) { 152 155 Removal = TouchedList[j]; 153 L og() << Verbose(2+verbosity) << "Removing item nr. " << Removal << " from snake stack." << endl;156 LOG(2+verbosity, "Removing item nr. " << Removal << " from snake stack."); 154 157 FragmentSet->erase(Removal); 155 158 TouchedList[j] = -1; 156 159 } 157 DoLog(2) && (Log() << Verbose(2) << "Remaining local nr.s on snake stack are: "); 160 std::stringstream output; 161 output << "Remaining local nr.s on snake stack are: "; 158 162 for(KeySet::iterator runner = FragmentSet->begin(); runner != FragmentSet->end(); runner++) 159 DoLog(0) && (Log() << Verbose(0) << (*runner) << " ");160 DoLog(0) && (Log() << Verbose(0) << endl);163 output << (*runner) << " "; 164 LOG(2, output.str()); 161 165 TouchedIndex = 0; // set Index to 0 for list of atoms added on this level 162 166 }; … … 180 184 int Counter = FragmentSearch->FragmentCounter; // mark current value of counter 181 185 182 DoLog(0) && (Log() << Verbose(0) <<endl);183 DoLog(0) && (Log() << Verbose(0) << "Begin of PowerSetGenerator with order " << BondsPerSPList.getOrder() << " at Root " << *FragmentSearch->getRoot() << "." << endl);186 LOG(0, std::endl); 187 LOG(0, "Begin of PowerSetGenerator with order " << BondsPerSPList.getOrder() << " at Root " << *FragmentSearch->getRoot() << "."); 184 188 185 189 BondsPerSPList.SetSPList(FragmentSearch->getRoot()); … … 193 197 // creating fragments with the found edge sets (may be done in reverse order, faster) 194 198 int SP = BondsPerSPList.CountNumbersInBondsList(); 195 DoLog(0) && (Log() << Verbose(0) << "Total number of edges is " << SP << "." << endl);199 LOG(0, "Total number of edges is " << SP << "."); 196 200 if (SP >= (BondsPerSPList.getOrder()-1)) { 197 201 // start with root (push on fragment stack) 198 DoLog(0) && (Log() << Verbose(0) << "Starting fragment generation with " << *FragmentSearch->getRoot() << ", local nr is " << FragmentSearch->getRoot()->getNr() << "." << endl);202 LOG(0, "Starting fragment generation with " << *FragmentSearch->getRoot() << ", local nr is " << FragmentSearch->getRoot()->getNr() << "."); 199 203 FragmentSearch->FragmentSet->clear(); 200 DoLog(0) && (Log() << Verbose(0) << "Preparing subset for this root and calling generator." << endl);204 LOG(0, "Preparing subset for this root and calling generator."); 201 205 202 206 // prepare the subset and call the generator … … 209 213 SPFragmentGenerator(0, BondsList, BondsPerSPList.BondsPerSPCount[0], BondsPerSPList.getOrder()); 210 214 } else { 211 DoLog(0) && (Log() << Verbose(0) << "Not enough total number of edges to build " << BondsPerSPList.getOrder() << "-body fragments." << endl);215 LOG(0, "Not enough total number of edges to build " << BondsPerSPList.getOrder() << "-body fragments."); 212 216 } 213 217 214 218 // as FragmentSearch structure is used only once, we don't have to clean it anymore 215 219 // remove root from stack 216 DoLog(0) && (Log() << Verbose(0) << "Removing root again from stack." << endl);220 LOG(0, "Removing root again from stack."); 217 221 FragmentSearch->FragmentSet->erase(FragmentSearch->getRoot()->getNr()); 218 222 … … 221 225 222 226 // return list 223 DoLog(0) && (Log() << Verbose(0) << "End of PowerSetGenerator." << endl);227 LOG(0, "End of PowerSetGenerator."); 224 228 return (FragmentSearch->FragmentCounter - Counter); 225 229 }; … … 240 244 void PowerSetGenerator::SPFragmentGenerator(int RootDistance, std::vector<bond *> &BondsSet, int SetDimension, int SubOrder) 241 245 { 246 Info info(__func__); 242 247 int verbosity = 0; //FragmentSearch->ANOVAOrder-SubOrder; 243 248 int NumCombinations; … … 253 258 // recursively for the next level 254 259 255 Log() << Verbose(1+verbosity) << "Begin of SPFragmentGenerator." << endl; 256 Log() << Verbose(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)." << endl; 260 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)."); 257 261 258 262 // initialised touched list (stores added atoms on this level) … … 260 264 261 265 // create every possible combination of the endpieces 262 L og() << Verbose(1+verbosity) << "Going through all combinations of the power set." << endl;266 LOG(1+verbosity, "Going through all combinations of the power set."); 263 267 for (int i=1;i<NumCombinations;i++) { // sweep through all power set combinations (skip empty set!) 264 268 // count the set bit of i … … 267 271 bits += (i & (1 << j)) >> j; 268 272 269 L og() << Verbose(1+verbosity) << "Current set is " << Binary(i | (1 << SetDimension)) << ", number of bits is " << bits << "." << endl;273 LOG(1+verbosity, "Current set is " << Binary(i | (1 << SetDimension)) << ", number of bits is " << bits << "."); 270 274 if (bits <= SubOrder) { // if not greater than additional atoms allowed on stack, continue 271 275 // --1-- add this set of the power set of bond partners to the snake stack … … 274 278 SpaceLeft = SubOrder - Added ;// SubOrder - bits; // due to item's maybe being already present, this does not work anymore 275 279 if (SpaceLeft > 0) { 276 L og() << Verbose(1+verbosity) << "There's still some space left on stack: " << SpaceLeft << "." << endl;280 LOG(1+verbosity, "There's still some space left on stack: " << SpaceLeft << "."); 277 281 if (SubOrder > 1) { // Due to Added above we have to check extra whether we're not already reaching beyond the desired Order 278 282 // --2-- look at all added end pieces of this combination, construct bond subsets and sweep through a power set of these by recursion … … 288 292 289 293 // then iterate 290 L og() << Verbose(2+verbosity) << "Calling subset generator " << SP << " away from root " << *FragmentSearch->getRoot() << " with sub set dimension " << SubSetDimension << "." << endl;294 LOG(2+verbosity, "Calling subset generator " << SP << " away from root " << *FragmentSearch->getRoot() << " with sub set dimension " << SubSetDimension << "."); 291 295 SPFragmentGenerator(SP, BondsList, SubSetDimension, SubOrder-bits); 292 296 } 293 297 } else { 294 298 // --2-- otherwise store the complete fragment 295 L og() << Verbose(1+verbosity) << "Enough items on stack for a fragment!" << endl;299 LOG(1+verbosity, "Enough items on stack for a fragment!"); 296 300 // store fragment as a KeySet 297 DoLog(2) && (Log() << Verbose(2) << "Found a new fragment[" << FragmentSearch->FragmentCounter << "], local nr.s are: "); 298 for(KeySet::iterator runner = FragmentSearch->FragmentSet->begin(); runner != FragmentSearch->FragmentSet->end(); runner++) 299 DoLog(0) && (Log() << Verbose(0) << (*runner) << " "); 300 DoLog(0) && (Log() << Verbose(0) << endl); 301 if (DoLog(2)) { 302 std::stringstream output; 303 output << "Found a new fragment[" << FragmentSearch->FragmentCounter << "], local nr.s are: "; 304 for(KeySet::iterator runner = FragmentSearch->FragmentSet->begin(); runner != FragmentSearch->FragmentSet->end(); runner++) 305 output << (*runner) << " "; 306 LOG(2, output.str()); 307 } 301 308 FragmentSearch->InsertFragmentIntoGraph(); 302 309 } 303 310 304 311 // --3-- remove all added items in this level from snake stack 305 L og() << Verbose(1+verbosity) << "Removing all items that were added on this SP level " << RootDistance << "." << endl;312 LOG(1+verbosity, "Removing all items that were added on this SP level " << RootDistance << "."); 306 313 RemoveAllTouchedFromSnakeStack(verbosity, FragmentSearch->FragmentSet, TouchedList, TouchedIndex); 307 314 } else { 308 L og() << Verbose(2+verbosity) << "More atoms to add for this set (" << bits << ") than space left on stack " << SubOrder << ", skipping this set." << endl;315 LOG(2+verbosity, "More atoms to add for this set (" << bits << ") than space left on stack " << SubOrder << ", skipping this set."); 309 316 } 310 317 } 311 318 delete[](TouchedList); 312 L og() << Verbose(1+verbosity) << "End of SPFragmentGenerator, " << RootDistance << " away from Root " << *FragmentSearch->getRoot() << " and SubOrder is " << SubOrder << "." << endl;313 }; 319 LOG(1+verbosity, "End of SPFragmentGenerator, " << RootDistance << " away from Root " << *FragmentSearch->getRoot() << " and SubOrder is " << SubOrder << "."); 320 };
Note:
See TracChangeset
for help on using the changeset viewer.
