Ignore:
Timestamp:
Nov 3, 2011, 7:44:01 PM (14 years ago)
Author:
Frederik Heber <heber@…>
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)
Message:

HUGE: Removed all calls to Log(), eLog(), replaced by LOG() and ELOG().

  • Replaced DoLog(.) && (Log() << Verbose(.) << ... << std::endl) by Log(., ...).
  • Replaced Log() << Verbose(.) << .. << by Log(., ...)
  • on multiline used stringstream to generate and message which was finally used in LOG(., output.str())
  • there should be no more occurence of Log(). LOG() and ELOG() must be used instead.
  • Eventually, this will allow for storing all errors and re-printing them on program exit which would be very helpful to ascertain error-free runs for the user.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Fragmentation/PowerSetGenerator.cpp

    r50e4e5 r47d041  
    2222#include "PowerSetGenerator.hpp"
    2323
     24#include <sstream>
     25
     26#include "CodePatterns/Info.hpp"
    2427#include "CodePatterns/Log.hpp"
    2528
     
    5356void PowerSetGenerator::ClearingTouched(int verbosity, int *&TouchedList, int SubOrder, int &TouchedIndex)
    5457{
    55   Log() << Verbose(1+verbosity) << "Clearing touched list." << endl;
     58  LOG(1+verbosity, "Clearing touched list.");
    5659  for (TouchedIndex=SubOrder+1;TouchedIndex--;)  // empty touched list
    5760    TouchedList[TouchedIndex] = -1;
     
    8184    if (bit) {  // if bit is set, we add this bond partner
    8285      OtherWalker = BondsSet[j]->rightatom;  // rightatom is always the one more distant, i.e. the one to add
    83       //Log() << Verbose(1+verbosity) << "Current Bond is " << BondsSet[j] << ", checking on " << *OtherWalker << "." << endl;
    84       Log() << 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() << ".");
    8588      TestKeySetInsert = FragmentSet->insert(OtherWalker->getNr());
    8689      if (TestKeySetInsert.second) {
     
    8891        Added++;
    8992      } else {
    90         Log() << 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.");
    9194      }
    9295    } else {
    93       Log() << Verbose(2+verbosity) << "Not adding." << endl;
     96      LOG(2+verbosity, "Not adding.");
    9497    }
    9598  }
     
    151154  for(int j=0;j<TouchedIndex;j++) {
    152155    Removal = TouchedList[j];
    153     Log() << Verbose(2+verbosity) << "Removing item nr. " << Removal << " from snake stack." << endl;
     156    LOG(2+verbosity, "Removing item nr. " << Removal << " from snake stack.");
    154157    FragmentSet->erase(Removal);
    155158    TouchedList[j] = -1;
    156159  }
    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: ";
    158162  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());
    161165  TouchedIndex = 0; // set Index to 0 for list of atoms added on this level
    162166};
     
    180184  int Counter = FragmentSearch->FragmentCounter; // mark current value of counter
    181185
    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() << ".");
    184188
    185189  BondsPerSPList.SetSPList(FragmentSearch->getRoot());
     
    193197  // creating fragments with the found edge sets  (may be done in reverse order, faster)
    194198  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 << ".");
    196200  if (SP >= (BondsPerSPList.getOrder()-1)) {
    197201    // 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() << ".");
    199203    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.");
    201205
    202206    // prepare the subset and call the generator
     
    209213    SPFragmentGenerator(0, BondsList, BondsPerSPList.BondsPerSPCount[0], BondsPerSPList.getOrder());
    210214  } 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.");
    212216  }
    213217
    214218  // as FragmentSearch structure is used only once, we don't have to clean it anymore
    215219  // remove root from stack
    216   DoLog(0) && (Log() << Verbose(0) << "Removing root again from stack." << endl);
     220  LOG(0, "Removing root again from stack.");
    217221  FragmentSearch->FragmentSet->erase(FragmentSearch->getRoot()->getNr());
    218222
     
    221225
    222226  // return list
    223   DoLog(0) && (Log() << Verbose(0) << "End of PowerSetGenerator." << endl);
     227  LOG(0, "End of PowerSetGenerator.");
    224228  return (FragmentSearch->FragmentCounter - Counter);
    225229};
     
    240244void PowerSetGenerator::SPFragmentGenerator(int RootDistance, std::vector<bond *> &BondsSet, int SetDimension, int SubOrder)
    241245{
     246  Info info(__func__);
    242247  int verbosity = 0; //FragmentSearch->ANOVAOrder-SubOrder;
    243248  int NumCombinations;
     
    253258  // recursively for the next level
    254259
    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).");
    257261
    258262  // initialised touched list (stores added atoms on this level)
     
    260264
    261265  // create every possible combination of the endpieces
    262   Log() << Verbose(1+verbosity) << "Going through all combinations of the power set." << endl;
     266  LOG(1+verbosity, "Going through all combinations of the power set.");
    263267  for (int i=1;i<NumCombinations;i++) {  // sweep through all power set combinations (skip empty set!)
    264268    // count the set bit of i
     
    267271      bits += (i & (1 << j)) >> j;
    268272
    269     Log() << 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 << ".");
    270274    if (bits <= SubOrder) { // if not greater than additional atoms allowed on stack, continue
    271275      // --1-- add this set of the power set of bond partners to the snake stack
     
    274278      SpaceLeft = SubOrder - Added ;// SubOrder - bits; // due to item's maybe being already present, this does not work anymore
    275279      if (SpaceLeft > 0) {
    276         Log() << 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 << ".");
    277281        if (SubOrder > 1) {    // Due to Added above we have to check extra whether we're not already reaching beyond the desired Order
    278282          // --2-- look at all added end pieces of this combination, construct bond subsets and sweep through a power set of these by recursion
     
    288292
    289293          // then iterate
    290           Log() << 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 << ".");
    291295          SPFragmentGenerator(SP, BondsList, SubSetDimension, SubOrder-bits);
    292296        }
    293297      } else {
    294298        // --2-- otherwise store the complete fragment
    295         Log() << Verbose(1+verbosity) << "Enough items on stack for a fragment!" << endl;
     299        LOG(1+verbosity, "Enough items on stack for a fragment!");
    296300        // 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        }
    301308        FragmentSearch->InsertFragmentIntoGraph();
    302309      }
    303310
    304311      // --3-- remove all added items in this level from snake stack
    305       Log() << 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 << ".");
    306313      RemoveAllTouchedFromSnakeStack(verbosity, FragmentSearch->FragmentSet, TouchedList, TouchedIndex);
    307314    } else {
    308       Log() << 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.");
    309316    }
    310317  }
    311318  delete[](TouchedList);
    312   Log() << 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.