package cs437.som.neighborhood;

import cs437.som.NeighborhoodWidthFunction;

/**
 * Hyperbolic neighborhood width strategy for self-organizing map.
 *
 * <pre>
 * The exact behavior follows the formula:
 *      \frac{w_i}{(t + t_{max})}
 *  where
 *      w_i     is the initial width of the neighborhood
 *      t       is the current iteration
 *      t_{max} is the maximum expected iteration
 * </pre>
 */
public class HyperbolicNeighborhoodWidthFunction implements NeighborhoodWidthFunction {
    private double expectedIterations = 0.0;

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

    public double neighborhoodWidth(int iteration) {
        return expectedIterations / (expectedIterations + iteration);
    }

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

@@ -209,32 +209,58 @@
     
-%5Cfrac%7Bw_i%7D%7B(t + 
+w_0 %5Ccdot (%5Cfrac%7Bw_%7Bfinal%7D%7D%7Bw_0%7D)%5E%5Cfrac%7Bt%7D%7B
 t_%7Bmax%7D
-)
 %7D%0A *
@@ -277,17 +277,19 @@
       w_
-i
+0  
      is 
@@ -296,41 +296,105 @@
 the 
-initial width of the neighborhood
+learning rate at the first iteration%0A *      w_%7Bfinal%7D is the learning rate at the last iteration
 %0A * 
@@ -402,24 +402,31 @@
     t       
+       
 is the curre
@@ -453,16 +453,23 @@
  t_%7Bmax%7D
+       
  is the 
@@ -557,16 +557,24 @@
 Function
+%0A       
  impleme
@@ -649,16 +649,313 @@
 s = 0.0;
+%0A    private double initialWidth;%0A    private double widthRatio;%0A%0A    public HyperbolicNeighborhoodWidthFunction(double initialWidth,%0A                                               double finalWidth) %7B%0A        this.initialWidth = initialWidth;%0A        widthRatio = finalWidth / initialWidth;%0A    %7D
 %0A%0A    pu
@@ -1141,33 +1141,62 @@
  return 
-expectedI
+initialWidth * Math.pow(widthRatio, (i
 teration
 s / (exp
@@ -1191,13 +1191,11 @@
 tion
-s
  / 
-(
 expe
@@ -1212,20 +1212,9 @@
 ions
- + iteration
+)
 );%0A 

Bring HyperbolicNeighborhoodWidthFunction in line with the better hyperbolic function used in HyperbolicLearningRateFunction.