/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

package etomica.integrator.mcmove;

import java.io.Serializable;

/**
 * This class is responsible for tracking acceptance statistics for an MCMove.
 * The acceptance ratio and probability can be retrieved.  This class has no 
 * effect on the MCMove.
 *
 * @author Andrew Schultz
 */
public class MCMoveTracker implements Serializable {

    /**
     * Updates statistics regarding the acceptance rate of this move.  This 
     * method should only be called by the Integrator after a move has been
     * accepted or rejected.
     * 
     * @param moveWasAccepted
     *            indicates whether the most recently attempted move was
     *            accepted
     * @param chi
     *            indicates the probability with which the MC move was
     *            accepted.
     */
    public void updateCounts(boolean moveWasAccepted, double chi) {
        nTrials++;
        if (moveWasAccepted)
            nAccept++;
        chiSum += chi > 1 ? 1 : chi;
    }

    /**
     * Returns the fraction of accepted trials of the move associated with 
     * this tracker.
     */
    public double acceptanceRatio() {
        return (nTrials > 0) ? (double) nAccept / nTrials : Double.NaN;
    }


    /**
     * Returns the average probability of accepting the move associated with
     * this tracker.
     */
    public double acceptanceProbability() {
        return ((nTrials > 0) ? chiSum / nTrials : Double.NaN);
    }
    
    protected long nTrials, nAccept;
    protected double chiSum;
    private static final long serialVersionUID = 1L;
}

@@ -239,37 +239,8 @@
 e;%0A%0A
-import java.io.Serializable;%0A
 %0A/**
@@ -486,32 +486,8 @@
 ker 
-implements Serializable 
 %7B%0A%0A 
@@ -1585,16 +1585,104 @@
  %7D%0A    %0A
+    public void reset() %7B%0A        nTrials = nAccept = 0;%0A        chiSum = 0;%0A    %7D%0A    %0A
     prot
@@ -1743,59 +1743,6 @@
 um;%0A
-    private static final long serialVersionUID = 1L;%0A
 %7D%0A

allow tracker to be reset