@@ -0,0 +1,2455 @@
+package org.opentripplanner.profile;%0A%0A/**%0A * A weighting function, expressing how influential something is according to its distance from you.%0A * A functional interface (with a single function, so it can be defined using Java 8 shorthand).%0A */%0Apublic abstract class WeightingFunction %7B%0A%0A    public abstract double getWeight (double x);%0A%0A    public double applyWeight (double n, double x) %7B%0A        return n * getWeight(x);%0A    %7D%0A%0A    /**%0A     * The logistic function, a commonly used sigmoid (s-shaped function).%0A     * Basically a step function with a smooth rolloff.%0A     * Positive values of k cause the function to increase from zero to one, negative values will be inverted.%0A     * %3Cbr%3E%0A     * k=-1 gives a rolloff over an interval of ~10 minutes%3Cbr%3E%0A     * k=-0.5 gives a rolloff over an interval of ~20 minutes%3Cbr%3E%0A     * k=-2 contracts the rolloff interval to ~5 minutes%3Cbr%3E%0A     */%0A    public static final class Logistic extends WeightingFunction %7B%0A%0A        double x0;  // cutoff point%0A        double k;   // steepness of the curve. negative%0A%0A        public Logistic (double cutoff, double steepness) %7B%0A            this.x0 = cutoff;%0A            this.k = steepness;%0A        %7D%0A%0A        @Override%0A        public double getWeight (double x) %7B%0A            return 1 / (1 + Math.exp( -k * (x - x0)));%0A        %7D%0A%0A    %7D%0A%0A    /**%0A     * The typical hard cutoff used to select all objects within an isochrone curve.%0A     * WARNING: This can have nefarious effects on accessibility indicators when the opportunity density surface%0A     * contains steep gradients (e.g. Manhattan).%0A     * Any misalignment in the before/after travel time surfaces near these gradients (for example due to street length%0A     * roundoff errors) will create a sharp bidirectional fringe x0 minutes away in the resulting%0A     * accessibility indicator surface, frequently in outlying low-accessibility areas where the echo will overwhelm%0A     * the local indicator value, showing impossible decreases in accessibility in a clearly superior network.%0A     */%0A    public static class SharpCutoff extends WeightingFunction %7B%0A%0A        double x0; // the cutoff point%0A%0A        public SharpCutoff(double x0) %7B%0A            this.x0 = x0;%0A        %7D%0A%0A        @Override%0A        public double getWeight(double x) %7B%0A            return (x %3C x0) ? 1 : 0;%0A        %7D%0A%0A        @Override%0A        public double applyWeight (double n, double x) %7B%0A            return (n %3C x0) ? n : 0;%0A        %7D%0A%0A    %7D%0A%0A%7D%0A

add sigmoid (logistic) weighting functon