Java Code Examples for org.apache.commons.math3.optim.PointVectorValuePair#getValueRef()

The following examples show how to use org.apache.commons.math3.optim.PointVectorValuePair#getValueRef() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MultiStartMultivariateVectorOptimizer.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @return a comparator for sorting the optima.
 */
private Comparator<PointVectorValuePair> getPairComparator() {
    return new Comparator<PointVectorValuePair>() {
        private final RealVector target = new ArrayRealVector(optimizer.getTarget(), false);
        private final RealMatrix weight = optimizer.getWeight();

        public int compare(final PointVectorValuePair o1,
                           final PointVectorValuePair o2) {
            if (o1 == null) {
                return (o2 == null) ? 0 : 1;
            } else if (o2 == null) {
                return -1;
            }
            return Double.compare(weightedResidual(o1),
                                  weightedResidual(o2));
        }

        private double weightedResidual(final PointVectorValuePair pv) {
            final RealVector v = new ArrayRealVector(pv.getValueRef(), false);
            final RealVector r = target.subtract(v);
            return r.dotProduct(weight.operate(r));
        }
    };
}
 
Example 2
Source File: MultiStartMultivariateVectorOptimizer.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @return a comparator for sorting the optima.
 */
private Comparator<PointVectorValuePair> getPairComparator() {
    return new Comparator<PointVectorValuePair>() {
        private final RealVector target = new ArrayRealVector(optimizer.getTarget(), false);
        private final RealMatrix weight = optimizer.getWeight();

        public int compare(final PointVectorValuePair o1,
                           final PointVectorValuePair o2) {
            if (o1 == null) {
                return (o2 == null) ? 0 : 1;
            } else if (o2 == null) {
                return -1;
            }
            return Double.compare(weightedResidual(o1),
                                  weightedResidual(o2));
        }

        private double weightedResidual(final PointVectorValuePair pv) {
            final RealVector v = new ArrayRealVector(pv.getValueRef(), false);
            final RealVector r = target.subtract(v);
            return r.dotProduct(weight.operate(r));
        }
    };
}
 
Example 3
Source File: MultiStartMultivariateVectorOptimizer.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @return a comparator for sorting the optima.
 */
private Comparator<PointVectorValuePair> getPairComparator() {
    return new Comparator<PointVectorValuePair>() {
        private final RealVector target = new ArrayRealVector(optimizer.getTarget(), false);
        private final RealMatrix weight = optimizer.getWeight();

        public int compare(final PointVectorValuePair o1,
                           final PointVectorValuePair o2) {
            if (o1 == null) {
                return (o2 == null) ? 0 : 1;
            } else if (o2 == null) {
                return -1;
            }
            return Double.compare(weightedResidual(o1),
                                  weightedResidual(o2));
        }

        private double weightedResidual(final PointVectorValuePair pv) {
            final RealVector v = new ArrayRealVector(pv.getValueRef(), false);
            final RealVector r = target.subtract(v);
            return r.dotProduct(weight.operate(r));
        }
    };
}
 
Example 4
Source File: MultiStartMultivariateVectorOptimizer.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @return a comparator for sorting the optima.
 */
private Comparator<PointVectorValuePair> getPairComparator() {
    return new Comparator<PointVectorValuePair>() {
        private final RealVector target = new ArrayRealVector(optimizer.getTarget(), false);
        private final RealMatrix weight = optimizer.getWeight();

        public int compare(final PointVectorValuePair o1,
                           final PointVectorValuePair o2) {
            if (o1 == null) {
                return (o2 == null) ? 0 : 1;
            } else if (o2 == null) {
                return -1;
            }
            return Double.compare(weightedResidual(o1),
                                  weightedResidual(o2));
        }

        private double weightedResidual(final PointVectorValuePair pv) {
            final RealVector v = new ArrayRealVector(pv.getValueRef(), false);
            final RealVector r = target.subtract(v);
            return r.dotProduct(weight.operate(r));
        }
    };
}
 
Example 5
Source File: MultiStartMultivariateVectorOptimizer.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @return a comparator for sorting the optima.
 */
private Comparator<PointVectorValuePair> getPairComparator() {
    return new Comparator<PointVectorValuePair>() {
        private final RealVector target = new ArrayRealVector(optimizer.getTarget(), false);
        private final RealMatrix weight = optimizer.getWeight();

        public int compare(final PointVectorValuePair o1,
                           final PointVectorValuePair o2) {
            if (o1 == null) {
                return (o2 == null) ? 0 : 1;
            } else if (o2 == null) {
                return -1;
            }
            return Double.compare(weightedResidual(o1),
                                  weightedResidual(o2));
        }

        private double weightedResidual(final PointVectorValuePair pv) {
            final RealVector v = new ArrayRealVector(pv.getValueRef(), false);
            final RealVector r = target.subtract(v);
            return r.dotProduct(weight.operate(r));
        }
    };
}