Changeset bf1d1b for src


Ignore:
Timestamp:
Aug 9, 2013, 2:20:36 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:
e355b31
Parents:
ff09f3
git-author:
Frederik Heber <heber@…> (07/04/13 08:49:28)
git-committer:
Frederik Heber <heber@…> (08/09/13 14:20:36)
Message:

HomologyContainer now stores full struct as value to HomologyGraph key.

  • this structure does not only contain fragment and energy but also the sampled charge and potential distribution.
  • added version handling to HomologyContainer::value_t serialization.
  • added option "store-grids" to AnalyseFragmentationResultsAction.
  • TESTFIX: adapted HomologyContainerUnitTest such that new values are correctly constructed.
Location:
src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/FragmentationAction/AnalyseFragmentationResultsAction.cpp

    rff09f3 rbf1d1b  
    222222void appendToHomologies(
    223223    const FragmentationShortRangeResults &shortrangeresults,
    224     const FragmentationLongRangeResults &longrangeresults
     224    const FragmentationLongRangeResults &longrangeresults,
     225    const bool storeGrids
    225226    )
    226227{
     
    246247    LOG(2, "DEBUG: Created graph " << graph << ".");
    247248    const IndexSet::ptr &index = *iter;
     249
     250    /// we fill the value structure
    248251    HomologyContainer::value_t value;
    249 
    250     // obtain fragment as key
     252    value.containsGrids = storeGrids;
     253    // obtain fragment
    251254    std::map<IndexSet::ptr, std::pair< MPQCDataFragmentMap_t, MPQCDataFragmentMap_t> >::const_iterator fragmentiter
    252255        = longrangeresults.Result_perIndexSet_Fragment.find(index);
     
    254257        "appendToHomologyFile() - cannot find index "+toString(*index)
    255258        +" in FragmentResults.");
    256     value.first = boost::fusion::at_key<MPQCDataFused::fragment>(fragmentiter->second.first);
    257 
    258     // obtain energy as value
     259    value.fragment = boost::fusion::at_key<MPQCDataFused::fragment>(fragmentiter->second.first);
     260
     261    // obtain energy
    259262    std::map<IndexSet::ptr, std::pair< MPQCDataEnergyMap_t, MPQCDataEnergyMap_t> >::const_iterator energyiter
    260263        = shortrangeresults.Result_perIndexSet_Energy.find(index);
     
    262265        "appendToHomologyFile() - cannot find index "+toString(*index)
    263266        +" in FragmentResults.");
    264     // value.second = boost::fusion::at_key<MPQCDataFused::energy_total>(energyiter->second.first); // values
    265     value.second = boost::fusion::at_key<MPQCDataFused::energy_total>(energyiter->second.second); // contributions
     267    value.energy = boost::fusion::at_key<MPQCDataFused::energy_total>(energyiter->second.second); // contributions
     268
     269    // only store sampled grids if desired
     270    if (storeGrids) {
     271      // obtain charge distribution
     272      std::map<IndexSet::ptr, std::pair< MPQCDataGridMap_t, MPQCDataGridMap_t> >::const_iterator chargeiter
     273          = longrangeresults.Result_perIndexSet_Grid.find(index);
     274      ASSERT( chargeiter != longrangeresults.Result_perIndexSet_Grid.end(),
     275          "appendToHomologyFile() - cannot find index "+toString(*index)
     276          +" in FragmentResults.");
     277      value.charge_distribution = boost::fusion::at_key<MPQCDataFused::sampled_grid>(chargeiter->second.second); // contributions
     278
     279      // obtain potential distribution
     280      std::map<IndexSet::ptr, std::pair< VMGDataMap_t, VMGDataMap_t> >::const_iterator potentialiter
     281          = longrangeresults.Result_perIndexSet_LongRange.find(index);
     282      ASSERT( potentialiter != longrangeresults.Result_perIndexSet_LongRange.end(),
     283          "appendToHomologyFile() - cannot find index "+toString(*index)
     284          +" in FragmentResults.");
     285      value.potential_distribution = boost::fusion::at_key<VMGDataFused::sampled_potential>(potentialiter->second.second); // contributions
     286    }
    266287    values.insert( std::make_pair( graph, value) );
    267288  }
     
    282303    for (HomologyContainer::container_t::const_iterator iter =
    283304        homology_container.begin(); iter != homology_container.end(); ++iter) {
    284       LOG(2, "DEBUG: graph " << iter->first << " has Fragment "
    285           << iter->second.first << " and associated energy " << iter->second.second << ".");
     305      LOG(2, "DEBUG: graph " << iter->first
     306          << " has Fragment " << iter->second.fragment
     307          << ", associated energy " << iter->second.energy
     308          << ", and sampled grid integral " << iter->second.charge_distribution.integral()
     309          << ".");
    286310    }
    287311  }
     
    383407
    384408    // append all keysets to homology file
    385     appendToHomologies(shortrangeresults, longrangeresults);
     409    appendToHomologies(shortrangeresults, longrangeresults, params.DoStoreGrids.get());
    386410  }
    387411#else
  • src/Actions/FragmentationAction/AnalyseFragmentationResultsAction.def

    rff09f3 rbf1d1b  
    1414// ValueStorage by the token "Z" -> first column: int, Z, "Z"
    1515// "undefine" if no parameters are required, use (NOPARAM_DEFAULT) for each (undefined) default value
    16 #define paramtypes (boost::filesystem::path)
    17 #define paramtokens ("fragment-resultfile")
    18 #define paramdescriptions ("parse fragment results from the given file")
    19 #define paramdefaults (PARAM_DEFAULT(""))
    20 #define paramreferences (resultsfile)
     16#define paramtypes (boost::filesystem::path)(bool)
     17#define paramtokens ("fragment-resultfile")("store-grids")
     18#define paramdescriptions ("parse fragment results from the given file")("whether to store sampled grids in homology files")
     19#define paramdefaults (PARAM_DEFAULT(""))(PARAM_DEFAULT("0"))
     20#define paramreferences (resultsfile)(DoStoreGrids)
    2121#define paramvalids \
    22 (DummyValidator< boost::filesystem::path >())
     22(DummyValidator< boost::filesystem::path >()) \
     23(DummyValidator< bool >())
    2324
    2425#undef statetypes
  • src/Actions/FragmentationAction/FitPotentialAction.cpp

    rff09f3 rbf1d1b  
    191191  for (HomologyContainer::container_t::const_iterator iter =
    192192      homologies.begin(); iter != homologies.end(); ++iter) {
    193     LOG(1, "INFO: graph " << iter->first << " has Fragment " << iter->second.first
    194         << " and associated energy " << iter->second.second << ".");
     193    LOG(1, "INFO: graph " << iter->first
     194        << " has Fragment " << iter->second.fragment
     195        << ", associated energy " << iter->second.energy
     196        << ", and sampled grid integral " << iter->second.charge_distribution.integral()
     197        << ".");
    195198  }
    196199
     
    289292        iter != fragmentrange.second;
    290293        ++iter) {
    291       const Fragment& fragment = iter->second.first;
    292       const double &energy = iter->second.second;
     294      const Fragment& fragment = iter->second.fragment;
     295      const double &energy = iter->second.energy;
    293296
    294297      // create arguments from the fragment
  • src/Fragmentation/Homology/HomologyContainer.cpp

    rff09f3 rbf1d1b  
    6262      iter != homologycontainer.container.end(); ++iter) {
    6363    out << "Graph: " << iter->first
    64         << ", (Fragment " << iter->second.first
    65         << ":" << iter->second.second << ")\n";
     64        << ", (Fragment " << iter->second.fragment
     65        << ":" << iter->second.energy
     66        << ":" << iter->second.charge_distribution.integral()
     67        << ")\n";
    6668  }
    6769  return out;
     70}
     71
     72bool HomologyContainer::value_t::operator==(const value_t &othervalue) const
     73{
     74  if (fragment != othervalue.fragment)
     75    return false;
     76  if (energy != othervalue.energy)
     77    return false;
     78  if (charge_distribution != othervalue.charge_distribution)
     79    return false;
     80  if (potential_distribution != othervalue.potential_distribution)
     81    return false;
     82  return true;
    6883}
    6984
  • src/Fragmentation/Homology/HomologyContainer.hpp

    rff09f3 rbf1d1b  
    2929#include "Fragmentation/Homology/HomologyGraph.hpp"
    3030#include "Fragmentation/Summation/SetValues/Fragment.hpp"
     31#include "Fragmentation/Summation/SetValues/SamplingGrid.hpp"
    3132
    3233class HomologyContainerTest;
     
    4950  //!> grant unit test access
    5051  friend class HomologyContainerTest;
     52
    5153public:
    52   typedef double energy_t;
    53   typedef std::pair<Fragment, energy_t> value_t;
     54  /** This structure represents all values associated to a specific homology
     55   * that we wish to store in this container for later reference.
     56   */
     57  struct value_t {
     58    Fragment fragment;
     59    double energy;
     60    bool containsGrids;
     61    SamplingGrid charge_distribution;
     62    SamplingGrid potential_distribution;
     63
     64    value_t() :
     65      energy(0.),
     66      containsGrids(false)
     67    {}
     68
     69    bool operator==(const value_t &othervalue) const;
     70
     71  private:
     72    friend class boost::serialization::access;
     73    // serialization
     74    template <typename Archive>
     75    void serialize(Archive& ar, const unsigned int version)
     76    {
     77      ar & fragment;
     78      ar & energy;
     79      if (version > 0) {
     80        ar & containsGrids;
     81        if (containsGrids) {
     82          ar & charge_distribution;
     83          ar & potential_distribution;
     84        }
     85      }
     86    }
     87  };
     88
     89public:
    5490  typedef std::multimap< HomologyGraph, value_t> container_t;
    5591  typedef container_t::const_iterator const_iterator;
     
    176212BOOST_CLASS_EXPORT_KEY(HomologyContainer)
    177213
     214// version for serialized information associated to HomologyGraph
     215BOOST_CLASS_VERSION(HomologyContainer::value_t, 1)
    178216
    179217#endif /* HOMOLOGYCONTAINER_HPP_ */
  • src/Fragmentation/Homology/unittests/HomologyContainerUnitTest.cpp

    rff09f3 rbf1d1b  
    100100  positions[0][0] = 2.;
    101101  Fragment dummy2(positions, charges);
     102  HomologyContainer::value_t value1;
     103  value1.fragment = dummy1;
     104  value1.energy = 1.;
     105  HomologyContainer::value_t value2;
     106  value2.fragment = dummy2;
     107  value2.energy = 1.5;
     108  HomologyContainer::value_t value3;
     109  value3.fragment = dummy;
     110  value3.energy = 2.;
    102111  container +=
    103       std::make_pair( graph, std::make_pair(dummy1, 1.) ),
    104       std::make_pair( graph, std::make_pair(dummy2, 1.5) ),
    105       std::make_pair( othergraph, std::make_pair(dummy, 2.) );
     112      std::make_pair( graph, value1 ),
     113      std::make_pair( graph, value2 ),
     114      std::make_pair( othergraph, value3 );
    106115  // create HomologyContainer
    107116  Keys = new HomologyContainer(container);
     
    126135  Fragment::charges_t charges(1,1.);
    127136  Fragment dummy(positions, charges);
     137  HomologyContainer::value_t value;
     138  value.fragment = dummy;
     139  value.energy = 1.;
    128140  newcontainer +=
    129       std::make_pair( graph, std::make_pair(dummy, 1.) );
     141      std::make_pair( graph, value );
    130142
    131143  Keys->insert(newcontainer);
     
    148160  Fragment::charges_t charges(1,1.);
    149161  Fragment dummy(positions, charges);
     162  HomologyContainer::value_t value;
     163  value.fragment = dummy;
     164  value.energy = 1.;
    150165  newcontainer +=
    151       std::make_pair( graph, std::make_pair(dummy, 1.) );
     166      std::make_pair( graph, value );
    152167
    153168  HomologyContainer other(newcontainer);
  • src/Fragmentation/Homology/unittests/Makefile.am

    rff09f3 rbf1d1b  
    2525
    2626FRAGMENTATIONHOMOLOGYLIBS = \
     27        ../libMolecuilderFragmentationSetValues.la \
    2728        ../libMolecuilderFragmentation.la \
    2829        ../libMolecuilderFragmentation_getFromKeysetStub.la \
  • src/FunctionApproximation/TrainingData.cpp

    rff09f3 rbf1d1b  
    5454void TrainingData::operator()(const range_t &range) {
    5555  for (HomologyContainer::const_iterator iter = range.first; iter != range.second; ++iter) {
    56     const Fragment &fragment = iter->second.first;
     56    const Fragment &fragment = iter->second.fragment;
    5757    // create internal list of arguments
    5858    FunctionModel::arguments_t all_args = Extractors::gatherAllSymmetricDistances(
     
    6262        );
    6363    DistanceVector.push_back( all_args );
    64     const double &energy = iter->second.second;
     64    const double &energy = iter->second.energy;
    6565    EnergyVector.push_back( FunctionModel::results_t(1, energy) );
    6666    // filter distances out of list of all arguments
Note: See TracChangeset for help on using the changeset viewer.