source: src/Fragmentation/Summation/OrthogonalFullSummator.hpp@ c9f9bb

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
Last change on this file since c9f9bb was c9f9bb, checked in by Frederik Heber <heber@…>, 12 years ago

Combining FragmentResult's id and ...Data in FragmentationAutomationAction's helpers.

  • all ...Data are always placed into map, hence associated to fragment job id.
  • necessitated changes to all ..Summators, ..SumUpPerLevel, and DataConverter.
  • Property mode set to 100644
File size: 4.6 KB
Line 
1/*
2 * OrthogonalFullSummator.hpp
3 *
4 * Created on: 08.09.2012
5 * Author: heber
6 */
7
8#ifndef ORTHOGONALFULLSUMMATOR_HPP_
9#define ORTHOGONALFULLSUMMATOR_HPP_
10
11// include config.h
12#ifdef HAVE_CONFIG_H
13#include <config.h>
14#endif
15
16#include <boost/fusion/sequence.hpp>
17
18#include "Fragmentation/Summation/OrthogonalSummation.hpp"
19#include "Fragmentation/Summation/SetValue.hpp"
20#include "Jobs/MPQCDataMap.hpp"
21
22/** OrthogonalFullSummator is a general class for making us of OrthogonalSummation.
23 *
24 *
25 * This class is very similar to OrthogonalSummation only that we specifically include
26 * the full set (with a value!) as well. Also there is a function to obtain the
27 * contribution. This is intended to check a full calculation against the truncated
28 * sum.
29 */
30template <typename MapType, typename MapKey>
31struct OrthogonalFullSummator {
32 /** We retrieve the type of the MPQCData member variable from the
33 * boost::fusion::map and stored it in this typedef. Note that for
34 * internal types (e.g. MapValue::const_iterator we need to place
35 * \b typename before).
36 */
37 typedef typename boost::fusion::result_of::value_at_key<MapType, MapKey>::type MapValue;
38
39 /** Constructor for class OrthogonalFullSummator.
40 *
41 * \param _subsetmap map with hierarchy of IndexSet's
42 * \param _data MPQCData converted to MPQCDataMap_t type, associated to job id
43 * \param _container container of IndexSet's such that each set has correct order
44 * to job id and hence to _data.
45 * \param _MatrixNrLookup lookup from job id to ordering in above vectors
46 */
47 OrthogonalFullSummator(
48 SubsetMap::ptr &_subsetmap,
49 const std::map<JobId_t, MapType> &_data,
50 const IndexSetContainer::Container_t &_container,
51 std::map< JobId_t, size_t > &_MatrixNrLookup) : /* cannot make this const due to operator[] */
52 indices(getSubsets(_container)),
53 values(createValues(_data, _container, _MatrixNrLookup)),
54 OS(indices, values, _subsetmap)
55 {
56 ASSERT( _data.size() == _container.size(),
57 "OrthogonalFullSummator() - data and indices don't have same size.");
58 ASSERT( _data.size() == _MatrixNrLookup.size(),
59 "OrthogonalFullSummator() - ids and MatrixNrLookup don't have same size.");
60 }
61
62 /** Summation operator.
63 *
64 * Initialises instantiated OrthogonalSummation of the respective type via
65 * \a OrthogonalFullSummator::data, uses OrthogonalSummation::operator() to sum and returns
66 * the result.
67 *
68 * \param level up to which level to sum up
69 * \return result of OrthogonalSummation for given type from MPQCDataMap_t.
70 */
71 MapValue operator()(const size_t level)
72 {
73 // evaluate
74 const MapValue result = OS(level);
75 return result;
76 }
77
78 /** Getter for the remaining contribution of the full set.
79 *
80 * @return contribution of allindices
81 */
82 MapValue getFullContribution() const {
83 typename SetValueMap<MapValue>::const_iterator iter = --OS.getSetValues().end();
84 return iter->second->getContribution();
85 }
86
87private:
88 /** Tiny helper to create the indices from a given IndexSetContainer.
89 *
90 * @param container container with IndexSet
91 * @return all subsets contained in \a container
92 */
93 typename OrthogonalSummation<MapValue>::InputSets_t getSubsets(
94 const IndexSetContainer::Container_t &container)
95 {
96 typename OrthogonalSummation<MapValue>::InputSets_t indices(
97 container.begin(),
98 container.end());
99 return indices;
100 }
101
102 /** Tiny helper to create the values for the summation in the correct order.
103 *
104 * @param data
105 * @param container
106 * @param MatrixNrLookup
107 * @return
108 */
109 typename OrthogonalSummation<MapValue>::InputValues_t createValues(
110 const std::map<JobId_t, MapType> &data,
111 const IndexSetContainer::Container_t &container,
112 std::map< JobId_t, size_t > &MatrixNrLookup)
113 {
114 typename OrthogonalSummation<MapValue>::InputValues_t values(container.size());
115 for (typename std::map<JobId_t, MapType>::const_iterator dataiter = data.begin();
116 dataiter != data.end(); ++dataiter) {
117 const MapType &Data = dataiter->second;
118 const JobId_t &jobid = dataiter->first;
119 const MapValue &value = boost::fusion::at_key<MapKey>(Data);
120 values[ MatrixNrLookup[jobid] ] = value;
121 }
122 return values;
123 }
124private:
125 //!> created indices for OS such that we may hand over refs
126 typename OrthogonalSummation<MapValue>::InputSets_t indices;
127 //!> created values for OS such that we may hand over refs
128 typename OrthogonalSummation<MapValue>::InputValues_t values;
129 //!> Summation instance to use in operator()(level)
130 OrthogonalSummation<MapValue> OS;
131};
132
133
134#endif /* ORTHOGONALFULLSUMMATOR_HPP_ */
Note: See TracBrowser for help on using the repository browser.