Changeset d760bb for src/Fragmentation


Ignore:
Timestamp:
Feb 24, 2013, 12:59:18 PM (12 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, 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:
c91572
Parents:
b6b5b8
git-author:
Frederik Heber <heber@…> (02/19/13 12:42:38)
git-committer:
Frederik Heber <heber@…> (02/24/13 12:59:18)
Message:

REFACTOR: PowerSetGenerator now creates all orders in one go, not limited to one by one increments.

  • atom_bondedparticle's MaxOrder is not a bool but an int containing the desired final order set by CheckOrderAtSite and compared to AdaptiveOrder to obtain its old meaning.
  • UniqueFragments now contains a vector of n Graphs to place n-body fragments in that are later combined. Also, cleaned up a lot of old functions and merged stuff into cstor. FreeAllOrdersList() and CombineAllOrderListIntoOne() have been adapted accordingly.
  • Fragmentation::FragmentBOSSANOVA now uses fully again FragmentLowerOrdersList which now has the above n slots to place n-body fragments in and which is passed by ref to UniqueFragments.
  • SPFragmentGenerator now always stores the current fragment, only in a specific slot in UniqueFragment's Graphs, and it recurses if there are enough SP levels and plces left.
  • FIX: BondsPerShortestPath properly prints and informs about resetting the path list.
  • We checked extra that BondFragments come out exactly as before (same order because of the Graph being a map naturally). The only difference is the OrderAtSite file which now has more than 0/1 values in the second entry.
Location:
src/Fragmentation
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/Fragmentation/AdaptivityMap.cpp

    rb6b5b8 rd760bb  
    155155    if (Walker != NULL) {
    156156      //if ((*runner).second.second >= Walker->AdaptiveOrder) { // only insert if this is an "active" root site for the current order
    157       if (!Walker->MaxOrder) {
     157      if (Walker->MaxOrder > Walker->AdaptiveOrder) {
    158158        LOG(2, "(" << (*runner).first << ",[" << (*runner).second.first << "," << (*runner).second.second << "])");
    159159        FinalRootCandidates->insert( make_pair( (*runner).second.first, pair<int,int>((*runner).first, (*runner).second.second) ) );
  • TabularUnified src/Fragmentation/BondsPerShortestPath.cpp

    rb6b5b8 rd760bb  
    100100{
    101101  LOG(0, "Free'ing all found lists and resetting index lists");
    102   std::stringstream output;
    103102  for(int i=Order;i--;) {
     103    std::stringstream output;
    104104    output << "Current SP level is " << i << ": ";
    105105    // delete added bonds
     
    114114    // also start and end node
    115115    output << "cleaned.";
    116   }
    117   LOG(1, output.str());
     116    LOG(1, output.str());
     117  }
    118118};
    119119
     
    204204        Binder != BondsPerSPList[i].end();
    205205        ++Binder) {
    206       LOG(2, *Binder);
     206      LOG(2, **Binder);
    207207    }
    208208  }
     
    223223  return SP;
    224224};
    225 
    226 /** Getter for BondsPerShortestPath::Order.
    227  *
    228  * @return returns BondsPerShortestPath::Order
    229  */
    230 int BondsPerShortestPath::getOrder() const
    231 {
    232   return Order;
    233 }
  • TabularUnified src/Fragmentation/BondsPerShortestPath.hpp

    rb6b5b8 rd760bb  
    5050};
    5151
     52/** Getter for BondsPerShortestPath::Order.
     53 *
     54 * @return returns BondsPerShortestPath::Order
     55 */
     56#ifdef HAVE_INLINE
     57inline
     58#endif
     59int BondsPerShortestPath::getOrder() const
     60{
     61  return Order;
     62}
     63
    5264
    5365#endif /* BONDSPERSHORTESTPATH_HPP_ */
  • TabularUnified src/Fragmentation/Fragmentation.cpp

    rb6b5b8 rd760bb  
    200200{
    201201  Info FunctionInfo(__func__);
    202   Graph ***FragmentLowerOrdersList = NULL;
     202  std::vector<Graph*> *FragmentLowerOrdersList = NULL;
    203203  int NumLevels = 0;
    204204  int NumMolecules = 0;
     
    210210  int RootKeyNr = 0;
    211211  int RootNr = 0;
    212   UniqueFragments FragmentSearch;
    213212
    214213  // FragmentLowerOrdersList is a 2D-array of pointer to MoleculeListClass objects, one dimension represents the ANOVA expansion of a single order (i.e. 5)
    215214  // with all needed lower orders that are subtracted, the other dimension is the BondOrder (i.e. from 1 to 5)
    216215  NumMoleculesOfOrder = new int[UpgradeCount];
    217   FragmentLowerOrdersList = new Graph**[UpgradeCount];
    218 
    219   for(int i=0;i<UpgradeCount;i++) {
     216  FragmentLowerOrdersList = new std::vector<Graph*>[UpgradeCount];
     217
     218  for(int i=0;i<UpgradeCount;i++)
    220219    NumMoleculesOfOrder[i] = 0;
    221     FragmentLowerOrdersList[i] = NULL;
    222   }
    223 
    224   FragmentSearch.Init(mol->FindAtom(RootKeyNr));
    225220
    226221  // Construct the complete KeySet which we need for topmost level only (but for all Roots)
     
    244239    //} else
    245240    {
    246       // increase adaptive order by one
    247       Walker->GetTrueFather()->AdaptiveOrder++;
     241      // set adaptive order to desired max order
     242      Walker->GetTrueFather()->AdaptiveOrder = Walker->GetTrueFather()->MaxOrder;
    248243      Order = Walker->AdaptiveOrder = Walker->GetTrueFather()->AdaptiveOrder;
    249244
     245      // allocate memory for all lower level orders
     246      NumLevels = Order;
     247      FragmentLowerOrdersList[RootNr].resize(NumLevels, NULL);
     248      for( size_t i=0;i<NumLevels;++i)
     249        FragmentLowerOrdersList[RootNr][i] = new Graph;
     250
    250251      // initialise Order-dependent entries of UniqueFragments structure
    251       class PowerSetGenerator PSG(&FragmentSearch, Walker->AdaptiveOrder);
    252 
    253       // allocate memory for all lower level orders in this 1D-array of ptrs
    254       NumLevels = 1 << (Order-1); // (int)pow(2,Order);
    255       FragmentLowerOrdersList[RootNr] = new Graph*[NumLevels];
    256       for (int i=0;i<NumLevels;i++)
    257         FragmentLowerOrdersList[RootNr][i] = NULL;
     252      UniqueFragments FragmentSearch(1., FragmentLowerOrdersList[RootNr], Walker);
     253      PowerSetGenerator PSG(&FragmentSearch, Walker->AdaptiveOrder);
    258254
    259255      // create top order where nothing is reduced
    260256      LOG(0, "==============================================================================================================");
    261       LOG(0, "Creating KeySets of Bond Order " << Order << " for " << *Walker << ", " << (RootStack.size()-RootNr) << " Roots remaining."); // , NumLevels is " << NumLevels << "
     257      LOG(0, "Creating KeySets up till Bond Order " << Order << " for " << *Walker << ", " << (RootStack.size()-RootNr) << " Roots remaining."); // , NumLevels is " << NumLevels << "
    262258
    263259      // Create list of Graphs of current Bond Order (i.e. F_{ij})
    264       FragmentLowerOrdersList[RootNr][0] = new Graph;
    265       FragmentSearch.PrepareForPowersetGeneration(1., FragmentLowerOrdersList[RootNr][0], Walker);
    266260      NumMoleculesOfOrder[RootNr] = PSG(CompleteMolecule, saturation);
    267261
     
    270264      if (NumMoleculesOfOrder[RootNr] != 0) {
    271265        NumMolecules = 0;
    272       } else {
    273         Walker->GetTrueFather()->MaxOrder = true;
    274266      }
    275267      // now, we have completely filled each cell of FragmentLowerOrdersList[] for the current Walker->AdaptiveOrder
     
    284276  LOG(1, "Total number of resulting molecules is: " << TotalNumMolecules << ".");
    285277  LOG(0, "==============================================================================================================");
    286 
    287   // cleanup FragmentSearch structure
    288   FragmentSearch.Cleanup();
    289278
    290279  // now, FragmentLowerOrdersList is complete, it looks - for BondOrder 5 - as this (number is the ANOVA Order of the terms therein)
     
    362351    delete[](IndexKeySetList);
    363352  } else { // global increase of Bond Order
    364     for(molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     353    for(molecule::iterator iter = mol->begin(); iter != mol->end(); ++iter) {
    365354      if (AtomMask.isTrue((*iter)->getNr())) { // skip masked out
     355        (*iter)->MaxOrder = (Order != 0 ? Order : (*iter)->MaxOrder+1);
    366356        // remove all that have reached desired order
    367         if ((Order != 0) && ((*iter)->AdaptiveOrder >= Order)) // && ((*iter)->AdaptiveOrder < MinimumRingSize[(*iter)->getNr()]))
     357        if ((*iter)->AdaptiveOrder >= (*iter)->MaxOrder) // && ((*iter)->AdaptiveOrder < MinimumRingSize[(*iter)->getNr()]))
    368358          AtomMask.setFalse((*iter)->getNr());
    369359        else
     
    450440    for(molecule::iterator iter=mol->begin();iter!=mol->end();++iter){
    451441      (*iter)->AdaptiveOrder = OrderArray[(*iter)->getNr()];
    452       (*iter)->MaxOrder = MaxArray.isTrue((*iter)->getNr());
     442      (*iter)->MaxOrder = OrderArray[(*iter)->getNr()]; //MaxArray.isTrue((*iter)->getNr());
    453443    }
    454444    //SetAtomValueToIndexedArray( OrderArray, &atom::getNr(), &atom::AdaptiveOrder );
  • TabularUnified src/Fragmentation/PowerSetGenerator.cpp

    rb6b5b8 rd760bb  
    5050 *
    5151 */
    52 PowerSetGenerator::PowerSetGenerator(class UniqueFragments *_FragmentSearch, int Order) :
    53   BondsPerSPList(Order),
     52PowerSetGenerator::PowerSetGenerator(UniqueFragments *_FragmentSearch, int _Order) :
     53  BondsPerSPList(_Order),
    5454  FragmentSearch(_FragmentSearch)
    5555{}
     
    213213  int SP = BondsPerSPList.CountNumbersInBondsList();
    214214  LOG(0, "Total number of edges is " << SP << ".");
    215   if (SP >= (BondsPerSPList.getOrder()-1)) {
     215  {
    216216    // start with root (push on fragment stack)
    217217    LOG(0, "Starting fragment generation with " << *FragmentSearch->getRoot() << ", local nr is " << FragmentSearch->getRoot()->getNr() << ".");
     
    227227
    228228    SPFragmentGenerator(0, BondsList, BondsPerSPList.BondsPerSPCount[0], BondsPerSPList.getOrder());
    229   } else {
    230     LOG(0, "Not enough total number of edges to build " << BondsPerSPList.getOrder() << "-body fragments.");
    231229  }
    232230
     
    261259  Info info(__func__);
    262260  int verbosity = 0; //FragmentSearch->ANOVAOrder-SubOrder;
    263   int NumCombinations;
    264   int bits, TouchedIndex, SubSetDimension, SP, Added;
     261  int TouchedIndex, SubSetDimension, Added;
    265262  int SpaceLeft;
    266263  int *TouchedList = new int[SubOrder + 1];
    267264  KeySetTestPair TestKeySetInsert;
    268265
    269   NumCombinations = 1 << SetDimension;
     266  const int NumCombinations = 1 << SetDimension;
    270267
    271268  // here for all bonds of Walker all combinations of end pieces (from the bonds)
     
    282279  for (int i=1;i<NumCombinations;i++) {  // sweep through all power set combinations (skip empty set!)
    283280    // count the set bit of i
    284     bits = 0;
    285     for (int j=SetDimension;j--;)
    286       bits += (i & (1 << j)) >> j;
     281    const int bits = countBits(i, SetDimension);
    287282
    288283    LOG(1+verbosity, "Current set is " << Binary(i | (1 << SetDimension)) << ", number of bits is " << bits << ".");
     
    291286      Added = AddPowersetToSnakeStack(verbosity, i, SetDimension, FragmentSearch->FragmentSet, BondsSet, TouchedList, TouchedIndex);
    292287
     288      // --2-- store the fragment
     289      const int order = BondsPerSPList.getOrder() - SubOrder + Added - 1;
     290      LOG(1+verbosity, "Storing fragment as order " << order << ".");
     291      // store fragment as a KeySet
     292      if (DoLog(2)) {
     293        std::stringstream output;
     294        output << "Found a new fragment[" << FragmentSearch->FragmentCounter << "], local nr.s are: ";
     295        for(KeySet::iterator runner = FragmentSearch->FragmentSet->begin(); runner != FragmentSearch->FragmentSet->end(); runner++)
     296          output << (*runner) << " ";
     297        LOG(2, output.str());
     298      }
     299      FragmentSearch->InsertFragmentIntoGraph(order);
     300
     301      // --3-- if below SubOrder still, recurse
    293302      SpaceLeft = SubOrder - Added ;// SubOrder - bits; // due to item's maybe being already present, this does not work anymore
    294       if (SpaceLeft > 0) {
     303      if ((SpaceLeft > 0) && (RootDistance < BondsPerSPList.getOrder())) {
    295304        LOG(1+verbosity, "There's still some space left on stack: " << SpaceLeft << ".");
    296305        if (SubOrder > 1) {    // Due to Added above we have to check extra whether we're not already reaching beyond the desired Order
    297306          // --2-- look at all added end pieces of this combination, construct bond subsets and sweep through a power set of these by recursion
    298           SP = RootDistance+1;  // this is the next level
     307          const int SP = RootDistance+1;  // this is the next level
    299308
    300309          // first count the members in the subset
     
    311320        }
    312321      } else {
    313         // --2-- otherwise store the complete fragment
    314         LOG(1+verbosity, "Enough items on stack for a fragment!");
    315         // store fragment as a KeySet
    316         if (DoLog(2)) {
    317           std::stringstream output;
    318           output << "Found a new fragment[" << FragmentSearch->FragmentCounter << "], local nr.s are: ";
    319           for(KeySet::iterator runner = FragmentSearch->FragmentSet->begin(); runner != FragmentSearch->FragmentSet->end(); runner++)
    320             output << (*runner) << " ";
    321           LOG(2, output.str());
    322         }
    323         FragmentSearch->InsertFragmentIntoGraph();
     322        LOG(1+verbosity, "No more space or no shortest path levels, not recursing.");
    324323      }
    325324
  • TabularUnified src/Fragmentation/PowerSetGenerator.hpp

    rb6b5b8 rd760bb  
    2626{
    2727public:
    28   PowerSetGenerator(UniqueFragments *_FragmentSearch, int Order);
     28  PowerSetGenerator(UniqueFragments *_FragmentSearch, int _Order);
    2929  ~PowerSetGenerator();
    3030
     
    3838
    3939private:
     40  int countBits(const int bits, const int SetDimension) const;
     41
    4042  BondsPerShortestPath BondsPerSPList;
     43  UniqueFragments *FragmentSearch;
     44};
    4145
    42   class UniqueFragments *FragmentSearch;
    43 };
     46#ifdef HAVE_INLINE
     47inline
     48#endif
     49int PowerSetGenerator::countBits(const int i, const int SetDimension) const
     50{
     51  int bits = 0;
     52  for (int j=SetDimension;j--;)
     53    bits += (i & (1 << j)) >> j;
     54  return bits;
     55}
    4456
    4557
  • TabularUnified src/Fragmentation/UniqueFragments.cpp

    rb6b5b8 rd760bb  
    3737#include "UniqueFragments.hpp"
    3838
     39#include "CodePatterns/Assert.hpp"
    3940#include "CodePatterns/Log.hpp"
    4041
     
    4849/** Constructor of class UniqueFragments.
    4950 *
     51 * @param _TEFactor total energy factor
     52 * @param _Leaflet current graph to work on
     53 * @param _Root root atom
    5054 */
    51 UniqueFragments::UniqueFragments()
    52 {}
     55UniqueFragments::UniqueFragments(double _TEFactor, std::vector<Graph*> &_Leaflets, atom *_Root) :
     56    FragmentCounter(0),
     57    Root(_Root),
     58    TEFactor(_TEFactor),
     59    Leaflets(_Leaflets)
     60{
     61  FragmentSet = new KeySet;
     62}
    5363
    5464/** Destructor of class UniqueFragments.
     
    5666 */
    5767UniqueFragments::~UniqueFragments()
    58 {}
     68{
     69  Cleanup();
     70}
    5971
    6072/** Checking whether KeySet is not already present in Graph, if so just adds factor.
     73 *
     74 * \param order order at which to insert
    6175 */
    62 void UniqueFragments::InsertFragmentIntoGraph()
     76void UniqueFragments::InsertFragmentIntoGraph(const size_t order)
    6377{
    6478  GraphTestPair testGraphInsert;
    6579
    66   testGraphInsert = Leaflet->insert(GraphPair (*FragmentSet,std::pair<int,double>(FragmentCounter,TEFactor)));  // store fragment number and current factor
     80  ASSERT( Leaflets.size() > order,
     81      "UniqueFragments::InsertFragmentIntoGraph() - Leaflets has only "
     82      +toString(Leaflets.size())+" entries, not enough for "+toString(order));
     83  testGraphInsert = Leaflets[order]->insert(GraphPair (*FragmentSet,std::pair<int,double>(FragmentCounter,TEFactor)));  // store fragment number and current factor
    6784  if (testGraphInsert.second) {
    6885    LOG(2, "KeySet " << FragmentCounter << " successfully inserted.");
     
    7592};
    7693
    77 /** Initialization for UniqueFragments.
    78  *
    79  * \param _Root ref to atom to start from (with graph algorithms, hence root node)
    80  * \param AtomCount number of nodes/atoms
    81  */
    82 void UniqueFragments::Init(atom *_Root)
    83 {
    84   // initialise the fragments structure
    85   FragmentCounter = 0;
    86   FragmentSet = new KeySet;
    87   Root = _Root;
    88 }
    89 
    9094/** Removes some allocated memory.
    9195 *
     
    9397void UniqueFragments::Cleanup()
    9498{
    95   delete(FragmentSet);
     99  delete FragmentSet;
    96100}
    97101
     
    113117  Root=_root;
    114118}
    115 
    116 /** Sets initial values before PowerSetGenerator uses this class.
    117  *
    118  * @param _TEFactor total energy factor
    119  * @param _Leaflet current graph to work on
    120  * @param _Root root atom
    121  */
    122 void UniqueFragments::PrepareForPowersetGeneration(double _TEFactor, Graph *_Leaflet, atom *_Root)
    123 {
    124   TEFactor = _TEFactor;
    125   Leaflet = _Leaflet;
    126   Root = _Root;
    127 }
  • TabularUnified src/Fragmentation/UniqueFragments.hpp

    rb6b5b8 rd760bb  
    1414#endif
    1515
    16 #include <list>
    1716#include <vector>
    1817
    1918class atom;
    20 class bond;
    21 class config;
    2219class Graph;
    2320class KeySet;
     
    2825{
    2926public:
    30   UniqueFragments();
     27  UniqueFragments(
     28      double _TEFactor,
     29      std::vector<Graph*> &Leaflets,
     30      atom *_Root);
    3131  ~UniqueFragments();
    3232
    33   void InsertFragmentIntoGraph(); // Insert a KeySet into a Graph
    34   void Init(atom *_Root);
     33  void InsertFragmentIntoGraph(const size_t order); // Insert a KeySet into a Graph
    3534  void Cleanup();
    3635
    3736  atom * const getRoot() const;
    3837  void setRoot(atom *_root);
    39 
    40   void PrepareForPowersetGeneration(double _TEFactor, Graph *_Leaflet, atom *_Root);
    4138
    4239  KeySet *FragmentSet;
     
    4643  atom *Root;
    4744  double TEFactor;
    48   Graph *Leaflet;
    49 
    50 private:
    51   int ANOVAOrder;
    52   int CurrentIndex;
    53   bool **UsedList;
     45  std::vector<Graph*> &Leaflets;
    5446};
    5547
  • TabularUnified src/Fragmentation/fragmentation_helpers.cpp

    rb6b5b8 rd760bb  
    3737#include "fragmentation_helpers.hpp"
    3838
     39#include <algorithm>
    3940#include <sstream>
    4041
     42#include "CodePatterns/Assert.hpp"
    4143#include "CodePatterns/Log.hpp"
    4244
    4345#include "Atom/atom.hpp"
    44 #include "Bond/bond.hpp"
    45 #include "Element/element.hpp"
    4646#include "Fragmentation/AdaptivityMap.hpp"
    4747#include "Fragmentation/AtomMask.hpp"
     
    8282 * \param *mol molecule with atoms and bonds
    8383 */
    84 int CombineAllOrderListIntoOne(Graph &FragmentList, Graph ***FragmentLowerOrdersList, KeyStack &RootStack, molecule *mol)
     84int CombineAllOrderListIntoOne(Graph &FragmentList, std::vector<Graph*> *&FragmentLowerOrdersList, KeyStack &RootStack, molecule *mol)
    8585{
    8686  int RootNr = 0;
     
    9999    RootStack.pop_front();
    100100    Walker = mol->FindAtom(RootKeyNr);
    101     NumLevels = 1 << (Walker->AdaptiveOrder - 1);
     101    NumLevels = Walker->AdaptiveOrder;
     102    ASSERT( NumLevels == FragmentLowerOrdersList[RootNr].size(),
     103        "CombineAllOrderListIntoOne() - differing size and NumLevels.");
    102104    for(int i=0;i<NumLevels;i++) {
    103105      if (FragmentLowerOrdersList[RootNr][i] != NULL) {
     
    113115/** Free's memory allocated for all KeySets from all orders.
    114116 * \param *out output stream for debugging
    115  * \param ***FragmentLowerOrdersList
     117 * \param **&FragmentLowerOrdersList
    116118 * \param &RootStack stack with all root candidates (unequal to each atom in complete molecule if adaptive scheme is applied)
    117119 * \param *mol molecule with atoms and bonds
    118120 */
    119 void FreeAllOrdersList(Graph ***FragmentLowerOrdersList, KeyStack &RootStack, molecule *mol)
     121void FreeAllOrdersList(std::vector<Graph*> *&FragmentLowerOrdersList, KeyStack &RootStack, molecule *mol)
    120122{
    121123  LOG(1, "Free'ing the lists of all orders per order.");
     
    128130    RootStack.pop_front();
    129131    Walker = mol->FindAtom(RootKeyNr);
    130     NumLevels = 1 << (Walker->AdaptiveOrder - 1);
     132    NumLevels = Walker->AdaptiveOrder;
    131133    for(int i=0;i<NumLevels;i++) {
    132134      if (FragmentLowerOrdersList[RootNr][i] != NULL) {
    133         delete(FragmentLowerOrdersList[RootNr][i]);
     135        delete FragmentLowerOrdersList[RootNr][i];
    134136      }
     137      FragmentLowerOrdersList[RootNr].clear();
    135138    }
    136     delete[](FragmentLowerOrdersList[RootNr]);
    137139    RootNr++;
    138140  }
    139   delete[](FragmentLowerOrdersList);
     141  delete[] FragmentLowerOrdersList;
    140142};
    141143
  • TabularUnified src/Fragmentation/fragmentation_helpers.hpp

    rb6b5b8 rd760bb  
    1515
    1616#include <deque>
    17 #include <list>
    18 #include <map>
    19 #include <string>
    2017#include <vector>
    2118
     
    3128void PrintAtomMask(const AtomMask_t &AtomMask, int AtomCount);
    3229
    33 int CombineAllOrderListIntoOne(Graph &FragmentList, Graph ***FragmentLowerOrdersList, KeyStack &RootStack, molecule *mol);
    34 void FreeAllOrdersList(Graph ***FragmentLowerOrdersList, KeyStack &RootStack, molecule *mol);
     30int CombineAllOrderListIntoOne(Graph &FragmentList, std::vector<Graph*> *&FragmentLowerOrdersList, KeyStack &RootStack, molecule *mol);
     31void FreeAllOrdersList(std::vector<Graph*> *&FragmentLowerOrdersList, KeyStack &RootStack, molecule *mol);
    3532
    3633const std::vector<atomId_t> getGlobalIdsFromLocalIds(const molecule &mol, const std::vector<atomId_t> &atomids);
Note: See TracChangeset for help on using the changeset viewer.