The following document contains the results of PMD's CPD 6.55.0.

Duplications

File Line
org/hipparchus/optim/nonlinear/vector/leastsquares/GaussNewtonOptimizer.java 206
org/hipparchus/optim/nonlinear/vector/leastsquares/SequentialGaussNewtonOptimizer.java 373
", formNormalEquations=" + formNormalEquations +
                '}';
    }

    /**
     * Compute the normal matrix, J<sup>T</sup>J.
     *
     * @param jacobian  the m by n jacobian matrix, J. Input.
     * @param residuals the m by 1 residual vector, r. Input.
     * @return  the n by n normal matrix and  the n by 1 J<sup>Tr vector.
     */
    private static Pair<RealMatrix, RealVector> computeNormalMatrix(final RealMatrix jacobian,
                                                                    final RealVector residuals) {
        //since the normal matrix is symmetric, we only need to compute half of it.
        final int nR = jacobian.getRowDimension();
        final int nC = jacobian.getColumnDimension();
        //allocate space for return values
        final RealMatrix normal = MatrixUtils.createRealMatrix(nC, nC);
        final RealVector jTr = new ArrayRealVector(nC);
        //for each measurement
        for (int i = 0; i < nR; ++i) {
            //compute JTr for measurement i
            for (int j = 0; j < nC; j++) {
                jTr.setEntry(j, jTr.getEntry(j) +
                        residuals.getEntry(i) * jacobian.getEntry(i, j));
            }

            // add the the contribution to the normal matrix for measurement i
            for (int k = 0; k < nC; ++k) {
                //only compute the upper triangular part
                for (int l = k; l < nC; ++l) {
                    normal.setEntry(k, l, normal.getEntry(k, l) +
                            jacobian.getEntry(i, k) * jacobian.getEntry(i, l));
                }
            }
        }
        //copy the upper triangular part to the lower triangular part.
        for (int i = 0; i < nC; i++) {
            for (int j = 0; j < i; j++) {
                normal.setEntry(i, j, normal.getEntry(j, i));
            }
        }
        return new Pair<RealMatrix, RealVector>(normal, jTr);
    }
File Line
org/hipparchus/optim/linear/LinearConstraint.java 199
org/hipparchus/optim/linear/LinearObjectiveFunction.java 130
Double.valueOf(value).hashCode() ^
            coefficients.hashCode();
    }

    /**
     * Serialize the instance.
     * @param oos stream where object should be written
     * @throws IOException if object cannot be written to stream
     */
    private void writeObject(ObjectOutputStream oos)
        throws IOException {
        oos.defaultWriteObject();
        final int n = coefficients.getDimension();
        oos.writeInt(n);
        for (int i = 0; i < n; ++i) {
            oos.writeDouble(coefficients.getEntry(i));
        }
    }

    /**
     * Deserialize the instance.
     * @param ois stream from which the object should be read
     * @throws ClassNotFoundException if a class in the stream cannot be found
     * @throws IOException if object cannot be read from the stream
     */
    private void readObject(ObjectInputStream ois)
      throws ClassNotFoundException, IOException {
        ois.defaultReadObject();

        // read the vector data
        final int n = ois.readInt();
        final double[] data = new double[n];
        for (int i = 0; i < n; ++i) {
            data[i] = ois.readDouble();
        }

        try {
            // create the instance
            ArrayRealVector vector = new ArrayRealVector(data, false);
            final java.lang.reflect.Field f = getClass().getDeclaredField("coefficients");
            f.setAccessible(true); // NOPMD
            f.set(this, vector);
        } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
            IOException ioe = new IOException();
            ioe.initCause(e);
            throw ioe;
        }

    }
}
File Line
org/hipparchus/optim/nonlinear/vector/constrained/SQPOptimizerS.java 175
org/hipparchus/optim/nonlinear/vector/constrained/SQPOptimizerS.java 217
while ((alfaPenalty - currentPenalty) >= getSettings().getMu() * alpha * currentPenaltyGrad &&
                    search < getSettings().getMaxLineSearchIteration()) {
                double alfaStar = -0.5 * alpha * alpha * currentPenaltyGrad / (-alpha * currentPenaltyGrad + alfaPenalty - currentPenalty);


                alpha = FastMath.max(getSettings().getB() * alpha, FastMath.min(1.0, alfaStar));
                alphaF = this.getObj().value(x.add(dx.mapMultiply(alpha)));
                alfaPenalty = penaltyFunction(alphaF, alpha, x, y, dx, dy.subtract(y), r);
                search = search + 1;

            }
File Line
org/hipparchus/optim/nonlinear/vector/constrained/SQPOptimizerGM.java 443
org/hipparchus/optim/nonlinear/vector/constrained/SQPOptimizerS.java 659
RealVector y = y1.mapMultiply(theta).add(oldH.operate(s).mapMultiply(1.0 - theta));

        RealMatrix firstTerm = y.outerProduct(y).scalarMultiply(1.0 / s.dotProduct(y));
        RealMatrix secondTerm = oldH1.multiply(s.outerProduct(s)).multiply(oldH);
        double thirtTerm = s.dotProduct(oldH1.operate(s));
        RealMatrix Hnew = oldH1.add(firstTerm).subtract(secondTerm.scalarMultiply(1.0 / thirtTerm));
        //RESET HESSIAN IF NOT POSITIVE DEFINITE
        EigenDecompositionSymmetric dsX = new EigenDecompositionSymmetric(Hnew);
        double min = new ArrayRealVector(dsX.getEigenvalues()).getMinValue();
        if (new ArrayRealVector(dsX.getEigenvalues()).getMinValue() < 0) {

Back to top

Version: 3.1. Last Published: 2024-04-02.

Reflow Maven skin maintained by Olivier Lamy.