<p>The problem is that the query tree is provided as an argument every time Search(Tree* queryTree, ...) method is called, so we can not track when it is necessary to reset the stats there. We don't know where that query tree comes from... if it is a new one, or was previously used for something different...</p>

<p>This is what I understand, let me know if you agree:</p>

<ul>
<li><p>The problem appears when we use the same query tree with different reference sets. I mean, when reusing outdated stats in a different scenario.</p></li>
<li><p>When we do monochromatic search, the reference set and query set are always the same, so we never reach the erroneous situation. So, treeNeedsReset, as used now, is irrelevant. I mean, NeighborSearch class reset the stats in the reference tree every time we repeat a monochromatic search. It is not necessary, because the reference set never changes. If it changes, a new tree is built, with new stats, so there isn't any problem.</p></li>
<li><p>On the other hand, we should reset stats when using the same query tree with different reference datasets. But we don't know that information, because the query tree is not part of the state of NeighborSearch class. It is provided as an argument every time Search(Tree* queryTree, ...) method is called, so we can not track when it is necessary to reset the stats there. We don't know where that query tree comes from... if it is a new one, or was previously used for something different...</p></li>
</ul>

<p>Because of that, I think we should take one of the approaches:</p>

<ul>
<li>allways reset the provided query tree. This way we are sure everything is ok, but slows down the calculation a bit.</li>
<li>never reset, and add a comment mentioned this, so the user can decide if it is necessary.</li>
</ul>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">&mdash;<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/mlpack/mlpack/issues/672#issuecomment-223592697">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe/AJ4bFEplA3l5Id-pUkAXn4ufi6ypf_I5ks5qIDj7gaJpZM4Itiy7">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AJ4bFJgAA7LFhzytfT5mjgmHsd1R1E87ks5qIDj7gaJpZM4Itiy7.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/mlpack/mlpack/issues/672#issuecomment-223592697"></link>
  <meta itemprop="name" content="View Issue"></meta>
</div>
<meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>