public static DiscordRecords series2BruteForceDiscords ( double [ ] series , Integer windowSize , int discordCollectionSize , SlidingWindowMarkerAlgorithm marker , double nThreshold ) throws Exception { DiscordRecords discords = new DiscordRecords ( ) ; // init new registry to the full length, but mark the end of it // VisitRegistry globalTrackVisitRegistry = new VisitRegistry ( series . length ) ; globalTrackVisitRegistry . markVisited ( series . length - windowSize - 1 , series . length ) ; int discordCounter = 0 ; while ( discords . getSize ( ) < discordCollectionSize ) { LOGGER . debug ( "currently known discords: {} out of {}" , discords . getSize ( ) , discordCollectionSize ) ; // mark start and number of iterations Date start = new Date ( ) ; DiscordRecord bestDiscord = findBestDiscordBruteForce ( series , windowSize , globalTrackVisitRegistry , nThreshold ) ; bestDiscord . setPayload ( "#" + discordCounter ) ; Date end = new Date ( ) ; // if the discord is null we getting out of the search if ( bestDiscord . getNNDistance ( ) == 0.0D || bestDiscord . getPosition ( ) == - 1 ) { LOGGER . debug ( "breaking the outer search loop, discords found: {} last seen discord: {}" + discords . getSize ( ) , bestDiscord ) ; break ; } bestDiscord . setInfo ( "position " + bestDiscord . getPosition ( ) + ", NN distance " + bestDiscord . getNNDistance ( ) + ", elapsed time: " + SAXProcessor . timeToString ( start . getTime ( ) , end . getTime ( ) ) + ", " + bestDiscord . getInfo ( ) ) ; LOGGER . debug ( "{}" , bestDiscord . getInfo ( ) ) ; // collect the result // discords . add ( bestDiscord ) ; // and maintain data structures // marker . markVisited ( globalTrackVisitRegistry , bestDiscord . getPosition ( ) , windowSize ) ; discordCounter ++ ; } // done deal // return discords ; }
Brute force discord search implementation . BRUTE FORCE algorithm .