BALL  1.4.79
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
BALL::FPTBondOrderStrategy::DPBackTrackingCombiner_ Class Reference

#include <BALL/STRUCTURE/BONDORDERS/FPTBondOrderStrategy.h>

Public Member Functions

 DPBackTrackingCombiner_ (std::vector< FPTBondOrderAssignment_ * > &bond_assignments, Size solution_number, Penalty upper_bound=infinite_penalty)
 
 DPBackTrackingCombiner_ (DPBackTrackingCombiner_ const &copy)
 
 ~DPBackTrackingCombiner_ ()
 
void clear ()
 
DPBackTrackingCombiner_operator= (DPBackTrackingCombiner_ const &copy)
 
bool hasMoreSolutions () const
 
void nextSolution ()
 
Assignment_getSolution ()
 
Assignment_ const & getSolution () const
 
Penalty penaltyOfNextSolution () const
 

Public Attributes

std::vector
< MolecularGraphTraits::EdgeType
sorted_edges
 

Protected Member Functions

std::pair< Size, PenaltygetNextMinimumBackTracker_ () const
 
void applyAssignment_ (Size backtracker_index, Size solution_index)
 
void initialize_ ()
 
void combineEachSolution_ (Size mindex)
 
std::vector< DPBackTracking_ * > deepCopyOfBacktrackers_ () const
 

Protected Attributes

std::vector< DPBackTracking_ * > backtrackers_
 
std::priority_queue
< Assignment_, std::vector
< Assignment_ >, std::greater
< Assignment_ > > 
priority_queue_
 
std::vector< std::vector
< Assignment_ > > 
component_solutions_
 
Assignment_ assignment_
 
Size solution_number_
 
Penalty optimum_
 
Penalty upper_bound_
 

Detailed Description

Combines backtracked solutions from other DPBackTrackers. Is used to combine the solutions of computed connection components of a graph to a solution for the whole graph. Because the bond orders of the connection components are disjoint, the solutions of the backtrackers can be combined independently. This class provides the same public functions as DPBackTracking. Remarks that this class will start the backtracking of the best solution after constructing, while DPBackTracking will start only after calling DPBackTracking::nextSolution. Nevertheless you have to call nextSolution before you can access the optimal solution.

Definition at line 1240 of file FPTBondOrderStrategy.h.

Constructor & Destructor Documentation

BALL::FPTBondOrderStrategy::DPBackTrackingCombiner_::DPBackTrackingCombiner_ ( std::vector< FPTBondOrderAssignment_ * > &  bond_assignments,
Size  solution_number,
Penalty  upper_bound = infinite_penalty 
)

Construct a DPBackTrackingCombiner with the given FPTBondOrder and the number of solutions

Parameters
bondAssignmentsvector with pointers to the bond assignments. Call #compute before constructing
solutionNumberthe maximum number of solutions you want to backtrack
BALL::FPTBondOrderStrategy::DPBackTrackingCombiner_::DPBackTrackingCombiner_ ( DPBackTrackingCombiner_ const &  copy)

Copy constructor

BALL::FPTBondOrderStrategy::DPBackTrackingCombiner_::~DPBackTrackingCombiner_ ( )

Destructor. Deletes all backtrackers but not the bond assignment algorithms

Member Function Documentation

void BALL::FPTBondOrderStrategy::DPBackTrackingCombiner_::applyAssignment_ ( Size  backtracker_index,
Size  solution_index 
)
protected

Combines the component assignment with the whole graph assignment

Parameters
backtracker_indexindex of the backtracker
solutionIndexthe number of the assignment of this backtracker, which will be combined
void BALL::FPTBondOrderStrategy::DPBackTrackingCombiner_::clear ( )
void BALL::FPTBondOrderStrategy::DPBackTrackingCombiner_::combineEachSolution_ ( Size  mindex)
protected

Combines the given new assignment with each previous found assignments

Parameters
mindexindex of the backtracker which found the next best assignment
std::vector<DPBackTracking_*> BALL::FPTBondOrderStrategy::DPBackTrackingCombiner_::deepCopyOfBacktrackers_ ( ) const
protected

copy each DPBackTracking

std::pair<Size, Penalty> BALL::FPTBondOrderStrategy::DPBackTrackingCombiner_::getNextMinimumBackTracker_ ( ) const
protected

Searches for the backtracker which would compute the best next solution (after combining). Returns it index and the penalty of it's solution.

Assignment_& BALL::FPTBondOrderStrategy::DPBackTrackingCombiner_::getSolution ( )

returns the last computed solution

Assignment_ const& BALL::FPTBondOrderStrategy::DPBackTrackingCombiner_::getSolution ( ) const

returns the last computed solution, const version

bool BALL::FPTBondOrderStrategy::DPBackTrackingCombiner_::hasMoreSolutions ( ) const

return true if there are more solutions to backtrack

void BALL::FPTBondOrderStrategy::DPBackTrackingCombiner_::initialize_ ( )
protected

Lets each backtracker backtrack a solution and initialize the combiner.

void BALL::FPTBondOrderStrategy::DPBackTrackingCombiner_::nextSolution ( )

computes the next solution. Call hasMoreSolutions before to avoid an OutOfRange exception.

Exceptions
BALL::Exception::OutOfRangeif there is no more solution to backtrack
DPBackTrackingCombiner_& BALL::FPTBondOrderStrategy::DPBackTrackingCombiner_::operator= ( DPBackTrackingCombiner_ const &  copy)

Assignment operator

Penalty BALL::FPTBondOrderStrategy::DPBackTrackingCombiner_::penaltyOfNextSolution ( ) const

returns the penalty of the solution which can be backtracked next or INFINITE_PENALTY, if there is no more solution.

Member Data Documentation

Assignment_ BALL::FPTBondOrderStrategy::DPBackTrackingCombiner_::assignment_
protected

the last backtracked and combined solution

Definition at line 1323 of file FPTBondOrderStrategy.h.

std::vector<DPBackTracking_*> BALL::FPTBondOrderStrategy::DPBackTrackingCombiner_::backtrackers_
protected

The backtrackers. They are managed by this class, so you don't have to care about deleting them.

Definition at line 1305 of file FPTBondOrderStrategy.h.

std::vector<std::vector<Assignment_> > BALL::FPTBondOrderStrategy::DPBackTrackingCombiner_::component_solutions_
protected

The backtracked solutions of the connection components. They can be combined to build the solution of the whole graph.

Definition at line 1318 of file FPTBondOrderStrategy.h.

Penalty BALL::FPTBondOrderStrategy::DPBackTrackingCombiner_::optimum_
protected

The penalty of the best solution

Definition at line 1333 of file FPTBondOrderStrategy.h.

std::priority_queue<Assignment_, std::vector<Assignment_>, std::greater<Assignment_> > BALL::FPTBondOrderStrategy::DPBackTrackingCombiner_::priority_queue_
protected

The priority queue for the assignments. Because each new backtracked assignment of a connection component can be combined with each other found assignment of the other connection components, you get many new solutions in each backtracking step. They are combined inserted into this queue.

Definition at line 1312 of file FPTBondOrderStrategy.h.

Size BALL::FPTBondOrderStrategy::DPBackTrackingCombiner_::solution_number_
protected

maximum number of solutions you want to backtrack

Definition at line 1328 of file FPTBondOrderStrategy.h.

std::vector<MolecularGraphTraits::EdgeType> BALL::FPTBondOrderStrategy::DPBackTrackingCombiner_::sorted_edges

A sorted vector of the edges of the graph. The bond values in the assignments are in the same order as the edges in this vector.

Definition at line 1299 of file FPTBondOrderStrategy.h.

Penalty BALL::FPTBondOrderStrategy::DPBackTrackingCombiner_::upper_bound_
protected

This backtracker returns only solutions which have a better penalty than the given upperbound

Definition at line 1338 of file FPTBondOrderStrategy.h.