ABSDIFFLOG.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;
/**
*
*/
class ABSDIFFLOG extends ObjFunc {
@Override
public String name() {
return "Absolute Diff LOG";
}
@Override
public double eval(double[] obs, double[] sim, double missing) {
checkArrays(obs, sim);
double abs = 0;
for (int i = 0; i < obs.length; i++) {
if (obs[i] > missing) {
double measured = obs[i];
double simulated = sim[i];
if (measured == 0) {
measured = 0.0000001;
} else if (measured < 0) {
throw new RuntimeException("Error on Absolute Difference (log): Observed value is negative.");
}
if (simulated == 0) {
simulated = 0.0000001;
} else if (simulated < 0) {
throw new RuntimeException("Error on Absolute Difference (log): Simulated value is negative.");
}
abs += Math.abs(Math.log(measured) - Math.log(simulated));
}
}
return abs;
}
@Override
public int direction() {
return -1;
}
@Override
public int optimum() {
return 0;
}
}