source: src/FunctionApproximation/FunctionModel.hpp@ c5e75f3

Action_Thermostats Add_AtomRandomPerturbation Add_RotateAroundBondAction Add_SelectAtomByNameAction Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_StructOpt_integration_tests Automaking_mpqc_open AutomationFragmentation_failures 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_ChronosMutex 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_IntegrationTest 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 StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg ThirdParty_MPQC_rebuilt_buildsystem TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps Ubuntu_1604_changes stable
Last change on this file since c5e75f3 was e1fe7e, checked in by Frederik Heber <heber@…>, 11 years ago

FunctionModel now uses list_of_arguments to split sequence of subsets of distances.

  • this fixes ambiguities with the set of distances: Imagine the distances within a water molecule as OH (A) and HH (B). We then may have a sequence of argument_t as AABAAB. And with the current implementation of CompoundPotential::splitUpArgumentsByModels() we would always choose the latter (and more complex) model. Hence, we make two calls to TriplePotential_Angle, instead of calls twice to PairPotential_Harmonic for A, one to PairPotential_Harmonic for B, and once to TriplePotential_Angle for AAB.
  • now, we new list looks like A,A,B,AAB where each tuple of distances can be uniquely associated with a specific potential.
  • changed signatures of EmpiricalPotential::operator(), ::derivative(), ::parameter_derivative(). This involved changing all of the current specific potentials and CompoundPotential.
  • TrainingData must discern between the InputVector_t (just all distances) and the FilteredInputVector_t (tuples of subsets of distances).
  • FunctionApproximation now has list_of_arguments_t as parameter to evaluate() and evaluate_derivative().
  • DOCU: docu change in TrainingData.
  • Property mode set to 100644
File size: 6.3 KB
Line 
1/*
2 * FunctionModel.hpp
3 *
4 * Created on: 02.10.2012
5 * Author: heber
6 */
7
8#ifndef FUNCTIONMODEL_HPP_
9#define FUNCTIONMODEL_HPP_
10
11// include config.h
12#ifdef HAVE_CONFIG_H
13#include <config.h>
14#endif
15
16#include <boost/function.hpp>
17#include <list>
18#include <vector>
19
20#include "FunctionApproximation/FunctionArgument.hpp"
21
22class Fragment;
23class TrainingData;
24
25/** This class represents the interface for a given function to model a
26 * high-dimensional data set in FunctionApproximation.
27 *
28 * As the parameters may be stored differently, the interface functions for
29 * getting and setting them are as light-weight (and not speed-optimized)
30 * as possible.
31 *
32 * We always work in distances, i.e. pairs of atoms and the distance in between.
33 * As fragments do not contain these distances directly but the atomic positions
34 * (and charges) instead, we need to extract these from the fragment. For this
35 * purpose we need a bound function, termed an 'Extractor'. However, this is only
36 * required when one wants to use a FunctionModel directly on a given fragment.
37 * In FunctionApproximation we instead have TrainingData generate automatically
38 * a list of all pair-wise distances. The FunctionModel's Extractor may however
39 * create a more specific (and tighter) list of arguments, which however can
40 * then only be used with this specific FunctionModel.
41 *
42 * Furthermore, the underlying function to fit may require these distances, or
43 * arguments (termed so if paired with charges and atomic indices), to be in a
44 * certain order or does need only a subset. For this purpose we need another
45 * bound function, called a 'Filter'.
46 *
47 * As a fragment may contain multiple sets of arguments or distances that serve
48 * as valid function arguments, we need to split these sets up, such that they
49 * can be served one by one to the function. For this purpose we need a function
50 * that gives the number of arguments per set. (note that the Filter is supposed
51 * to place related arguments consecutively.
52 *
53 */
54class FunctionModel
55{
56public:
57 //!> typedef for a single parameter degree of freedom of the function
58 typedef double parameter_t;
59 //!> typedef for the whole set of parameters of the function
60 typedef std::vector<parameter_t> parameters_t;
61 //!> typedef for the argument vector as input to the function (subset of distances)
62 typedef std::vector<argument_t> arguments_t;
63 //!> typedef for a list of argument vectors as input to the function (list of subsets)
64 typedef std::list<arguments_t> list_of_arguments_t;
65 //!> typedef for a single result degree of freedom
66 typedef double result_t;
67 //!> typedef for the result vector as returned by the function
68 typedef std::vector<result_t> results_t;
69 //!> typedef for a function containing how to extract required information from a Fragment.
70 typedef boost::function< list_of_arguments_t (const Fragment &, const size_t)> extractor_t;
71 //!> typedef for a function containing how to filter required distances from a full argument list.
72 typedef boost::function< list_of_arguments_t (const arguments_t &)> filter_t;
73 //!> typedef for the magic triple function that gets the other two distances for a given argument
74 typedef boost::function< std::vector<arguments_t>(const argument_t &, const double)> triplefunction_t;
75
76public:
77 FunctionModel() {}
78 virtual ~FunctionModel() {}
79
80 /** Setter for the parameters of the model function.
81 *
82 * \param params set of parameters to set
83 */
84 virtual void setParameters(const parameters_t &params)=0;
85
86 /** Getter for the parameters of this model function.
87 *
88 * \return current set of parameters of the model function
89 */
90 virtual parameters_t getParameters() const=0;
91
92 /** Sets the parameter randomly within the sensible range of each parameter.
93 *
94 * \param data container with training data for guesstimating range
95 */
96 virtual void setParametersToRandomInitialValues(const TrainingData &data)=0;
97
98 /** Getter for the number of parameters of this model function.
99 *
100 * \return number of parameters
101 */
102 virtual size_t getParameterDimension() const=0;
103
104 /** Sets the magic triple function that we use for getting angle distances.
105 *
106 * @param _triplefunction function that returns a list of triples (i.e. the
107 * two remaining distances) to a given pair of points (contained as
108 * indices within the argument)
109 */
110 virtual void setTriplefunction(triplefunction_t &_triplefunction)
111 {}
112
113 /** Evaluates the function with the given \a arguments and the current set of
114 * parameters.
115 *
116 * \param arguments set of arguments as input variables to the function
117 * \return result of the function
118 */
119 virtual results_t operator()(const list_of_arguments_t &arguments) const=0;
120
121 /** Evaluates the derivative of the function with the given \a arguments
122 * with respect to a specific parameter indicated by \a index.
123 *
124 * \param arguments set of arguments as input variables to the function
125 * \param index derivative of which parameter
126 * \return result vector containing the derivative with respect to the given
127 * input
128 */
129 virtual results_t parameter_derivative(const list_of_arguments_t &arguments, const size_t index) const=0;
130
131 /** States whether lower and upper boundaries should be used to constraint
132 * the parameter search for this function model.
133 *
134 * \return true - constraints should be used, false - else
135 */
136 virtual bool isBoxConstraint() const=0;
137
138 /** Returns a vector which are the lower boundaries for each parameter_t
139 * of this FunctionModel.
140 *
141 * \return vector of parameter_t resembling lowest allowed values
142 */
143 virtual parameters_t getLowerBoxConstraints() const=0;
144
145 /** Returns a vector which are the upper boundaries for each parameter_t
146 * of this FunctionModel.
147 *
148 * \return vector of parameter_t resembling highest allowed values
149 */
150 virtual parameters_t getUpperBoxConstraints() const=0;
151
152 /** Returns a bound function to be used with TrainingData, extracting distances
153 * from a Fragment.
154 *
155 * \return bound function extracting distances from a fragment
156 */
157 virtual filter_t getSpecificFilter() const=0;
158
159 /** Returns the number of arguments the underlying function requires.
160 *
161 * \return number of arguments of the function
162 */
163 virtual size_t getSpecificArgumentCount() const=0;
164};
165
166#endif /* FUNCTIONMODEL_HPP_ */
Note: See TracBrowser for help on using the repository browser.