Displaying differences for changeset
 
display as  

src/java/m/oms/ages/V1_01.java

@@ -38,6 +38,9 @@
 
     public static final String CAL_STARTTIME = "cal_startTime";
     public static final String CAL_ENDTIME = "cal_endTime";
+    
+    public static final String EVAL_STARTTIME = "eva_startTime";
+    public static final String EVAL_ENDTIME = "eva_endTime";
 
     public static final String PAYLOAD = "payload";
     public static final String PROJECT = "project";

src/java/oms/utils/Utils.java

@@ -77,6 +77,49 @@
     /**
      *
      */
+    public static class MNS implements ObjectiveFunction {
+
+        @Override
+        public double calculate(double[] obs, double[] sim, double missing) {
+            if (sim.length != obs.length) {
+                throw new IllegalArgumentException("obs/sim length differ: " + obs.length + "!=" + sim.length);
+            }
+
+            int steps = sim.length;
+            double sum_vd = 0;
+
+            double size = 0;
+            for (int i = 0; i < obs.length; i++) {
+                if (obs[i] != missing) {
+                    sum_vd += obs[i];
+                    size++;
+                }
+            }
+
+            double mean_vd = sum_vd / size;
+
+            double td_vd = 0;
+            double vd_mean = 0;
+            for (int i = 0; i < steps; i++) {
+                if (obs[i] != missing) {
+                    td_vd += Math.abs(obs[i] - sim[i]);
+                    vd_mean += Math.abs(obs[i] - mean_vd);
+                }
+            }
+
+            double r = 1 - (td_vd / vd_mean);
+            return Double.isNaN(r) ? 0.0 : r;
+        }
+
+        @Override
+        public boolean positiveDirection() {
+            return true;
+        }
+    }
+
+    /**
+     *
+     */
     public static class NSLOG1P implements ObjectiveFunction {
 
         @Override