145 unsigned int pickSize,
147 int seed,
double &threshold)
const {
152 if (poolSize < pickSize) {
158 unsigned int memsize = (
unsigned int)(poolSize *
sizeof(
MaxMinPickInfo));
160 memset(pinfo, 0, memsize);
162 picks.reserve(pickSize);
163 unsigned int picked = 0;
164 unsigned int pick = 0;
167 if (firstPicks.empty()) {
169 typedef boost::mt19937 rng_type;
170 typedef boost::uniform_int<> distrib_type;
171 typedef boost::variate_generator<rng_type &, distrib_type> source_type;
173 distrib_type dist(0, poolSize - 1);
175 generator.seed(
static_cast<rng_type::result_type
>(seed));
177 generator.seed(std::random_device()());
179 source_type randomSource(generator, dist);
180 pick = randomSource();
182 picks.push_back(
pick);
188 for (RDKit::INT_VECT::const_iterator pIdx = firstPicks.begin();
189 pIdx != firstPicks.end(); ++pIdx) {
190 pick =
static_cast<unsigned int>(*pIdx);
191 if (
pick >= poolSize) {
195 picks.push_back(
pick);
201 if (picked >= pickSize) {
207 unsigned int pool_list = 0;
208 unsigned int *prev = &pool_list;
210 for (
unsigned int i = 0; i < poolSize; i++) {
211 if (pinfo[i].picks == 0) {
213 prev = &pinfo[i].
next;
218 unsigned int poolIdx;
219 unsigned int pickIdx;
226 pinfo[poolIdx].
dist_bound = func(poolIdx, pickIdx);
227 pinfo[poolIdx].
picks = 1;
228 prev = &pinfo[poolIdx].
next;
229 }
while (*prev != 0);
232 double maxOFmin = -1.0;
233 double tmpThreshold = -1.0;
234 while (picked < pickSize) {
235 unsigned int *pick_prev =
nullptr;
241 if (minTOi > maxOFmin) {
242 unsigned int pi = pinfo[poolIdx].
picks;
243 while (pi < picked) {
244 unsigned int picki = picks[pi];
246 double dist = func(poolIdx, picki);
248 if (dist <= minTOi) {
250 if (minTOi <= maxOFmin) {
256 pinfo[poolIdx].
picks = pi;
257 if (minTOi > maxOFmin) {
263 prev = &pinfo[poolIdx].
next;
264 }
while (*prev != 0);
267 if (maxOFmin <= threshold && threshold >= 0.0) {
270 tmpThreshold = maxOFmin;
273 picks.push_back(
pick);
277 threshold = tmpThreshold;
RDKit::INT_VECT pick(const double *distMat, unsigned int poolSize, unsigned int pickSize, RDKit::INT_VECT firstPicks, int seed=-1) const
Contains the implementation for the MaxMin diversity picker.