CoolingSchedule.java :  » Natural-Language-Processing » Stanford-Chinese-Word-Segmenter » edu » stanford » nlp » sequences » Java Open Source

Java Open Source » Natural Language Processing » Stanford Chinese Word Segmenter 
Stanford Chinese Word Segmenter » edu » stanford » nlp » sequences » CoolingSchedule.java
package edu.stanford.nlp.sequences;

/**
 * @author grenager
 *         Date: Dec 14, 2004
 */
public abstract class CoolingSchedule {

  public abstract int numIterations();
  public abstract double getTemperature(int iteration);

  public static CoolingSchedule getExponentialSchedule(final double start, final double rate, final int numIterations) {
    return new CoolingSchedule() {
      public int numIterations() {
        return numIterations;
      }
      public double getTemperature(int iteration) {
        return start * Math.pow(rate, (double) iteration);
      }
    };
  }

  public static CoolingSchedule getLinearSchedule(final double start, final int numIterations) {
    return new CoolingSchedule() {
      final double rate = start / (double)numIterations;
      public int numIterations() {
        return numIterations+1; // will hit zero on the last one
      }
      public double getTemperature(int iteration) {
        return start - rate*(double)iteration;
      }
    };
  }

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.