Ignore:
Timestamp:
Nov 20, 2012, 11:04:12 AM (13 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, Candidate_v1.7.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:
a22e05
Parents:
cebac0 (diff), a1436b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'VMGJob_SamplingNucleiCharges' into Candidate_v1.3.5

Location:
src/Fragmentation/Summation
Files:
11 added
14 edited
1 moved

Legend:

Unmodified
Added
Removed
  • src/Fragmentation/Summation/AllLevelSummator.hpp

    rcebac0 r36bb2d  
    11/*
    2  * printSum.hpp
     2 * AllLevelSummator.hpp
    33 *
    44 *  Created on: 29.07.2012
     
    66 */
    77
    8 #ifndef PRINTSUM_HPP_
    9 #define PRINTSUM_HPP_
     8#ifndef ALLLEVELSUMMATOR_HPP_
     9#define ALLLEVELSUMMATOR_HPP_
    1010
    1111// include config.h
     
    1616#include <vector>
    1717
     18#include "CodePatterns/Assert.hpp"
     19
    1820#include "Fragmentation/Summation/IndexSetContainer.hpp"
    1921#include "Fragmentation/Summation/SubsetMap.hpp"
     
    2224#include "Fragmentation/Summation/printKeyNames.hpp"
    2325
    24 /** Tiny template functor to use OrthogonalSummation, sum up and print the result.
     26/** Tiny template functor to use Summation, sum up each level, and store the
     27 * result in a given vector.
    2528 *
    2629 */
    2730template <typename MapType>
    28 struct printSum {
     31struct AllLevelSummator {
    2932  /** Constructor takes the arguments that \a Summator also needs and stores
    3033   * them internally.
     
    3639   *        to job id and hence to _data.
    3740   * \param _MatrixNrLookup lookup from job id to ordering in above vectors
     41   * \param _results vector place results into
    3842   */
    39   printSum(
     43  AllLevelSummator(
    4044      SubsetMap::ptr &_subsetmap,
    4145      const std::vector<MapType> &_data,
    4246      const std::vector<JobId_t> &_jobids,
    4347      const IndexSetContainer::Container_t &_container,
    44       std::map< JobId_t, size_t > &_MatrixNrLookup) : /* cannot make this const due to operator[] */
     48      std::map< JobId_t, size_t > &_MatrixNrLookup,  /* cannot make this const due to operator[] */
     49      std::vector<MapType> &_results) :
    4550    subsetmap(_subsetmap),
    4651    data(_data),
    4752    jobids(_jobids),
    4853    container(_container),
    49     MatrixNrLookup(_MatrixNrLookup)
    50   {}
     54    MatrixNrLookup(_MatrixNrLookup),
     55    results(_results)
     56  {
     57    ASSERT( results.size() >= subsetmap->getMaximumSubsetLevel(),
     58        "AllLevelSummator() - result vector is not large enough.");
     59  }
    5160
    5261  /** Operator that calls on Summator and prints the value.
     
    6372        subsetmap, data, jobids, container, MatrixNrLookup
    6473        );
    65     // sum up
    66     MapValue value = sum_value();
    67     // print value
    68     LOG(0, "STATUS: Resulting " << printKeyNames::printName<MapKey>() << " is " << value << ".");
     74    const size_t MaxLevel = subsetmap->getMaximumSubsetLevel();
     75    for (size_t level=1; level <= MaxLevel; ++level) {
     76      MapType &LevelResults = results[level-1];
     77      // sum up and store in results
     78      const MapValue value = sum_value(level);
     79      boost::fusion::at_key<MapKey>(LevelResults) = value;
     80      // print value
     81      //LOG(0, "STATUS: Level " << level << " resulting " << printKeyNames::printName<MapKey>() << " is " << value << ".");
     82    }
    6983  }
    7084
     
    8094  //!> lookup map from job ids to ordering in above vectors
    8195  std::map< JobId_t, size_t > MatrixNrLookup;
     96  //!> vector of results
     97  std::vector<MapType> &results;
    8298};
    8399
    84 #endif /* PRINTSUM_HPP_ */
     100#endif /* ALLLEVELSUMMATOR_HPP_ */
  • src/Fragmentation/Summation/IndexSetContainer.hpp

    rcebac0 r36bb2d  
    2222
    2323class IndexSetContainerTest;
     24class KeySetsContainer;
    2425
    2526/**
     
    6364    SortedVector<IndexSet>(_instance)
    6465  {}
     66
     67  /** Conversion constructor from a KeySetConntainer.
     68   *
     69   * We create the super set of all found key sets and then each single set,
     70   * while always dropping indices equal to -1.
     71   *
     72   * @param _keysets keysets to turn into IndexSets
     73   */
     74  explicit IndexSetContainer(const KeySetsContainer &_keysets);
     75
     76  /** Sum up the number of IndexSets with indices less or equal to \a level.
     77   *
     78   * Sadly, we have to re-implement a binary search as size_t != IndexSet::ptr.
     79   *
     80   * @param level maximum set size
     81   * @return number of sets up till \a level
     82   */
     83  size_t countSetsTillLevel(const size_t level) const;
     84
     85private:
     86  /** Helper function to get the super set out of a KeySetsContainer.
     87   *
     88   * @param _keysets keysets to construct super set for
     89   * @return IndexSet that contains each index once that appears in the sets of \a _keysets
     90   */
     91  IndexSet::ptr& createSuperSet(const KeySetsContainer &_keysets) const;
     92
     93  //!> static instance for AllIndices such that createSuperSet may return a reference.
     94  static IndexSet::ptr AllIndices;
    6595};
     96
    6697//!> typedef for IndexSet instance stored as shared_ptr in SortedVector
    6798typedef IndexSetContainer::T_ptr IndexSet_ptr;
  • src/Fragmentation/Summation/Makefile.am

    rcebac0 r36bb2d  
    44FRAGMENTATIONSUMMATIONSOURCE = \
    55        Fragmentation/Summation/IndexSet.cpp \
     6        Fragmentation/Summation/IndexSetContainer.cpp \
    67        Fragmentation/Summation/SubsetMap.cpp
    78
    89FRAGMENTATIONSUMMATIONHEADER = \
     10        Fragmentation/Summation/AllLevelOrthogonalSummator.hpp \
     11        Fragmentation/Summation/AllLevelSummator.hpp \
     12        Fragmentation/Summation/HeaderPrinter.hpp \
    913        Fragmentation/Summation/IndexSet.hpp \
    1014        Fragmentation/Summation/IndexSetContainer.hpp \
    1115        Fragmentation/Summation/OrthogonalSummation.hpp \
    1216        Fragmentation/Summation/OrthogonalSummation_impl.hpp \
     17        Fragmentation/Summation/OrthogonalSummator.hpp \
    1318        Fragmentation/Summation/printKeyNames.hpp \
    14         Fragmentation/Summation/printSum.hpp \
    1519        Fragmentation/Summation/SetValue.hpp \
    1620        Fragmentation/Summation/SetValueMap.hpp \
    1721        Fragmentation/Summation/SortedVector.hpp \
    1822        Fragmentation/Summation/SubsetMap.hpp \
    19         Fragmentation/Summation/Summator.hpp
     23        Fragmentation/Summation/Summation.hpp \
     24        Fragmentation/Summation/Summation_impl.hpp \
     25        Fragmentation/Summation/Summator.hpp \
     26        Fragmentation/Summation/ValuePrinter.hpp \
     27        Fragmentation/Summation/writeTable.hpp \
     28        Fragmentation/Summation/ZeroInstance.hpp
    2029
    2130
  • src/Fragmentation/Summation/OrthogonalSummation.hpp

    rcebac0 r36bb2d  
    2525 *
    2626 *  For the given class we require the following functions:
    27  *  -# operator=(): assigment operator for placement in vector
     27 *  -# operator=(): assignment operator for placement in vector
    2828 *  -# operator+=(): addition operator for adding one instance from another
    2929 *  -# operator-=(): subtraction operator for subtracting one instance from another
     
    4040  /** Performs the orthogonal summation and returns result.
    4141   *
     42   * @param level sum up to this level
    4243   * @return resulting value
    4344   */
    44   T operator()() const;
     45  T operator()(const size_t level) const;
     46
     47  /** Returns const reference to internal setvalues.
     48   *
     49   * @return const reference to internal setvalues.
     50   */
     51  const SetValueMap<T> & getSetValues() const {
     52    return setvalues;
     53  }
    4554
    4655private:
    47   T Sum() const;
     56  T Sum(const size_t level) const;
    4857
    4958private:
  • src/Fragmentation/Summation/OrthogonalSummation_impl.hpp

    rcebac0 r36bb2d  
    1717#include "CodePatterns/IteratorAdaptors.hpp"
    1818#include "CodePatterns/Log.hpp"
     19
     20#include "Fragmentation/Summation/ZeroInstance.hpp"
    1921
    2022/** Constructor of class OrthogonalSummation.
     
    5759
    5860template <class T>
    59 T OrthogonalSummation<T>::operator()() const
     61T OrthogonalSummation<T>::operator()(const size_t level) const
    6062{
    61   return Sum();
     63  return Sum(level);
    6264}
    6365
    6466template <class T>
    65 T OrthogonalSummation<T>::Sum() const
     67T OrthogonalSummation<T>::Sum(const size_t level) const
    6668{
    6769  typename SetValueMap<T>::const_iterator iter = setvalues.begin();
    68   T sum = (iter->second)->getContribution();
     70  T sum(ZeroInstance<T>());
     71  if (iter->first->size() <= level)
     72    sum = (iter->second)->getContribution();
    6973  LOG(1, "DEBUG: Contribution from subset "+toString(*(iter->second->getIndexSet()))
    7074      +" is "+toString(sum)+".");
    71   for(++iter;iter != setvalues.end(); ++iter) {
     75  for(++iter;(iter != setvalues.end()) && (iter->first->size() <= level); ++iter) {
    7276    const T tempvalue = (iter->second)->getContribution();
    7377    sum += tempvalue;
  • src/Fragmentation/Summation/SetValue.hpp

    rcebac0 r36bb2d  
    3434  //!> grant OrthogonalSummation access to static lookup functions
    3535  template <class TT> friend class OrthogonalSummation;
     36  //!> grant Summation access to static lookup functions
     37  template <class TT> friend class Summation;
    3638public:
    3739  typedef boost::shared_ptr< SetValue<T> > ptr;
  • src/Fragmentation/Summation/SubsetMap.cpp

    rcebac0 r36bb2d  
    183183  return indexset;
    184184}
     185
     186size_t SubsetMap::getMaximumSubsetLevel() const
     187{
     188  // last one is super set, hence, the one before has largest subset size
     189  Lookup_t::const_iterator iter = --Lookup.end();
     190  --iter;
     191  return iter->first->size();
     192}
     193
     194size_t SubsetMap::getMaximumSetLevel() const
     195{
     196  // last one is super set
     197  Lookup_t::const_iterator iter = --Lookup.end();
     198  return iter->first->size();
     199}
  • src/Fragmentation/Summation/SubsetMap.hpp

    rcebac0 r36bb2d  
    5959  }
    6060
     61  /** Returns the size of the largest \b sub set.
     62   *
     63   * This would be \f${\cal O}(n)\f$ if we had to look at each set. However, due
     64   * to the specific sorting we just have to check the last sets.
     65   *
     66   * @return number of indices in largest subset, -1 if SubsetMap contains no IndexSet's
     67   */
     68  size_t getMaximumSubsetLevel() const;
     69
     70  /** Returns the size of the largest set.
     71   *
     72   * @return number of indices in largest set
     73   */
     74  size_t getMaximumSetLevel() const;
     75
    6176private:
    6277  /** Private function to fill the internal Lookup for a given IndexSet \a ptr.
  • src/Fragmentation/Summation/Summator.hpp

    rcebac0 r36bb2d  
    1616#include <boost/fusion/sequence.hpp>
    1717
    18 #include "Fragmentation/Summation/OrthogonalSummation.hpp"
     18#include "Fragmentation/Summation/Summation.hpp"
    1919#include "Fragmentation/Summation/SetValue.hpp"
    2020#include "Jobs/MPQCDataMap.hpp"
    2121
    22 /** Summator is a general class for making us of OrthogonalSummation.
     22/** Summator is a general class for making us of Summation.
    2323 *
    2424 * The idea is that we want to sum up not only one value but a whole bunch of.
     
    3232 * key. Via this key, which is a type and hence can be used for template
    3333 * specification, we may gather all information for launching the
    34  * OrthogonalSummation. We only need to convert MPQCData into the above
     34 * Summation. We only need to convert MPQCData into the above
    3535 * MPQCDataMap_t instance and may then access the member variables via the above
    3636 * key and also obtain the type at \b run-time through the key.
     
    7373      const IndexSetContainer::Container_t &_container,
    7474      std::map< JobId_t, size_t > &_MatrixNrLookup) : /* cannot make this const due to operator[] */
    75     subsetmap(_subsetmap),
    76     data(_data),
    77     jobids(_jobids),
    78     container(_container),
    79     MatrixNrLookup(_MatrixNrLookup)
     75    indices(getSubsets(_container)),
     76    values(createValues(_data, _jobids, _container, _MatrixNrLookup)),
     77    OS(indices, values, _subsetmap)
    8078  {
    81     ASSERT( data.size() == jobids.size(),
     79    ASSERT( _data.size() == _jobids.size(),
    8280        "Summator() - data and ids don't have same size.");
    83     ASSERT( jobids.size() == MatrixNrLookup.size(),
     81    ASSERT( _jobids.size() == _MatrixNrLookup.size(),
    8482        "Summator() - ids and MatrixNrLookup don't have same size.");
    8583  }
     
    8785  /** Summation operator.
    8886   *
    89    * Initialises instantiated OrthogonalSummation of the respective type via
    90    * \a Summator::data, uses OrthogonalSummation::operator() to sum and returns
     87   * Initialises instantiated Summation of the respective type via
     88   * \a Summator::data, uses Summation::operator() to sum and returns
    9189   * the result.
    9290   *
    93    * \return result of OrthogonalSummation for given type from MPQCDataMap_t.
     91   * \param level up to which level to sum up
     92   * \return result of Summation for given type from MPQCDataMap_t.
    9493   */
    95   MapValue operator()()
     94  MapValue operator()(const size_t level)
     95  {
     96    // evaluate
     97    const MapValue result = OS(level);
     98    return result;
     99  }
     100
     101private:
     102  /** Tiny helper to create the indices from a given IndexSetContainer.
     103   *
     104   * Basically, we just have to make sure we miss the last one but only
     105   * if the \a container has more than one set.
     106   *
     107   * @param container container with IndexSet
     108   * @return all subsets contained in \a container
     109   */
     110  typename Summation<MapValue>::InputSets_t getSubsets(
     111      const IndexSetContainer::Container_t &container)
    96112  {
    97113    // if we just have one indexset, we don't need to get rid of the "union index set"
    98     typename OrthogonalSummation<MapValue>::InputSets_t indices(
     114    typename Summation<MapValue>::InputSets_t indices(
    99115        container.begin(),
    100116        container.end()-1 == container.begin() ? container.end() : container.end()-1);
    101     typename OrthogonalSummation<MapValue>::InputValues_t values(
     117    return indices;
     118  }
     119
     120  /** Tiny helper to create the values for the summation in the correct order.
     121   *
     122   * @param data
     123   * @param jobids
     124   * @param container
     125   * @param MatrixNrLookup
     126   * @return
     127   */
     128  typename Summation<MapValue>::InputValues_t createValues(
     129      const std::vector<MapType> &data,
     130      const std::vector<JobId_t> &jobids,
     131      const IndexSetContainer::Container_t &container,
     132      std::map< JobId_t, size_t > &MatrixNrLookup)
     133  {
     134    // if we just have one indexset, we don't need to get rid of the "union index set"
     135    typename Summation<MapValue>::InputValues_t values(
    102136        container.size() == 1 ? (size_t)1 : container.size()-1);
    103137    typename std::vector<MapType>::const_iterator dataiter = data.begin();
     
    108142      values[ MatrixNrLookup[*iditer] ] = value;
    109143    }
    110 
    111     // create the summation functor and evaluate
    112     OrthogonalSummation<MapValue> OS(indices, values, subsetmap);
    113     const MapValue result = OS();
    114     return result;
     144    return values;
    115145  }
    116 
    117146private:
    118   //!> Hierarchy of IndexSet's
    119   SubsetMap::ptr &subsetmap;
    120   //!> vector of data converted from MPQCData
    121   const std::vector<MapType> &data;
    122   //!> vector of jobids
    123   const std::vector<JobId_t> &jobids;
    124   //!> container with all IndexSet's
    125   const IndexSetContainer::Container_t &container;
    126   //!> lookup map from job ids to ordering in above vectors
    127   std::map< JobId_t, size_t > MatrixNrLookup;
     147  //!> created indices for OS such that we may hand over refs
     148  typename Summation<MapValue>::InputSets_t indices;
     149  //!> created values for OS such that we may hand over refs
     150  typename Summation<MapValue>::InputValues_t values;
     151  //!> Summation instance to use in operator()(level)
     152  Summation<MapValue> OS;
    128153};
    129154
  • src/Fragmentation/Summation/unittests/IndexSetContainerUnitTest.cpp

    rcebac0 r36bb2d  
    4545#include <boost/assign.hpp>
    4646#include <boost/foreach.hpp>
     47
     48#include "Fragmentation/KeySetsContainer.hpp"
    4749
    4850#ifdef HAVE_TESTRUNNER
     
    138140  CPPUNIT_ASSERT( !SV->ContainerSorted );
    139141}
     142
     143/** Unit tests for cstr(KeySetsContainer)
     144 *
     145 */
     146void IndexSetContainerTest::KeySetContainerTest()
     147{
     148  KeySetsContainer keysets;
     149  KeySetsContainer::IntVector vector1;
     150  vector1 += 1,-1;
     151  KeySetsContainer::IntVector vector2;
     152  vector2 += -1,1,2,-1;
     153  keysets.KeySets.push_back(vector1);
     154  keysets.KeySets.push_back(vector2);
     155  SV = new IndexSetContainer(keysets);
     156
     157  // check sets
     158  CPPUNIT_ASSERT_EQUAL( (size_t)2, SV->getContainer().size() );
     159  CPPUNIT_ASSERT_EQUAL( (size_t)1, SV->getContainer()[0]->size() );
     160  CPPUNIT_ASSERT_EQUAL( (size_t)2, SV->getContainer()[1]->size() );
     161
     162}
     163
     164/** Unit tests for countSetsTillLevel()
     165 *
     166 */
     167void IndexSetContainerTest::countSetsTillLevelTest()
     168{
     169  SV = new IndexSetContainer(allsets);
     170
     171  CPPUNIT_ASSERT_EQUAL( (size_t)0, SV->countSetsTillLevel(0) );
     172  CPPUNIT_ASSERT_EQUAL( (size_t)2, SV->countSetsTillLevel(1) );
     173  CPPUNIT_ASSERT_EQUAL( (size_t)4, SV->countSetsTillLevel(2) );
     174  CPPUNIT_ASSERT_EQUAL( (size_t)5, SV->countSetsTillLevel(3) );
     175  CPPUNIT_ASSERT_EQUAL( (size_t)6, SV->countSetsTillLevel(4) );
     176  CPPUNIT_ASSERT_EQUAL( (size_t)6, SV->countSetsTillLevel(5) );
     177}
  • src/Fragmentation/Summation/unittests/IndexSetContainerUnitTest.hpp

    rcebac0 r36bb2d  
    3030    CPPUNIT_TEST ( comparatorTest );
    3131    CPPUNIT_TEST ( insertTest );
     32    CPPUNIT_TEST ( KeySetContainerTest );
     33    CPPUNIT_TEST ( countSetsTillLevelTest );
    3234    CPPUNIT_TEST_SUITE_END();
    3335
     
    3840      void comparatorTest();
    3941      void insertTest();
     42      void KeySetContainerTest();
     43      void countSetsTillLevelTest();
    4044
    4145private:
  • src/Fragmentation/Summation/unittests/Makefile.am

    rcebac0 r36bb2d  
    88        ../Fragmentation/Summation/unittests/SetValueUnitTest.cpp \
    99        ../Fragmentation/Summation/unittests/SetValueMapUnitTest.cpp \
    10         ../Fragmentation/Summation/unittests/SubsetMapUnitTest.cpp
     10        ../Fragmentation/Summation/unittests/SubsetMapUnitTest.cpp \
     11        ../Fragmentation/Summation/unittests/SummationUnitTest.cpp
    1112
    1213FRAGMENTATIONSUMMATIONTESTSHEADERS = \
     
    1617        ../Fragmentation/Summation/unittests/SetValueUnitTest.hpp \
    1718        ../Fragmentation/Summation/unittests/SetValueMapUnitTest.hpp \
    18         ../Fragmentation/Summation/unittests/SubsetMapUnitTest.hpp
     19        ../Fragmentation/Summation/unittests/SubsetMapUnitTest.hpp \
     20        ../Fragmentation/Summation/unittests/SummationUnitTest.hpp
    1921
    2022FRAGMENTATIONSUMMATIONTESTS = \
     
    2426  SetValueUnitTest \
    2527  SetValueMapUnitTest \
    26   SubsetMapUnitTest
     28  SubsetMapUnitTest \
     29  SummationUnitTest
    2730
    2831TESTS += $(FRAGMENTATIONSUMMATIONTESTS)
     
    4447        ../Fragmentation/Summation/unittests/IndexSetContainerUnitTest.cpp \
    4548        ../Fragmentation/Summation/unittests/IndexSetContainerUnitTest.hpp
    46 IndexSetContainerUnitTest_LDADD = ${FRAGMENTATIONSUMMATIONLIBS}
     49IndexSetContainerUnitTest_LDADD = \
     50        ../libMolecuilderFragmentation.la \
     51        ../libMolecuilderHelpers.la \
     52        ${FRAGMENTATIONSUMMATIONLIBS}
    4753
    4854OrthogonalSummationUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \
    4955        ../Fragmentation/Summation/unittests/OrthogonalSummationUnitTest.cpp \
    50         ../Fragmentation/Summation/unittests/OrthogonalSummationUnitTest.hpp
     56        ../Fragmentation/Summation/unittests/OrthogonalSummationUnitTest.hpp \
     57        ../Fragmentation/Summation/OrthogonalSummation.hpp \
     58        ../Fragmentation/Summation/OrthogonalSummation_impl.hpp
    5159OrthogonalSummationUnitTest_LDADD = ${FRAGMENTATIONSUMMATIONLIBS}
    5260
     
    6876SubsetMapUnitTest_LDADD = ${FRAGMENTATIONSUMMATIONLIBS}
    6977
     78SummationUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \
     79        ../Fragmentation/Summation/unittests/SummationUnitTest.cpp \
     80        ../Fragmentation/Summation/unittests/SummationUnitTest.hpp \
     81        ../Fragmentation/Summation/Summation.hpp \
     82        ../Fragmentation/Summation/Summation_impl.hpp
     83SummationUnitTest_LDADD = ${FRAGMENTATIONSUMMATIONLIBS}
     84
    7085
    7186#AUTOMAKE_OPTIONS = parallel-tests
  • src/Fragmentation/Summation/unittests/OrthogonalSummationUnitTest.cpp

    rcebac0 r36bb2d  
    5959// Registers the fixture into the 'registry'
    6060CPPUNIT_TEST_SUITE_REGISTRATION( OrthogonalSummationTest );
    61 //
    62 //template <class T>
    63 //struct SetValueAllocator {
    64 //  SetValueAllocator(const T &_value) :
    65 //    value(_value)
    66 //  {}
    67 //  SetValue<T> * operator()(const IndexSet &set) {
    68 //    SetValue<T> * _instance = new SetValue<T>(set, value);
    69 //    return _instance;
    70 //  }
    71 //private:
    72 //  //!> internally stored fixed initial value
    73 //  const T value;
    74 //};
    7561
    7662void OrthogonalSummationTest::setUp()
     
    119105
    120106    // sum up, as full set is contained we must get value again
    121     CPPUNIT_ASSERT_EQUAL( value, OS() );
     107    //CPPUNIT_ASSERT_EQUAL( 0, OS(0) ); /* zero value is not guaranteed to bet set to zero. */
     108    CPPUNIT_ASSERT_EQUAL( value*2, OS(1) );
     109    CPPUNIT_ASSERT_EQUAL( value*2, OS(2) );
     110    CPPUNIT_ASSERT_EQUAL( value*2, OS(3) );
     111    CPPUNIT_ASSERT_EQUAL( value, OS(4) );
     112    CPPUNIT_ASSERT_EQUAL( value, OS(5) );
    122113  }
    123114}
  • src/Fragmentation/Summation/unittests/SubsetMapUnitTest.cpp

    rcebac0 r36bb2d  
    300300  }
    301301}
     302
     303/** UnitTest for getMaximumSubsetLevel()
     304 */
     305void SubsetMapTest::getMaximumSubsetLevelTest()
     306{
     307  // create small container
     308  {
     309    IndexSet tempset;
     310    std::vector<IndexSet> sets;
     311    sets.push_back(tempset);
     312    tempset += 1;
     313    sets.push_back(tempset);
     314    tempset += 2;
     315    sets.push_back(tempset);
     316    tempset.clear();
     317    tempset += 2;
     318    sets.push_back(tempset);
     319    IndexSetContainer container( sets );
     320    // now we have {}, {1}, {2}, {1,2} in container
     321
     322    SM = new SubsetMap(container);
     323    CPPUNIT_ASSERT( SM != NULL );
     324
     325    CPPUNIT_ASSERT_EQUAL( (size_t)1, SM->getMaximumSubsetLevel() );
     326    // we are strictly less than super set (last one)
     327    CPPUNIT_ASSERT( SM->getMaximumSubsetLevel() < (--SM->Lookup.end())->first->size() );
     328  }
     329
     330  // create larger container
     331  {
     332    IndexSetContainer container( allsets );
     333    delete SM;
     334    SM = new SubsetMap(container);
     335    CPPUNIT_ASSERT( SM != NULL );
     336
     337    CPPUNIT_ASSERT_EQUAL( (size_t)3, SM->getMaximumSubsetLevel() );
     338    CPPUNIT_ASSERT( SM->getMaximumSubsetLevel() < (--SM->Lookup.end())->first->size() );
     339  }
     340}
  • src/Fragmentation/Summation/unittests/SubsetMapUnitTest.hpp

    rcebac0 r36bb2d  
    3131    CPPUNIT_TEST ( getSubsetTest );
    3232    CPPUNIT_TEST ( gatherSubsetTest );
     33    CPPUNIT_TEST ( getMaximumSubsetLevelTest );
    3334    CPPUNIT_TEST_SUITE_END();
    3435
     
    4041      void getSubsetTest();
    4142      void gatherSubsetTest();
     43      void getMaximumSubsetLevelTest();
    4244
    4345private:
Note: See TracChangeset for help on using the changeset viewer.