FLF.java [src/csip/cosu] Revision:   Date:
/*
 * $Id$
 *
 * This file is part of the Cloud Services Integration Platform (CSIP),
 * a Model-as-a-Service framework, API and application suite.
 *
 * 2012-2022, Olaf David and others, OMSLab, Colorado State University.
 *
 * OMSLab licenses this file to you under the MIT license.
 * See the LICENSE file in the project root for more information.
 */
package csip.cosu;

/**
 * Fenicia low flow
 */
class FLF extends ObjFunc {

  @Override
  public String name() {
    return "Fenicia low flow";
  }


  @Override
  public double eval(double[] obs, double[] sim, double missing) {
    checkArrays(obs, sim);
    int count = 0;
    double flf = 0;
    for (int i = 0; i < obs.length; i++) {
      if (obs[i] > missing) {
        if (sim[i] != 0 && obs[i] != 0) {
          count++;
          flf += (Math.log(sim[i]) - Math.log(obs[i])) * (Math.log(sim[i]) - Math.log(obs[i]));
        }
      }
    }
    return flf / count;
  }


  @Override
  public int direction() {
    return -1;
  }


  @Override
  public int optimum() {
    return 0;
  }
  
}