Changeset 326000 for src


Ignore:
Timestamp:
Apr 17, 2013, 6:56:55 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:
4f04ab8
Parents:
378fc6b
git-author:
Frederik Heber <heber@…> (03/19/13 13:32:21)
git-committer:
Frederik Heber <heber@…> (04/17/13 18:56:55)
Message:

BondGraph::CorrectBondDegree() now allows for incrementing only on a subset.

  • is used to first increment backedges, then treeedges.
Location:
src/Graph
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/Graph/BondGraph.cpp

    r378fc6b r326000  
    3535#include "CodePatterns/MemDebug.hpp"
    3636
     37#include <deque>
    3738#include <iostream>
    3839
     
    4950#include "Element/periodentafel.hpp"
    5051#include "Fragmentation/MatrixContainer.hpp"
     52#include "Graph/DepthFirstSearchAnalysis.hpp"
    5153#include "LinearAlgebra/Vector.hpp"
    5254#include "World.hpp"
     
    226228
    227229/** Corrects the bond degree by one at most if necessary.
     230 *
     231 * We are constraint to bonds in \a egdes, if the candidate bond is in edges, we
     232 * just don't increment its bond degree. We do not choose an alternative for this
     233 * atom.
     234 *
     235 * \param edges only these edges can be updated
    228236 * \return number of corrections done
    229237 */
    230 int BondGraph::CorrectBondDegree(atom *_atom) const
     238int BondGraph::CorrectBondDegree(atom *_atom, const std::set<bond::ptr>& edges) const
    231239{
    232240  int NoBonds = 0;
     
    260268    }
    261269    if ((CandidateBond != NULL)) {
    262       CandidateBond->setDegree(CandidateBond->getDegree()+1);
    263       LOG(2, "Increased bond degree for bond " << *CandidateBond << ".");
     270      if (edges.find(CandidateBond) != edges.end()) {
     271        CandidateBond->setDegree(CandidateBond->getDegree()+1);
     272        LOG(2, "Increased bond degree for bond " << *CandidateBond << ".");
     273      } else
     274        LOG(2, "Bond " << *CandidateBond << " is not in edges.");
    264275    } else {
    265276      ELOG(2, "Could not find correct degree for atom " << *_atom << ".");
     
    268279  }
    269280  return FalseBondDegree;
    270 };
     281}
    271282
    272283/** Sets the weight of all connected bonds to one.
     
    279290      ++BondRunner)
    280291    (*BondRunner)->setDegree(1);
    281 };
    282 
     292}
     293
     294std::set<bond::ptr> BondGraph::getBackEdges() const
     295{
     296  DepthFirstSearchAnalysis DFS;
     297  DFS();
     298
     299  const std::deque<bond::ptr>& backedgestack = DFS.getBackEdgeStack();
     300  std::set<bond::ptr> backedges(backedgestack.begin(), backedgestack.end());
     301
     302  return backedges;
     303}
     304
     305std::set<bond::ptr> BondGraph::getTreeEdges() const
     306{
     307  const std::set<bond::ptr> backedges = getBackEdges();
     308  std::set<bond::ptr> alledges;
     309  const World& world = World::getInstance();
     310  for(World::AtomConstIterator iter = world.getAtomIter();
     311      iter != world.atomEnd(); ++iter) {
     312    const BondList &ListOfBonds = (*iter)->getListOfBonds();
     313    alledges.insert(ListOfBonds.begin(), ListOfBonds.end());
     314  }
     315  std::set<bond::ptr> treeedges;
     316  std::set_difference(
     317      alledges.begin(), alledges.end(),
     318      backedges.begin(), backedges.end(),
     319      std::inserter(treeedges, treeedges.begin()));
     320  return treeedges;
     321}
  • src/Graph/BondGraph.hpp

    r378fc6b r326000  
    473473            class iterator_type,
    474474            class const_iterator_type>
    475   void resetBondDegree(
     475  void resetBondDegree (
    476476      AtomSetMixin<container_type,iterator_type,const_iterator_type> &Set) const
    477477  {
     
    493493      AtomSetMixin<container_type,iterator_type,const_iterator_type> &Set) const
    494494  {
     495    const std::set<bond::ptr> backedges = getBackEdges();
     496    const std::set<bond::ptr> treeedges = getTreeEdges();
     497
    495498    //LOG(1, "Correcting Bond degree of each bond ... ");
    496499    int No = 0, OldNo = -1;
     
    499502      No=0;
    500503      for(iterator_type AtomRunner = Set.begin(); AtomRunner != Set.end(); ++AtomRunner) {
    501         No+=CorrectBondDegree(*AtomRunner);
     504        No+=CorrectBondDegree(*AtomRunner, backedges);
     505      }
     506      for(iterator_type AtomRunner = Set.begin(); AtomRunner != Set.end(); ++AtomRunner) {
     507        No+=CorrectBondDegree(*AtomRunner, treeedges);
    502508      }
    503509    } while (OldNo != No);
     
    512518  }
    513519
    514   int CorrectBondDegree(atom *_atom) const;
     520  std::set<bond::ptr> getBackEdges() const;
     521  std::set<bond::ptr> getTreeEdges() const;
     522
     523  int CorrectBondDegree(atom *_atom, const std::set<bond::ptr>& skipedges) const;
    515524
    516525  void resetBondDegree(atom *_atom) const;
Note: See TracChangeset for help on using the changeset viewer.