1 #ifndef INDIGOX_ALGORITHM_ELECTRON_OPTIMISER_HPP 2 #define INDIGOX_ALGORITHM_ELECTRON_OPTIMISER_HPP 4 #include "../../classes/periodictable.hpp" 5 #include "../../graph/assignment.hpp" 6 #include "../../utils/common.hpp" 7 #include "../../utils/fwd_declares.hpp" 8 #include <boost/dynamic_bitset/dynamic_bitset.hpp> 10 #include <EASTL/vector_set.h> 78 virtual void Run() = 0;
305 return _algo->GetAssignmentGraph();
323 return _algo->ApplyAssignment(idx);
328 return _algo->GetOptimisedScore();
335 std::unique_ptr<AssignAlgorithm> _algo;
339 std::string _current_file;
bool ApplyAssignment(size_t idx)
Apply an optimised assignment.
AssignMask CalculateUpperLimit()
Calculates the upper score limit.
std::vector< graph::AGVertex > _locs
Locations to possibly place electrons.
Definition: assigner.hpp:182
Definition: assigner.hpp:29
size_t GetOptimalCount() const
Definition: assigner.hpp:326
int16_t _max_charge
Maximum charge magnitude.
Definition: assigner.hpp:198
score_t _min_score
Score of optimisied assignments.
Definition: assigner.hpp:190
size_t _num_e
Number of electrons to assign.
Definition: assigner.hpp:184
Option
Definition: common.hpp:25
score_t CalculateVertexScore(const graph::AGVertex &v) const
Calculate the score of a vertex.
const ScoreTable & _table
Reference to the score table.
Definition: assigner.hpp:196
uint16_t _max_results
Maximum number of results.
Definition: assigner.hpp:200
Definition: assigner.hpp:212
std::map< key_t, score_t > ScoreTable
Type of a score table.
Definition: assigner.hpp:27
graph::AssignmentGraph GetAssignmentGraph()
Get the AssignmentGraph used by the assignment algorithm.
Definition: assigner.hpp:304
std::vector< AssignMask > _results
Optimised assignments.
Definition: assigner.hpp:194
Algorithm initailised.
Definition: assigner.hpp:51
static AssignerAlgorithm Algorithm
Which algorithm to use to assign electrons.
Definition: assigner.hpp:215
score_t CalculateAssignmentScore(const AssignMask &a)
Calculate the score of an assignment.
static int16_t MaxChargeMagnitude
The maximum allowed charge magnitude on an atom.
Definition: assigner.hpp:264
static eastl::vector_set< Element > AllowedElements
Set of elements for which scores are available.
Definition: assigner.hpp:283
ElectronAssigner CreateElectronAssigner(const Molecule &m)
Create an ElectronAssigner.
Definition: assigner.hpp:348
uint64_t score_t
Type of the score of an electron assignment.
Definition: assigner.hpp:21
AssignMask _previous_mask
Previous assignment mask.
Definition: assigner.hpp:202
static utils::Option ElectronPairs
Assign electrons in pairs instead of singly.
Definition: assigner.hpp:221
friend ElectronAssigner CreateElectronAssigner(const Molecule &m)
Friendship allows creation of electron assigner instances.
Definition: assigner.hpp:348
size_t GetOptimalCount() const
Get the number of optimal assignments found.
Definition: assigner.hpp:95
boost::dynamic_bitset<> AssignMask
Type of the mask used for assignments.
Definition: assigner.hpp:23
std::shared_ptr< IXElectronAssigner > ElectronAssigner
Definition: fwd_declares.hpp:86
Use pairs of electrons.
Definition: assigner.hpp:48
Number of options.
Definition: assigner.hpp:52
IXElectronAssigner()=delete
score_t _limit
Upper limit of optimised score.
Definition: assigner.hpp:192
virtual void Run()=0
Required method for algorithms to run.
std::shared_ptr< IXAGVertex > AGVertex
Definition: fwd_declares.hpp:104
The local optimisation method.
Preassign electrons.
Definition: assigner.hpp:50
void LoadScoreTable()
Load the current score file.
static score_t Infinity
Value of an infinite score.
Definition: assigner.hpp:252
An A* path finding method.
Base class for an electron assignment algorithm.
Definition: assigner.hpp:44
graph::AssignmentGraph _g
Assignment graph working on.
Definition: assigner.hpp:180
void SetAssignment(const AssignMask &a)
Apply an assignment to the AssignmentGraph.
std::bitset< __num_opts > _opts
State of boolean options.
Definition: assigner.hpp:186
bool ApplyAssignment(size_t idx)
Apply the given assignment.
Definition: assigner.hpp:322
score_t GetOptimisedScore() const
Definition: assigner.hpp:327
static utils::Option Preassign
Assign some electrons prior to performing optimisation.
Definition: assigner.hpp:239
std::shared_ptr< IXAssignmentGraph > AssignmentGraph
Definition: fwd_declares.hpp:100
Definition: molecule.hpp:15
AssignerAlgorithm
Enum of the various electron assignment optimisation algorithms.
Definition: assigner.hpp:206
static uint8_t MaxBondOrder
Maximum bond order to assign.
Definition: assigner.hpp:258
_Molecule _mol
Molecule working with.
Definition: assigner.hpp:178
static std::string ScoreFile
Path to the assignment score file.
Definition: assigner.hpp:246
uint32_t key_t
Type of the key for a score table.
Definition: assigner.hpp:25
virtual ~AssignAlgorithm()
Virtual destructor to avoid memory leaks.
Definition: assigner.hpp:65
A dynamic programming method.
Allow charge carbon.
Definition: assigner.hpp:49
_bool_opts
Normal enum for algorithm option indexing.
Definition: assigner.hpp:47
size_t Run()
Run the electron assignment.
const score_t _inf
Infinity value.
Definition: assigner.hpp:188
static uint16_t MaxNumResults
Maximum number of degenerate score results to calculate.
Definition: assigner.hpp:274
virtual void Initalise(const Molecule &m)
Initalise an assignment algorithm.
score_t GetOptimisedScore() const
Get the optimised score.
Definition: assigner.hpp:91
graph::AssignmentGraph GetAssignmentGraph()
Obtain the AssignmentGraph in use by the algorithm.
bool IsInitalised() const
If the algorithm has been initalised or not.
Definition: assigner.hpp:108
static utils::Option ChargedCarbon
Allow carbons to have non zero formal charges.
Definition: assigner.hpp:226