package cs437.som.neighborhood;

import cs437.som.NeightborhoodWidthFunction;

/**
 * Neighborhood width strategy for self-organizing maps that decays the width
 * linearly as the iterations progress.
 */
public class LinearDecayNeighborhoodWidthFunction implements NeightborhoodWidthFunction {
    private final double initialNeighborhoodWidth;
    private double expectedIterations;

    public LinearDecayNeighborhoodWidthFunction(double initialWidth) {
        initialNeighborhoodWidth = initialWidth;
    }

    public void setExpectedIterations(int expectedIterations) {
        this.expectedIterations = expectedIterations;
    }

    public double neighborhoodWidth(int iteration) {
        return initialNeighborhoodWidth * (1.0 - (iteration / expectedIterations));
    }

    @Override
    public String toString() {
        return "LinearDecayNeighborhoodWidthFunction";
    }
}

@@ -194,16 +194,298 @@
 ogress.%0A
+ *%0A * The exact behavior follows the formula:%0A *      w_i * (1 - (-t / t_max))%0A *  where%0A *      w_i   is the initial width of the neighborhood%0A *      e     is the base of the natural logarithm%0A *      t     is the current iteration%0A *      t_max is the maximum expected iteration%0A
  */%0Apubl
@@ -658,16 +658,22 @@
 erations
+ = 0.0
 ;%0A%0A    p

Add formula comment to lin. decay NW class.