source: src/Fragmentation/Exporters/SaturationDistanceMaximizer.hpp@ 0983e6

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_StructOpt_integration_tests Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator 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_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion GeometryObjects Gui_displays_atomic_force_velocity IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps Ubuntu_1604_changes stable
Last change on this file since 0983e6 was 2a6d8c, checked in by Frederik Heber <heber@…>, 10 years ago

DOCUFIX: Doyxygen formula was broken in SaturationDistanceMaximizer.

  • Property mode set to 100644
File size: 3.7 KB
Line 
1/*
2 * SaturationDistanceMaximizer.hpp
3 *
4 * Created on: Jul 27, 2014
5 * Author: heber
6 */
7
8#ifndef SATURATIONDISTANCEMAXIMIZER_HPP_
9#define SATURATIONDISTANCEMAXIMIZER_HPP_
10
11// include config.h
12#ifdef HAVE_CONFIG_H
13#include <config.h>
14#endif
15
16#include <vector>
17
18#include <gsl/gsl_vector.h>
19
20#include "SaturatedBond.hpp"
21
22class SaturationDistanceMaximizerTest;
23
24/** This class encapsulates the minimizing/maximization performed to find the
25 * best angles alpha for a vector of SaturatedBonds.
26 */
27class SaturationDistanceMaximizer
28{
29public:
30 struct Advocate;
31
32 //!> typedef for a vector of SaturatedBonds
33 typedef std::vector<SaturatedBond::ptr> PositionContainers_t;
34 //!> typedef for the positions per saturated bond
35 typedef std::vector< SaturatedBond::positions_t > position_bins_t;
36
37 SaturationDistanceMaximizer(PositionContainers_t &_PositionContainers) :
38 PositionContainers(_PositionContainers)
39 {}
40 ~SaturationDistanceMaximizer() {}
41
42 /** Maximizes the distances between the saturation hydrogens for a number of
43 * SaturedBonds.
44 *
45 * We maximize the function \f$ \sum_{i<j} \frac{1}{ || x_i - x_j ||^2} \f$.
46 */
47 void operator()();
48
49 /** Requests positions from each SaturatedBond and places it into vector.
50 *
51 * \return vector of tuples of positions
52 */
53 position_bins_t getAllPositionBins() const;
54
55private:
56 //!> make advocate friend
57 friend struct Advocate;
58 //!> make unit tests friend
59 friend class SaturationDistanceMaximizerTest;
60
61 /** Evaluates the penalty function over the current positions.
62 *
63 * \return \f$ \sum_{i<j} \frac{1}{ || x_i - x_j ||^2} \f$
64 */
65 double calculatePenality() const;
66
67 /** Evaluates the gradient with respect to the angles (i.e. per bin only!)
68 *
69 * \return tuple with amount of change per bin
70 */
71 std::vector<double> calculatePenalityGradient() const;
72
73 /** Getter for the alphas of each SaturatedBond.
74 *
75 * \return vector with all alphas
76 */
77 std::vector<double> getAlphas() const;
78
79 /** Helper function to set the angles alpha of each SaturatedBond from the
80 * components of a gsl_vector \a *x.
81 *
82 * \param x components containing alpha per bond
83 */
84 void setAlphas(const gsl_vector *x);
85
86 /** Getter for the advocate to be handed over to other functions or classes.
87 *
88 * \return ptr to advocate
89 */
90 Advocate* getAdvocate();
91
92public:
93 /** This class is friend and may call penalty functions.
94 *
95 * This class is private and only SaturationDistanceMaximizer is its friend.
96 * Hence, it has total control of who may call its function by instantiating
97 * this advocate object abd handing it to someone else (e.g. a function).
98 *
99 */
100 class Advocate
101 {
102 private:
103 friend class SaturationDistanceMaximizer;
104
105 Advocate(
106 SaturationDistanceMaximizer &_maximizer) :
107 maximizer(_maximizer)
108 {}
109
110 public:
111 double calculatePenality() const
112 {
113 return maximizer.calculatePenality();
114 }
115
116 /** Evaluates the gradient with respect to the angles (i.e. per bin only!)
117 *
118 * \return tuple with amount of change per bin
119 */
120 std::vector<double> calculatePenalityGradient() const
121 {
122 return maximizer.calculatePenalityGradient();
123 }
124
125 /** Helper function to set the angles alpha of each SaturatedBond from the
126 * components of a gsl_vector \a *x.
127 *
128 * \param x components containing alpha per bond
129 */
130 void setAlphas(const gsl_vector *x)
131 {
132 maximizer.setAlphas(x);
133 }
134
135 private:
136 //!> internal instance for functionc alls
137 SaturationDistanceMaximizer &maximizer;
138 };
139
140private:
141 //!> Vectors with all SaturatedBonds belonging to the central atom to saturate
142 PositionContainers_t &PositionContainers;
143};
144
145
146
147#endif /* SATURATIONDISTANCEMAXIMIZER_HPP_ */
Note: See TracBrowser for help on using the repository browser.