cleanup and documentation changes

This commit is contained in:
Greg Landrum
2007-11-14 06:09:52 +00:00
parent bd923cd580
commit 3e6cb74075
25 changed files with 389 additions and 397 deletions

View File

@@ -1,6 +1,6 @@
// $Id$
//
// Copyright (C) 2003-2006 Rational Discovery LLC
// Copyright (C) 2003-2007 Rational Discovery LLC
//
// @@ All Rights Reserved @@
//
@@ -8,46 +8,43 @@
#include "MaxMinPicker.h"
#include <RDGeneral/Invariant.h>
#include <RDGeneral/types.h>
#include <RDBoost/Exceptions.h>
#include <cstdlib>
namespace RDPickers {
RDKit::INT_VECT MaxMinPicker::pick(const double *distMat,
unsigned int poolSize, unsigned int pickSize) {
unsigned int poolSize, unsigned int pickSize) const {
CHECK_INVARIANT(distMat, "Invalid Distance Matrix");
CHECK_INVARIANT((poolSize >= pickSize), "pickSize cannot be larger than the poolSize");
RDKit::INT_LIST pool;
RDKit::INT_LIST_I plri, pli;
if(poolSize<pickSize)
throw ValueErrorException("pickSize cannot be larger than the poolSize");
RDKit::INT_VECT picks;
RDKit::INT_VECT_CI pi;
picks.reserve(pickSize);
unsigned int i, j;
unsigned int pick;
// enter the pool into a list so that we can pick out of it easily
for (i = 0; i < poolSize; i++) {
RDKit::INT_LIST pool;
for (unsigned int i = 0; i < poolSize; i++) {
pool.push_back(i);
}
// pick the first entry
pick = rand()%poolSize;
// pick a random entry
unsigned int pick = rand()%poolSize;
// add the pick to the picks
picks.push_back(pick);
// and remove it from the pool
pool.remove(pick);
double minTOi, maxOFmin, dist;
// now pick 1 compound at a time
while (picks.size() < pickSize) {
maxOFmin = 0.0;
for (pli = pool.begin(); pli != pool.end(); pli++) {
i = (*pli);
minTOi = RDKit::MAX_DOUBLE;
for (pi = picks.begin(); pi != picks.end(); pi++) {
j = (*pi);
CHECK_INVARIANT(i!=j,"");
dist = getDistFromLTM(distMat, i, j);
RDKit::INT_LIST_I plri;
double maxOFmin = 0.0;
for (RDKit::INT_LIST_I pli = pool.begin(); pli != pool.end(); ++pli) {
unsigned int i = (*pli);
double minTOi = RDKit::MAX_DOUBLE;
for (RDKit::INT_VECT_CI pi = picks.begin(); pi != picks.end(); ++pi) {
unsigned int j = (*pi);
CHECK_INVARIANT(i!=j,"");
double dist = getDistFromLTM(distMat, i, j);
if (dist < minTOi) {
minTOi = dist;
}
@@ -58,8 +55,7 @@ namespace RDPickers {
plri = pli;
}
}
// now add teh new pick to picks and remove it from the pool
// add the new pick to picks and remove it from the pool
picks.push_back(pick);
pool.erase(plri);
}