source: src/FunctionApproximation/FunctionModel.hpp@ 4464ef

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_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_levmar Subpackage_vmg ThirdParty_MPQC_rebuilt_buildsystem TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps Ubuntu_1604_changes stable
Last change on this file since 4464ef was e60558, checked in by Frederik Heber <heber@…>, 8 years ago

Extractors require additionally the binding graph of the fragment itself.

  • this is used in ::filterArguments..(), ::reorderArguments(), and CompountPotential::splitUpArgumentsByModelsFilter().
  • 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 HomologyGraph;
24class TrainingData;
25
26/** This class represents the interface for a given function to model a
27 * high-dimensional data set in FunctionApproximation.
28 *
29 * As the parameters may be stored differently, the interface functions for
30 * getting and setting them are as light-weight (and not speed-optimized)
31 * as possible.
32 *
33 * We always work in distances, i.e. pairs of atoms and the distance in between.
34 * As fragments do not contain these distances directly but the atomic positions
35 * (and charges) instead, we need to extract these from the fragment. For this
36 * purpose we need a bound function, termed an 'Extractor'. However, this is only
37 * required when one wants to use a FunctionModel directly on a given fragment.
38 * In FunctionApproximation we instead have TrainingData generate automatically
39 * a list of all pair-wise distances. The FunctionModel's Extractor may however
40 * create a more specific (and tighter) list of arguments, which however can
41 * then only be used with this specific FunctionModel.
42 *
43 * Furthermore, the underlying function to fit may require these distances, or
44 * arguments (termed so if paired with charges and atomic indices), to be in a
45 * certain order or does need only a subset. For this purpose we need another
46 * bound function, called a 'Filter'.
47 *
48 * As a fragment may contain multiple sets of arguments or distances that serve
49 * as valid function arguments, we need to split these sets up, such that they
50 * can be served one by one to the function. For this purpose we need a function
51 * that gives the number of arguments per set. (note that the Filter is supposed
52 * to place related arguments consecutively.
53 *
54 */
55class FunctionModel
56{
57public:
58 //!> typedef for a single parameter degree of freedom of the function
59 typedef double parameter_t;
60 //!> typedef for the whole set of parameters of the function
61 typedef std::vector<parameter_t> parameters_t;
62 //!> typedef for the argument vector as input to the function (subset of distances)
63 typedef std::vector<argument_t> arguments_t;
64 //!> typedef for a list of argument vectors as input to the function (list of subsets)
65 typedef std::list<arguments_t> list_of_arguments_t;
66 //!> typedef for a single result degree of freedom
67 typedef double result_t;
68 //!> typedef for the result vector as returned by the function
69 typedef std::vector<result_t> results_t;
70 //!> typedef for a function containing how to extract required information from a Fragment.
71 typedef boost::function< list_of_arguments_t (const Fragment &, const size_t)> extractor_t;
72 //!> typedef for a function containing how to filter required distances from a full argument list.
73 typedef boost::function< list_of_arguments_t (const HomologyGraph &, const arguments_t &)> filter_t;
74 //!> typedef for the magic triple function that gets the other two distances for a given argument
75 typedef boost::function< std::vector<arguments_t>(const argument_t &, const double)> triplefunction_t;
76
77public:
78 FunctionModel() {}
79 virtual ~FunctionModel() {}
80
81 /** Setter for the parameters of the model function.
82 *
83 * \param params set of parameters to set
84 */
85 virtual void setParameters(const parameters_t &params)=0;
86
87 /** Getter for the parameters of this model function.
88 *
89 * \return current set of parameters of the model function
90 */
91 virtual parameters_t getParameters() const=0;
92
93 /** Sets the parameter randomly within the sensible range of each parameter.
94 *
95 * \param data container with training data for guesstimating range
96 */
97 virtual void setParametersToRandomInitialValues(const TrainingData &data)=0;
98
99 /** Getter for the number of parameters of this model function.
100 *
101 * \return number of parameters
102 */
103 virtual size_t getParameterDimension() const=0;
104
105 /** Sets the magic triple function that we use for getting angle distances.
106 *
107 * @param _triplefunction function that returns a list of triples (i.e. the
108 * two remaining distances) to a given pair of points (contained as
109 * indices within the argument)
110 */
111 virtual void setTriplefunction(triplefunction_t &_triplefunction)
112 {}
113
114 /** Evaluates the function with the given \a arguments and the current set of
115 * parameters.
116 *
117 * \param arguments set of arguments as input variables to the function
118 * \return result of the function
119 */
120 virtual results_t operator()(const list_of_arguments_t &arguments) const=0;
121
122 /** Evaluates the derivative of the function with the given \a arguments
123 * with respect to a specific parameter indicated by \a index.
124 *
125 * \param arguments set of arguments as input variables to the function
126 * \param index derivative of which parameter
127 * \return result vector containing the derivative with respect to the given
128 * input
129 */
130 virtual results_t parameter_derivative(const list_of_arguments_t &arguments, const size_t index) const=0;
131
132 /** States whether lower and upper boundaries should be used to constraint
133 * the parameter search for this function model.
134 *
135 * \return true - constraints should be used, false - else
136 */
137 virtual bool isBoxConstraint() const=0;
138
139 /** Returns a vector which are the lower boundaries for each parameter_t
140 * of this FunctionModel.
141 *
142 * \return vector of parameter_t resembling lowest allowed values
143 */
144 virtual parameters_t getLowerBoxConstraints() const=0;
145
146 /** Returns a vector which are the upper boundaries for each parameter_t
147 * of this FunctionModel.
148 *
149 * \return vector of parameter_t resembling highest allowed values
150 */
151 virtual parameters_t getUpperBoxConstraints() const=0;
152
153 /** Returns a bound function to be used with TrainingData, extracting distances
154 * from a Fragment.
155 *
156 * \return bound function extracting distances from a fragment
157 */
158 virtual filter_t getSpecificFilter() const=0;
159
160 /** Returns the number of arguments the underlying function requires.
161 *
162 * \return number of arguments of the function
163 */
164 virtual size_t getSpecificArgumentCount() const=0;
165};
166
167#endif /* FUNCTIONMODEL_HPP_ */
Note: See TracBrowser for help on using the repository browser.