10 #ifndef RGROUP_SCORE_H
11 #define RGROUP_SCORE_H
31 for (
unsigned long size :
sizes) {
46 size_t value(
const std::vector<size_t> &p)
const {
48 for (
size_t i = 0; i < p.size(); ++i) {
62 size_t max_index_of_row =
sizes[rowToIncrement] - 1;
63 if (
permutation[rowToIncrement] > max_index_of_row) {
77 double matchScore(
const std::vector<size_t> &permutation,
78 const std::vector<std::vector<RGroupMatch>> &matches,
79 const std::set<int> &labels);
84 return d_saved.permutation;
91 void breakTies(
const std::vector<std::vector<RGroupMatch>> &matches,
92 const std::set<int> &labels,
93 const std::unique_ptr<CartesianProduct> &iterator,
94 const std::chrono::steady_clock::time_point &t0,
104 void restoreInitialState() { d_current = d_initial; }
107 std::vector<std::map<std::string, unsigned int>> matchSetVect;
108 std::map<std::set<int>,
size_t> linkerMatchSet;
118 void computeTieBreakingCriteria(
119 const std::vector<std::vector<RGroupMatch>> &matches,
120 const std::vector<int> &orderedLabels, std::vector<int> &heavyCounts) {
125 "permutation.size() should be <= matches.size()");
126 size_t offset = matches.size() - permutation.size();
130 for (
int label : orderedLabels) {
131 for (
size_t m = 0;
m < permutation.size(); ++
m) {
139 const auto &match = matches[
m + offset][permutation[
m]];
140 auto rg = match.rgroups.find(label);
141 if (rg != match.rgroups.end() && !rg->second->is_hydrogen) {
142 if (label < 0 && heavyCounts.at(i) == 0) {
144 }
else if (label > 0) {
145 ++numMatchedUserRGroups;
155 int numAddedRGroups = 0;
156 int numMatchedUserRGroups = 0;
157 std::map<int, int> heavyCountPerLabel;
158 std::map<int, RLabelData> labelDataMap;
159 std::vector<size_t> permutation;
161 double d_bestScore = 0.0;
169 std::deque<State> d_store;
#define PRECONDITION(expr, mess)
void pushTieToStore(const std::vector< size_t > &permutation)
store the passed tied permutation for subsequent processing
void startProcessing()
called when process() starts to initialize State
void setBestPermutation(const std::vector< size_t > &permutation, double score)
set the passed permutation and score as the best one
void breakTies(const std::vector< std::vector< RGroupMatch >> &matches, const std::set< int > &labels, const std::unique_ptr< CartesianProduct > &iterator, const std::chrono::steady_clock::time_point &t0, double timeout)
find the best permutation across the tied ones that were stored
void clearTieStore()
clear all stored tied permutations
RGroupScorer(const std::vector< std::vector< size_t >> &permutations, double score)
const std::vector< size_t > & getBestPermutation() const
return the best permutation found so far
double matchScore(const std::vector< size_t > &permutation, const std::vector< std::vector< RGroupMatch >> &matches, const std::set< int > &labels)
score the passed permutation of matches
size_t tieStoreSize() const
number of stored tied permutations
double getBestScore() const
return the best score found so far
#define RDKIT_RGROUPDECOMPOSITION_EXPORT
iterate through all possible permutations of the rgroups
std::vector< size_t > sizes
std::deque< size_t > bases
size_t value(const std::vector< size_t > &p) const
CartesianProduct(const std::vector< size_t > &inputSizes)
bool increment(size_t rowToIncrement)
std::vector< size_t > permutation