Ignore:
Timestamp:
Feb 27, 2013, 12:39:03 PM (12 years ago)
Author:
Frederik Heber <heber@…>
Branches:
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
Children:
df350c
Parents:
dbf8c8
git-author:
Frederik Heber <heber@…> (12/06/12 10:35:37)
git-committer:
Frederik Heber <heber@…> (02/27/13 12:39:03)
Message:

Added gatherAllDistancesFromFragment() to Extractors.

  • gatherDistancesFromFragment() did only get the first matching distance, but e.g. for SaturationPotential we need to get all from (8,1,1) for types (8,1).
  • this involved three helper functions initially similar in spirit, but we get all combinations via a simple recursion with pickLastElementAsTarget().
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/FunctionApproximation/Extractors.hpp

    rdbf8c8 rcaa00e9  
    1414#endif
    1515
     16#include <boost/function.hpp>
     17
    1618#include "Fragmentation/SetValues/Fragment.hpp"
    1719#include "FunctionApproximation/FunctionModel.hpp"
     
    3032  typedef std::map< element_t, count_t> elementcounts_t;
    3133  typedef std::map< element_t, chargeiters_t > elementtargets_t;
     34  typedef std::vector< chargeiters_t > targets_per_combination_t;
    3235
    3336  /** Namespace for some internal helper functions.
     
    117120        const Fragment::charges_t& charges,
    118121        const Fragment::charges_t elements
     122        );
     123
     124    /** Brings all charges together in a map.
     125     *
     126     * @param charges charges as possible keys and their iterators as values in the map
     127     * @param elements list of charges to pick as keys
     128     * @return map of key and a vector of charge iterators
     129     */
     130    elementtargets_t convertChargesToTargetMap(
     131        const Fragment::charges_t& charges,
     132        Fragment::charges_t elements
     133        );
     134
     135    /** Brings combinatorially together desired list of \a charges and \a targets.
     136     *
     137     * @param charges list of desired charges
     138     * @param elementtargets map of available targets per element
     139     * @return vector of chargeiters with all unique combinations
     140     */
     141    targets_per_combination_t
     142    CombineChargesAndTargets(
     143        const Fragment::charges_t& charges,
     144        const elementtargets_t& elementtargets
     145        );
     146
     147    /** Recursive function to pick the next target.
     148     *
     149     * This is used by \sa CombineChargesAndTargets()
     150     *
     151     * @param charges set of charges, reduced by one per recursion
     152     * @param elementtargets targets, map of targets to pick from
     153     * @param currenttargets current set of targets, "global" through recursion
     154     * @param addFunction bound function to add a set when complete
     155     */
     156    void pickLastElementAsTarget(
     157        Fragment::charges_t elements,
     158        elementtargets_t elementtargets,
     159        chargeiters_t& currenttargets,
     160        boost::function<void (const chargeiters_t &currenttargets)> &addFunction
     161        );
     162
     163    /** Converts a list of chargeiters to a list of respective arguments.
     164     *
     165     * @param positions positions from fragment
     166     * @param charges charges associated to each element in \a positions
     167     * @param combinations vector of chargeiters
     168     * \param globalid refers to the index within the global set of configurations
     169     * @return list of arguments
     170     */
     171    FunctionModel::arguments_t
     172    convertTargetsToArguments(
     173        const Fragment::positions_t& positions,
     174        const Fragment::charges_t& charges,
     175        const targets_per_combination_t combinations,
     176        const size_t globalid
    119177        );
    120178  }
     
    199257   * \param charges all nuclei charges
    200258   * \param elements tuple of desired elements
     259   * \param globalid refers to the index within the global set of configurations
    201260   * \return vector of arguments_t containing those matched with elements
    202261   */
     
    208267      );
    209268
     269  /** Gather all combinations of charges as distance arguments from the fragment.
     270   *
     271   * E.g. we have a water fragment, i.e. (8,1,1) and we we want elements (8,1),
     272   * then two arguments are returned, first to second and first to third.
     273   *
     274   * With \sa gatherDistancesFromFragment() only the first distance would be
     275   * returned.
     276   *
     277   * @param positions positions in fragment
     278   * @param charges charges in fragment
     279   * @param elements list of desired elements
     280   * @param globalid some global id to discern training data tuples
     281   * @return list of arguments with distances
     282   */
     283  FunctionModel::arguments_t gatherAllDistancesFromFragment(
     284      const Fragment::positions_t& positions,
     285      const Fragment::charges_t& charges,
     286      const Fragment::charges_t elements,
     287      const size_t globalid
     288      );
     289
    210290  /** Reorder arguments by increasing distance.
    211291   *
Note: See TracChangeset for help on using the changeset viewer.