public Result run ( Database database , Relation < O > relation , Relation < NumberVector > radrel ) { if ( queries != null ) { throw new AbortException ( "This 'run' method will not use the given query set!" ) ; } // Get a distance and kNN query instance. DistanceQuery < O > distQuery = database . getDistanceQuery ( relation , getDistanceFunction ( ) ) ; RangeQuery < O > rangeQuery = database . getRangeQuery ( distQuery ) ; final DBIDs sample = DBIDUtil . randomSample ( relation . getDBIDs ( ) , sampling , random ) ; FiniteProgress prog = LOG . isVeryVerbose ( ) ? new FiniteProgress ( "kNN queries" , sample . size ( ) , LOG ) : null ; int hash = 0 ; MeanVariance mv = new MeanVariance ( ) ; for ( DBIDIter iditer = sample . iter ( ) ; iditer . valid ( ) ; iditer . advance ( ) ) { double r = radrel . get ( iditer ) . doubleValue ( 0 ) ; DoubleDBIDList rres = rangeQuery . getRangeForDBID ( iditer , r ) ; int ichecksum = 0 ; for ( DBIDIter it = rres . iter ( ) ; it . valid ( ) ; it . advance ( ) ) { ichecksum += DBIDUtil . asInteger ( it ) ; } hash = Util . mixHashCodes ( hash , ichecksum ) ; mv . put ( rres . size ( ) ) ; LOG . incrementProcessed ( prog ) ; } LOG . ensureCompleted ( prog ) ; if ( LOG . isStatistics ( ) ) { LOG . statistics ( "Result hashcode: " + hash ) ; LOG . statistics ( "Mean number of results: " + mv . getMean ( ) + " +- " + mv . getNaiveStddev ( ) ) ; } return null ; }
Run the algorithm with separate radius relation