/* * Extractors.hpp * * Created on: 15.10.2012 * Author: heber */ #ifndef TRAININGDATA_EXTRACTORS_HPP_ #define TRAININGDATA_EXTRACTORS_HPP_ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include #include "Fragmentation/EdgesPerFragment.hpp" #include "Fragmentation/Summation/SetValues/Fragment.hpp" #include "FunctionApproximation/FunctionModel.hpp" class BindingModel; class Fragment; class HomologyGraph; /** Namespace containing all simple extractor functions. * * Extractor functions extract distances from a given fragment matching with * a given set of particle types (i.e. elements, e.h. H2O). * Filter functions extract a subset of distances from a given set of distances * to be used with a specific model. * * To this end, each FunctionModel has both a filter and an extractor function. * * The functions in this namespace act as helpers or basic building blocks in * constructing such filters and extractors. * */ namespace Extractors { typedef Fragment::charges_t::const_iterator chargeiter_t; typedef std::vector chargeiters_t; typedef size_t count_t; typedef Fragment::atomicNumber_t element_t; typedef std::map< element_t, count_t> elementcounts_t; typedef std::map< element_t, chargeiters_t > elementtargets_t; typedef std::vector< chargeiters_t > targets_per_combination_t; //!> typedef for particle designation typedef unsigned int ParticleType_t; //!> typedef for a vector of particle designations typedef std::vector ParticleTypes_t; /** Namespace for some internal helper functions. * */ namespace _detail { /** Counts all same elements in the vector and places into map of elements. * * \param elements vector of elements * \return count of same element in vector */ elementcounts_t getElementCounts( const Fragment::atomicnumbers_t elements ); } /** Gather all distances from a given set of positions. * * Here, we only return one of the two equal distances. * * \param positions all nuclei positions * \param atomicNumber all nuclei atomic numbers * \param edges edges of the fragment's bond graph * \param globalid index to associated in argument_t with * \return vector of argument_ , each with a distance */ FunctionModel::arguments_t gatherAllSymmetricDistanceArguments( const Fragment::positions_t& positions, const Fragment::atomicnumbers_t& atomicnumbers, const FragmentationEdges::edges_t &edges, const size_t globalid); /** Simple extractor of all unique pair distances of a given \a fragment, where * the first index is less than the second one. * * \param positions all nuclei positions * \param atomicNumber all nuclei atomic numbers * \param edges edges of the fragment's bond graph * \param index index refers to the index within the global set of configurations * \return vector of of argument_t containing all found distances */ inline FunctionModel::arguments_t gatherAllSymmetricDistances( const Fragment::positions_t& positions, const Fragment::atomicnumbers_t& atomicnumbers, const FragmentationEdges::edges_t &edges, const size_t index ) { // get distance out of Fragment return gatherAllSymmetricDistanceArguments(positions, atomicnumbers, edges, index); } /** Filter the arguments to select only these required by the model. * * \warning this is meant as a faster way of getting the arguments for simple * pair potentials. In any other case, one should use filterArgumentsByBindingModel() * * \param listargs list of arguments to reorder each * \param _graph contains binding model of graph * \param _types particle type vector * \return reordered args */ FunctionModel::list_of_arguments_t filterArgumentsByParticleTypes( const FunctionModel::arguments_t &args, const HomologyGraph &_graph, const ParticleTypes_t &_types, const BindingModel &_bindingmodel ); /** Filter and reorder the arguments to bring adjacent ones together. * * We need to find all matching subgraphs (given by \a _bindingmodel) in the * given homology graph (given by \a _graph) of the fragment molecule. * This means filtering down to the desired particle types and then find * all possible matching subgraphs in each of argument lists, \a eachargs. * * \param listargs list of arguments to filter and order appropriately * \param _graph contains binding model of graph * \param _types particle type vector * \return reordered args */ FunctionModel::list_of_arguments_t filterArgumentsByBindingModel( const FunctionModel::arguments_t &args, const HomologyGraph &_graph, const ParticleTypes_t &_types, const BindingModel &_bindingmodel ); /** Combines two argument lists by sorting and making unique. * * @param firstargs first list of arguments * @param secondargs second list of arguments * @return concatenated lists */ FunctionModel::arguments_t combineArguments( const FunctionModel::arguments_t &firstargs, const FunctionModel::arguments_t &secondargs); /** Combines two argument lists by concatenation. * * @param firstargs first list of arguments * @param secondargs second list of arguments * @return concatenated lists */ FunctionModel::arguments_t concatenateArguments( const FunctionModel::arguments_t &firstargs, const FunctionModel::arguments_t &secondargs); /** Combines two argument lists by concatenation. * * @param firstlistargs first list of argument tuples * @param secondlistargs second list of argument tuples * @return concatenated lists */ FunctionModel::list_of_arguments_t concatenateListOfArguments( const FunctionModel::list_of_arguments_t &firstlistargs, const FunctionModel::list_of_arguments_t &secondlistargs); }; /* namespace Extractors */ #endif /* TRAININGDATA_EXTRACTORS_HPP_ */