BALL 1.5.0
Classes | Friends | List of all members
BALL::AssignBondOrderProcessor Class Reference

Assignment of bond orders from topology information. More...

#include <BALL/STRUCTURE/assignBondOrderProcessor.h>

Inheritance diagram for BALL::AssignBondOrderProcessor:
BALL::UnaryProcessor< AtomContainer > BALL::UnaryFunctor< AtomContainer, Processor::Result >

Classes

struct  Algorithm
 
struct  Default
 Default values for options. More...
 
struct  Option
 Option names. More...
 

Public Member Functions

Constructors and Destructors
 AssignBondOrderProcessor ()
 Default Constructor. More...
 
virtual ~AssignBondOrderProcessor ()
 Destructor. More...
 
Processor-related methods
virtual bool start ()
 Processor method which is called before the operator()-call. More...
 
void clear ()
 
virtual Processor::Result operator() (AtomContainer &ac)
 
virtual bool finish ()
 Processor method which is called after the operator()-call. More...
 
Accessors
Size getNumberOfAddedHydrogens (Position i)
 
Size getNumberOfComputedSolutions ()
 
AtomContainergetAtomContainer ()
 
AtomContainer const * getAtomContainer () const
 
const SystemgetSolution (Position i)
 
float getTotalCharge (Position i)
 
float getTotalPenalty (Position i=0)
 
int getNumberOfNodeExpansions (Position i)
 
int getQueueSize (Position i)
 
bool apply (Position i)
 
void resetBondOrders ()
 
bool computeNextSolution (bool apply_solution=true)
 
void setDefaultOptions ()
 
bool hasValidOptions ()
 
float evaluatePenalty (AtomContainer *ac)
 
- Public Member Functions inherited from BALL::UnaryProcessor< AtomContainer >
 UnaryProcessor ()
 
 UnaryProcessor (const UnaryProcessor &)
 
virtual ~UnaryProcessor ()
 

Friends

class PartialBondOrderAssignment
 
class BondOrderAssignment
 
class PQ_Entry_
 
class BondOrderAssignmentStrategy
 
class AStarBondOrderStrategy
 
class BranchAndBoundBondOrderStrategy
 
class FPTBondOrderStrategy
 
class ILPBondOrderStrategy
 
class KGreedyBondOrderStrategy
 

Public Attributes

Options options
 the processor's options More...
 
bool valid_
 Processor is in a useable valid state. More...
 
bool evaluation_mode_
 Processor is in an evaluation mode. Default is false. More...
 
std::map< Bond *, short > bond_fixed_
 
std::vector< Bond * > free_bonds_
 
HashMap< Bond *, Indexbond_to_index_
 
std::vector< Bond * > index_to_bond_
 
HashMap< Atom *, int > number_of_virtual_hydrogens_
 
std::vector< int > virtual_bond_index_to_number_of_virtual_hydrogens_
 
Size num_of_virtual_bonds_
 
vector< Atom * > virtual_bond_index_to_atom_
 
HashMap< Atom *, int > atom_to_virtual_bond_index_
 
Bondvirtual_bond_
 
Position total_num_of_bonds_
 
int num_of_free_bonds_
 
std::vector< Positionfixed_val_
 
vector< BondOrderAssignmentsolutions_
 
vector< BondOrderAssignmentstarting_configuration_
 
float atom_type_normalization_factor_
 
float bond_length_normalization_factor_
 
int last_applied_solution_
 
AtomContainerac_
 
int max_bond_order_
 
float alpha_
 
int max_number_of_solutions_
 
int max_penalty_
 
bool compute_also_non_optimal_solutions_
 
bool add_missing_hydrogens_
 
bool compute_also_connectivity_
 
bool use_fine_penalty_
 
vector< int > penalties_
 
vector< Positionblock_to_start_idx_
 
vector< Sizeblock_to_length_
 
vector< int > block_to_start_valence_
 
vector< std::pair< String, String > > block_definition_
 
vector< vector< int > > atom_to_block_
 
HashMap< Bond *, vector< float > > bond_lengths_penalties_
 
Timer timer_
 
StringHashMap< boost::shared_ptr< BondOrderAssignmentStrategy > > strategies_
 
bool readOptions_ ()
 
bool readAtomPenalties_ ()
 
bool preassignPenaltyClasses_ ()
 
int getPenaltyClass_ (Atom *atom)
 
bool precomputeBondLengthPenalties_ ()
 
float computeVirtualHydrogens_ (Atom *atom)
 
bool apply_ (BondOrderAssignment &solution)
 
void storeOriginalConfiguration_ ()
 
int getQueueSize_ (const BondOrderAssignment &sol)
 
float getTotalCharge_ (const BondOrderAssignment &sol)
 
float getTotalPenalty_ (const BondOrderAssignment &sol)
 
int getNumberOfNodeExpansions_ (const BondOrderAssignment &sol)
 
 AssignBondOrderProcessor (const AssignBondOrderProcessor &abop)
 
AssignBondOrderProcessoroperator= (const AssignBondOrderProcessor &abop)
 

Additional Inherited Members

- Public Types inherited from BALL::UnaryFunctor< AtomContainer, Processor::Result >
typedef Processor::Result result_type
 
typedef AtomContainer argument_type
 
typedef AtomContainerargument_reference
 
typedef const AtomContainerconst_argument_reference
 
typedef AtomContainerargument_pointer
 
typedef const AtomContainerconst_argument_pointer
 

Detailed Description

Assignment of bond orders from topology information.

Called with default options the processor computes up to Default::MAX_NUMBER_OF_SOLUTIONS many possible bond orders with optimal value and applies the first solution found to the given AtomContainer.

All further optimal solutions can be applied by calling the method apply() . Additional solutions can be computed by calling the method computeNextSolution() (except when using the FPT strategy which currently does not support this behaviour).


Example code:
...
sys.apply(bop);
bop.apply(i-1);
...
while (bop.computeNextSolution())
{
i++;
bop.apply(i);
}
void setBool(const String &key, const bool value)
Assignment of bond orders from topology information.
bool computeNextSolution(bool apply_solution=true)
Options options
the processor's options

Definition at line 88 of file assignBondOrderProcessor.h.

Constructor & Destructor Documentation

◆ AssignBondOrderProcessor() [1/2]

BALL::AssignBondOrderProcessor::AssignBondOrderProcessor ( )

Default Constructor.

◆ ~AssignBondOrderProcessor()

virtual BALL::AssignBondOrderProcessor::~AssignBondOrderProcessor ( )
virtual

Destructor.

◆ AssignBondOrderProcessor() [2/2]

BALL::AssignBondOrderProcessor::AssignBondOrderProcessor ( const AssignBondOrderProcessor abop)
protected

Member Function Documentation

◆ apply()

bool BALL::AssignBondOrderProcessor::apply ( Position  i)

Applies the i-th precomputed bond order assignment.

Sets the AtomContainer's bond orders to the ones found in the (already computed!) i-th solution, start counting at 0!

NOTE: All virtual hydrogens added to the processed AtomContainer by a previous call of apply will be deleted by the current call!
Parameters
iindex of the solution whose bond orders should be assigned.
Returns
bool - true if the i-th solution is valid, false otherwise.

◆ apply_()

bool BALL::AssignBondOrderProcessor::apply_ ( BondOrderAssignment solution)
protected

Applies the given solution.

◆ clear()

void BALL::AssignBondOrderProcessor::clear ( )

Clears the data structures.

NOTE: The options remain! Use setDefaultOptions() to clear the options.

◆ computeNextSolution()

bool BALL::AssignBondOrderProcessor::computeNextSolution ( bool  apply_solution = true)

Computes and applies one of the next best solutions.

Ignores the options MAX_NUMBER_OF_SOLUTIONS and COMPUTE_ALSO_NON_OPTIMAL_SOLUTIONS .

Returns
bool - false if no further solution can be found.

◆ computeVirtualHydrogens_()

float BALL::AssignBondOrderProcessor::computeVirtualHydrogens_ ( Atom atom)
protected

Adds missing hydrogens as virtual hydrogens to the given atom, determines the possible penalty blocks, and returns the maximal possible atom type penalty.

"virtual" means that NO
atoms and bonds are added to the original AtomContainer.

Parameters
atomthe atom, to which the virtual hydrogens should be added.
Returns
float - the max possible penalty the atom can get, if hydrogen(s) are added.
See also
Option::ADD_HYDROGENS

◆ evaluatePenalty()

float BALL::AssignBondOrderProcessor::evaluatePenalty ( AtomContainer ac)

Evaluates the AtomContainer's bond orders as specified in the Options and returns the computed penalty.

Parameters
acAtomContainer, whose bond orders should be evaluated.
Returns
float - computed penalty, -1 if current assignment is not valid or includes aromatic bonds.

◆ finish()

virtual bool BALL::AssignBondOrderProcessor::finish ( )
virtual

Processor method which is called after the operator()-call.

Reimplemented from BALL::UnaryProcessor< AtomContainer >.

◆ getAtomContainer() [1/2]

AtomContainer * BALL::AssignBondOrderProcessor::getAtomContainer ( )
inline

Returns a pointer to the original Molecule as AtomContainer.

Definition at line 391 of file assignBondOrderProcessor.h.

◆ getAtomContainer() [2/2]

AtomContainer const * BALL::AssignBondOrderProcessor::getAtomContainer ( ) const
inline

Returns a nonmutable pointer to the original Molecule as AtomContainer.

Definition at line 395 of file assignBondOrderProcessor.h.

◆ getNumberOfAddedHydrogens()

Size BALL::AssignBondOrderProcessor::getNumberOfAddedHydrogens ( Position  i)
inline

Returns the number of added hydrogens in solution i.

NOTE: Hydrogens can only be added using the Option::ADD_HYDROGENS-option.

Returns
Size - number of hydrogens added in assignment solution i.
See also
Option::ADD_HYDROGENS

Definition at line 362 of file assignBondOrderProcessor.h.

◆ getNumberOfComputedSolutions()

Size BALL::AssignBondOrderProcessor::getNumberOfComputedSolutions ( )
inline

Returns the number of already computed solutions.

NOTE: Having applied the operator with option Option Algorithm::A_STAR this method returns the number of optimal solutions+1!

Returns
Size - number of already computed solutions.
See also
Option::COMPUTE_ALSO_NON_OPTIMAL_SOLUTIONS
Option::MAX_NUMBER_OF_SOLUTIONS

Definition at line 386 of file assignBondOrderProcessor.h.

◆ getNumberOfNodeExpansions()

int BALL::AssignBondOrderProcessor::getNumberOfNodeExpansions ( Position  i)
inline

Definition at line 451 of file assignBondOrderProcessor.h.

◆ getNumberOfNodeExpansions_()

int BALL::AssignBondOrderProcessor::getNumberOfNodeExpansions_ ( const BondOrderAssignment sol)
inlineprotected

Definition at line 651 of file assignBondOrderProcessor.h.

◆ getPenaltyClass_()

int BALL::AssignBondOrderProcessor::getPenaltyClass_ ( Atom atom)
protected

Finds the first matching SMARTS-expression in the penalty-vector and returns its index.

Return values
int-1 if there is no matching expression

◆ getQueueSize()

int BALL::AssignBondOrderProcessor::getQueueSize ( Position  i)
inline

Definition at line 468 of file assignBondOrderProcessor.h.

◆ getQueueSize_()

int BALL::AssignBondOrderProcessor::getQueueSize_ ( const BondOrderAssignment sol)
inlineprotected

Definition at line 615 of file assignBondOrderProcessor.h.

◆ getSolution()

const System & BALL::AssignBondOrderProcessor::getSolution ( Position  i)

Returns a reference to the original system to which solution i was applied.

NOTE: This method has the same effect as calling apply(i)!

Parameters
iindex of the solution, whose bond order assignment should be applied.
Returns
const System& - the original system with bond order assignment of solution i. If i is invalid, an Exception is thrown.
Exceptions
BALL::Exception::IndexOverflow

◆ getTotalCharge()

float BALL::AssignBondOrderProcessor::getTotalCharge ( Position  i)
inline

Returns the total charge of solution i.

NOTE: This method is still experimental.

Parameters
iindex of the solution, whose charge should be computed.
Returns
float - total charge of solution i.

Definition at line 415 of file assignBondOrderProcessor.h.

◆ getTotalCharge_()

float BALL::AssignBondOrderProcessor::getTotalCharge_ ( const BondOrderAssignment sol)
inlineprotected

Returns the total charge of a solution.

Parameters
solsolution, whose charge should be computed.
Returns
float - total charge of the given solution.

Definition at line 623 of file assignBondOrderProcessor.h.

◆ getTotalPenalty()

float BALL::AssignBondOrderProcessor::getTotalPenalty ( Position  i = 0)
inline

Returns the total penalty of solution i.

Parameters
iindex of the solution, whose penalty should be returned.
Returns
float - total penalty of solution i.

Definition at line 434 of file assignBondOrderProcessor.h.

◆ getTotalPenalty_()

float BALL::AssignBondOrderProcessor::getTotalPenalty_ ( const BondOrderAssignment sol)
inlineprotected

Returns the total penalty of the given solution.

Parameters
solsolution, whose penalty should be returned.
Returns
float - total penalty of solution i.
See also
Option::BOND_LENGTH_WEIGHTING;

Definition at line 641 of file assignBondOrderProcessor.h.

◆ hasValidOptions()

bool BALL::AssignBondOrderProcessor::hasValidOptions ( )
inline

Checks the options.

Definition at line 516 of file assignBondOrderProcessor.h.

◆ operator()()

virtual Processor::Result BALL::AssignBondOrderProcessor::operator() ( AtomContainer ac)
virtual

Operator () for the processor

Called with Default-options the processor computes all possible bond order assignments with optimal atomic penalty value and applies the first solution to the given AtomContainer.

NOTE: Having used the Algorithm::A_STAR-option (default) the method getNumberOfComputedSolutions() will return the number of optimal solutions+1!

Parameters
acthe AtomContainer to which the processor is applied.

Reimplemented from BALL::UnaryProcessor< AtomContainer >.

◆ operator=()

AssignBondOrderProcessor & BALL::AssignBondOrderProcessor::operator= ( const AssignBondOrderProcessor abop)
protected

◆ preassignPenaltyClasses_()

bool BALL::AssignBondOrderProcessor::preassignPenaltyClasses_ ( )
protected

Assigns every atom of the AtomContainer to which the processor is applied to a block of possible valences and the corresponding penalties.

Return values
bool- false if the AtomContainer to which the processor is applied to has an atom with no matching penalty block.
bool- true otherwise

◆ precomputeBondLengthPenalties_()

bool BALL::AssignBondOrderProcessor::precomputeBondLengthPenalties_ ( )
protected

Precomputes for every bond of the AtomContainer, to which the processor is applied to, the possible bond length penalties resulting from deviation of the actual bond length to a standard length for bonds with same atom types and the chosen bond order.

If there is no information for certain atom pairs, penalty 0 is assumed. In case of incomplete information, we assume the missing bond orders to be really unlikely and we set a penalty to 2* max_deviation_found (for this bond).
Return values
bool- false if the AtomContainer is invalid or the processor is in an invalid state
bool- true otherwise

◆ readAtomPenalties_()

bool BALL::AssignBondOrderProcessor::readAtomPenalties_ ( )
protected

Reads and stores the penalty-INIFile (for example BondOrder.ini).

Returns
bool - false if the INIFile could not be read correctly.
Exceptions
BALL::Exception::FileNotFound

◆ readOptions_()

bool BALL::AssignBondOrderProcessor::readOptions_ ( )
protected

Reads, checks and stores the options.

Returns
bool - false if one of the options got an invalid value.
bool - true otherwise

◆ resetBondOrders()

void BALL::AssignBondOrderProcessor::resetBondOrders ( )

Resets all bond orders and assigned hydrogens.

Assigns the original bond order assignments to the AtomContainer we are operating on.

◆ setDefaultOptions()

void BALL::AssignBondOrderProcessor::setDefaultOptions ( )

Resets the options to default values.

◆ start()

virtual bool BALL::AssignBondOrderProcessor::start ( )
virtual

Processor method which is called before the operator()-call.

Reimplemented from BALL::UnaryProcessor< AtomContainer >.

◆ storeOriginalConfiguration_()

void BALL::AssignBondOrderProcessor::storeOriginalConfiguration_ ( )
protected

Stores the original configuration of the AtomContainer.

Friends And Related Function Documentation

◆ AStarBondOrderStrategy

friend class AStarBondOrderStrategy
friend

Definition at line 100 of file assignBondOrderProcessor.h.

◆ BondOrderAssignment

friend class BondOrderAssignment
friend

Definition at line 93 of file assignBondOrderProcessor.h.

◆ BondOrderAssignmentStrategy

friend class BondOrderAssignmentStrategy
friend

Definition at line 98 of file assignBondOrderProcessor.h.

◆ BranchAndBoundBondOrderStrategy

friend class BranchAndBoundBondOrderStrategy
friend

Definition at line 101 of file assignBondOrderProcessor.h.

◆ FPTBondOrderStrategy

friend class FPTBondOrderStrategy
friend

Definition at line 102 of file assignBondOrderProcessor.h.

◆ ILPBondOrderStrategy

friend class ILPBondOrderStrategy
friend

Definition at line 103 of file assignBondOrderProcessor.h.

◆ KGreedyBondOrderStrategy

friend class KGreedyBondOrderStrategy
friend

Definition at line 104 of file assignBondOrderProcessor.h.

◆ PartialBondOrderAssignment

friend class PartialBondOrderAssignment
friend

Definition at line 92 of file assignBondOrderProcessor.h.

◆ PQ_Entry_

friend class PQ_Entry_
friend

Definition at line 96 of file assignBondOrderProcessor.h.

Member Data Documentation

◆ ac_

AtomContainer* BALL::AssignBondOrderProcessor::ac_
protected

Definition at line 725 of file assignBondOrderProcessor.h.

◆ add_missing_hydrogens_

bool BALL::AssignBondOrderProcessor::add_missing_hydrogens_
protected

Definition at line 743 of file assignBondOrderProcessor.h.

◆ alpha_

float BALL::AssignBondOrderProcessor::alpha_
protected

Definition at line 731 of file assignBondOrderProcessor.h.

◆ atom_to_block_

vector< vector<int> > BALL::AssignBondOrderProcessor::atom_to_block_
protected

Definition at line 772 of file assignBondOrderProcessor.h.

◆ atom_to_virtual_bond_index_

HashMap<Atom*, int> BALL::AssignBondOrderProcessor::atom_to_virtual_bond_index_
protected

Definition at line 690 of file assignBondOrderProcessor.h.

◆ atom_type_normalization_factor_

float BALL::AssignBondOrderProcessor::atom_type_normalization_factor_
protected

Definition at line 715 of file assignBondOrderProcessor.h.

◆ block_definition_

vector<std::pair<String, String> > BALL::AssignBondOrderProcessor::block_definition_
protected

Definition at line 765 of file assignBondOrderProcessor.h.

◆ block_to_length_

vector<Size> BALL::AssignBondOrderProcessor::block_to_length_
protected

Definition at line 762 of file assignBondOrderProcessor.h.

◆ block_to_start_idx_

vector<Position> BALL::AssignBondOrderProcessor::block_to_start_idx_
protected

Definition at line 761 of file assignBondOrderProcessor.h.

◆ block_to_start_valence_

vector<int> BALL::AssignBondOrderProcessor::block_to_start_valence_
protected

Definition at line 763 of file assignBondOrderProcessor.h.

◆ bond_fixed_

std::map<Bond*, short> BALL::AssignBondOrderProcessor::bond_fixed_
protected

Definition at line 661 of file assignBondOrderProcessor.h.

◆ bond_length_normalization_factor_

float BALL::AssignBondOrderProcessor::bond_length_normalization_factor_
protected

Definition at line 718 of file assignBondOrderProcessor.h.

◆ bond_lengths_penalties_

HashMap<Bond*, vector<float> > BALL::AssignBondOrderProcessor::bond_lengths_penalties_
protected

Definition at line 775 of file assignBondOrderProcessor.h.

◆ bond_to_index_

HashMap<Bond*, Index> BALL::AssignBondOrderProcessor::bond_to_index_
protected

Definition at line 667 of file assignBondOrderProcessor.h.

◆ compute_also_connectivity_

bool BALL::AssignBondOrderProcessor::compute_also_connectivity_
protected

Definition at line 746 of file assignBondOrderProcessor.h.

◆ compute_also_non_optimal_solutions_

bool BALL::AssignBondOrderProcessor::compute_also_non_optimal_solutions_
protected

Definition at line 740 of file assignBondOrderProcessor.h.

◆ evaluation_mode_

bool BALL::AssignBondOrderProcessor::evaluation_mode_
protected

Processor is in an evaluation mode. Default is false.

Definition at line 657 of file assignBondOrderProcessor.h.

◆ fixed_val_

std::vector<Position> BALL::AssignBondOrderProcessor::fixed_val_
protected

Definition at line 705 of file assignBondOrderProcessor.h.

◆ free_bonds_

std::vector<Bond*> BALL::AssignBondOrderProcessor::free_bonds_
protected

Definition at line 664 of file assignBondOrderProcessor.h.

◆ index_to_bond_

std::vector<Bond*> BALL::AssignBondOrderProcessor::index_to_bond_
protected

Definition at line 670 of file assignBondOrderProcessor.h.

◆ last_applied_solution_

int BALL::AssignBondOrderProcessor::last_applied_solution_
protected

Definition at line 722 of file assignBondOrderProcessor.h.

◆ max_bond_order_

int BALL::AssignBondOrderProcessor::max_bond_order_
protected

Definition at line 728 of file assignBondOrderProcessor.h.

◆ max_number_of_solutions_

int BALL::AssignBondOrderProcessor::max_number_of_solutions_
protected

Definition at line 734 of file assignBondOrderProcessor.h.

◆ max_penalty_

int BALL::AssignBondOrderProcessor::max_penalty_
protected

Definition at line 737 of file assignBondOrderProcessor.h.

◆ num_of_free_bonds_

int BALL::AssignBondOrderProcessor::num_of_free_bonds_
protected

Definition at line 702 of file assignBondOrderProcessor.h.

◆ num_of_virtual_bonds_

Size BALL::AssignBondOrderProcessor::num_of_virtual_bonds_
protected

Definition at line 686 of file assignBondOrderProcessor.h.

◆ number_of_virtual_hydrogens_

HashMap<Atom*, int> BALL::AssignBondOrderProcessor::number_of_virtual_hydrogens_
protected

Definition at line 680 of file assignBondOrderProcessor.h.

◆ options

Options BALL::AssignBondOrderProcessor::options

the processor's options

Definition at line 531 of file assignBondOrderProcessor.h.

◆ penalties_

vector<int> BALL::AssignBondOrderProcessor::penalties_
protected

Definition at line 760 of file assignBondOrderProcessor.h.

◆ solutions_

vector<BondOrderAssignment> BALL::AssignBondOrderProcessor::solutions_
protected

Definition at line 708 of file assignBondOrderProcessor.h.

◆ starting_configuration_

vector<BondOrderAssignment> BALL::AssignBondOrderProcessor::starting_configuration_
protected

Definition at line 712 of file assignBondOrderProcessor.h.

◆ strategies_

StringHashMap<boost::shared_ptr<BondOrderAssignmentStrategy> > BALL::AssignBondOrderProcessor::strategies_
protected

Definition at line 783 of file assignBondOrderProcessor.h.

◆ timer_

Timer BALL::AssignBondOrderProcessor::timer_
protected

Definition at line 777 of file assignBondOrderProcessor.h.

◆ total_num_of_bonds_

Position BALL::AssignBondOrderProcessor::total_num_of_bonds_
protected

Definition at line 699 of file assignBondOrderProcessor.h.

◆ use_fine_penalty_

bool BALL::AssignBondOrderProcessor::use_fine_penalty_
protected

Definition at line 749 of file assignBondOrderProcessor.h.

◆ valid_

bool BALL::AssignBondOrderProcessor::valid_
protected

Processor is in a useable valid state.

Definition at line 654 of file assignBondOrderProcessor.h.

◆ virtual_bond_

Bond* BALL::AssignBondOrderProcessor::virtual_bond_
protected

Definition at line 694 of file assignBondOrderProcessor.h.

◆ virtual_bond_index_to_atom_

vector<Atom*> BALL::AssignBondOrderProcessor::virtual_bond_index_to_atom_
protected

Definition at line 689 of file assignBondOrderProcessor.h.

◆ virtual_bond_index_to_number_of_virtual_hydrogens_

std::vector<int> BALL::AssignBondOrderProcessor::virtual_bond_index_to_number_of_virtual_hydrogens_
protected

Definition at line 683 of file assignBondOrderProcessor.h.