Java Code Examples for org.apache.commons.math3.exception.util.LocalizedFormats#EQUAL_VERTICES_IN_SIMPLEX

The following examples show how to use org.apache.commons.math3.exception.util.LocalizedFormats#EQUAL_VERTICES_IN_SIMPLEX . 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: AbstractSimplex.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * The start configuration for simplex is built from a box parallel to
 * the canonical axes of the space. The simplex is the subset of vertices
 * of a box parallel to the canonical axes. It is built as the path followed
 * while traveling from one vertex of the box to the diagonally opposite
 * vertex moving only along the box edges. The first vertex of the box will
 * be located at the start point of the optimization.
 * As an example, in dimension 3 a simplex has 4 vertices. Setting the
 * steps to (1, 10, 2) and the start point to (1, 1, 1) would imply the
 * start simplex would be: { (1, 1, 1), (2, 1, 1), (2, 11, 1), (2, 11, 3) }.
 * The first vertex would be set to the start point at (1, 1, 1) and the
 * last vertex would be set to the diagonally opposite vertex at (2, 11, 3).
 *
 * @param steps Steps along the canonical axes representing box edges. They
 * may be negative but not zero.
 * @throws NullArgumentException if {@code steps} is {@code null}.
 * @throws ZeroException if one of the steps is zero.
 */
protected AbstractSimplex(final double[] steps) {
    if (steps == null) {
        throw new NullArgumentException();
    }
    if (steps.length == 0) {
        throw new ZeroException();
    }
    dimension = steps.length;

    // Only the relative position of the n final vertices with respect
    // to the first one are stored.
    startConfiguration = new double[dimension][dimension];
    for (int i = 0; i < dimension; i++) {
        final double[] vertexI = startConfiguration[i];
        for (int j = 0; j < i + 1; j++) {
            if (steps[j] == 0) {
                throw new ZeroException(LocalizedFormats.EQUAL_VERTICES_IN_SIMPLEX);
            }
            System.arraycopy(steps, 0, vertexI, 0, j + 1);
        }
    }
}
 
Example 2
Source File: AbstractSimplex.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * The start configuration for simplex is built from a box parallel to
 * the canonical axes of the space. The simplex is the subset of vertices
 * of a box parallel to the canonical axes. It is built as the path followed
 * while traveling from one vertex of the box to the diagonally opposite
 * vertex moving only along the box edges. The first vertex of the box will
 * be located at the start point of the optimization.
 * As an example, in dimension 3 a simplex has 4 vertices. Setting the
 * steps to (1, 10, 2) and the start point to (1, 1, 1) would imply the
 * start simplex would be: { (1, 1, 1), (2, 1, 1), (2, 11, 1), (2, 11, 3) }.
 * The first vertex would be set to the start point at (1, 1, 1) and the
 * last vertex would be set to the diagonally opposite vertex at (2, 11, 3).
 *
 * @param steps Steps along the canonical axes representing box edges. They
 * may be negative but not zero.
 * @throws NullArgumentException if {@code steps} is {@code null}.
 * @throws ZeroException if one of the steps is zero.
 */
protected AbstractSimplex(final double[] steps) {
    if (steps == null) {
        throw new NullArgumentException();
    }
    if (steps.length == 0) {
        throw new ZeroException();
    }
    dimension = steps.length;

    // Only the relative position of the n final vertices with respect
    // to the first one are stored.
    startConfiguration = new double[dimension][dimension];
    for (int i = 0; i < dimension; i++) {
        final double[] vertexI = startConfiguration[i];
        for (int j = 0; j < i + 1; j++) {
            if (steps[j] == 0) {
                throw new ZeroException(LocalizedFormats.EQUAL_VERTICES_IN_SIMPLEX);
            }
            System.arraycopy(steps, 0, vertexI, 0, j + 1);
        }
    }
}
 
Example 3
Source File: AbstractSimplex.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * The start configuration for simplex is built from a box parallel to
 * the canonical axes of the space. The simplex is the subset of vertices
 * of a box parallel to the canonical axes. It is built as the path followed
 * while traveling from one vertex of the box to the diagonally opposite
 * vertex moving only along the box edges. The first vertex of the box will
 * be located at the start point of the optimization.
 * As an example, in dimension 3 a simplex has 4 vertices. Setting the
 * steps to (1, 10, 2) and the start point to (1, 1, 1) would imply the
 * start simplex would be: { (1, 1, 1), (2, 1, 1), (2, 11, 1), (2, 11, 3) }.
 * The first vertex would be set to the start point at (1, 1, 1) and the
 * last vertex would be set to the diagonally opposite vertex at (2, 11, 3).
 *
 * @param steps Steps along the canonical axes representing box edges. They
 * may be negative but not zero.
 * @throws NullArgumentException if {@code steps} is {@code null}.
 * @throws ZeroException if one of the steps is zero.
 */
protected AbstractSimplex(final double[] steps) {
    if (steps == null) {
        throw new NullArgumentException();
    }
    if (steps.length == 0) {
        throw new ZeroException();
    }
    dimension = steps.length;

    // Only the relative position of the n final vertices with respect
    // to the first one are stored.
    startConfiguration = new double[dimension][dimension];
    for (int i = 0; i < dimension; i++) {
        final double[] vertexI = startConfiguration[i];
        for (int j = 0; j < i + 1; j++) {
            if (steps[j] == 0) {
                throw new ZeroException(LocalizedFormats.EQUAL_VERTICES_IN_SIMPLEX);
            }
            System.arraycopy(steps, 0, vertexI, 0, j + 1);
        }
    }
}
 
Example 4
Source File: AbstractSimplex.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * The start configuration for simplex is built from a box parallel to
 * the canonical axes of the space. The simplex is the subset of vertices
 * of a box parallel to the canonical axes. It is built as the path followed
 * while traveling from one vertex of the box to the diagonally opposite
 * vertex moving only along the box edges. The first vertex of the box will
 * be located at the start point of the optimization.
 * As an example, in dimension 3 a simplex has 4 vertices. Setting the
 * steps to (1, 10, 2) and the start point to (1, 1, 1) would imply the
 * start simplex would be: { (1, 1, 1), (2, 1, 1), (2, 11, 1), (2, 11, 3) }.
 * The first vertex would be set to the start point at (1, 1, 1) and the
 * last vertex would be set to the diagonally opposite vertex at (2, 11, 3).
 *
 * @param steps Steps along the canonical axes representing box edges. They
 * may be negative but not zero.
 * @throws NullArgumentException if {@code steps} is {@code null}.
 * @throws ZeroException if one of the steps is zero.
 */
protected AbstractSimplex(final double[] steps) {
    if (steps == null) {
        throw new NullArgumentException();
    }
    if (steps.length == 0) {
        throw new ZeroException();
    }
    dimension = steps.length;

    // Only the relative position of the n final vertices with respect
    // to the first one are stored.
    startConfiguration = new double[dimension][dimension];
    for (int i = 0; i < dimension; i++) {
        final double[] vertexI = startConfiguration[i];
        for (int j = 0; j < i + 1; j++) {
            if (steps[j] == 0) {
                throw new ZeroException(LocalizedFormats.EQUAL_VERTICES_IN_SIMPLEX);
            }
            System.arraycopy(steps, 0, vertexI, 0, j + 1);
        }
    }
}
 
Example 5
Source File: AbstractSimplex.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * The start configuration for simplex is built from a box parallel to
 * the canonical axes of the space. The simplex is the subset of vertices
 * of a box parallel to the canonical axes. It is built as the path followed
 * while traveling from one vertex of the box to the diagonally opposite
 * vertex moving only along the box edges. The first vertex of the box will
 * be located at the start point of the optimization.
 * As an example, in dimension 3 a simplex has 4 vertices. Setting the
 * steps to (1, 10, 2) and the start point to (1, 1, 1) would imply the
 * start simplex would be: { (1, 1, 1), (2, 1, 1), (2, 11, 1), (2, 11, 3) }.
 * The first vertex would be set to the start point at (1, 1, 1) and the
 * last vertex would be set to the diagonally opposite vertex at (2, 11, 3).
 *
 * @param steps Steps along the canonical axes representing box edges. They
 * may be negative but not zero.
 * @throws NullArgumentException if {@code steps} is {@code null}.
 * @throws ZeroException if one of the steps is zero.
 */
protected AbstractSimplex(final double[] steps) {
    if (steps == null) {
        throw new NullArgumentException();
    }
    if (steps.length == 0) {
        throw new ZeroException();
    }
    dimension = steps.length;

    // Only the relative position of the n final vertices with respect
    // to the first one are stored.
    startConfiguration = new double[dimension][dimension];
    for (int i = 0; i < dimension; i++) {
        final double[] vertexI = startConfiguration[i];
        for (int j = 0; j < i + 1; j++) {
            if (steps[j] == 0) {
                throw new ZeroException(LocalizedFormats.EQUAL_VERTICES_IN_SIMPLEX);
            }
            System.arraycopy(steps, 0, vertexI, 0, j + 1);
        }
    }
}
 
Example 6
Source File: AbstractSimplex.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * The start configuration for simplex is built from a box parallel to
 * the canonical axes of the space. The simplex is the subset of vertices
 * of a box parallel to the canonical axes. It is built as the path followed
 * while traveling from one vertex of the box to the diagonally opposite
 * vertex moving only along the box edges. The first vertex of the box will
 * be located at the start point of the optimization.
 * As an example, in dimension 3 a simplex has 4 vertices. Setting the
 * steps to (1, 10, 2) and the start point to (1, 1, 1) would imply the
 * start simplex would be: { (1, 1, 1), (2, 1, 1), (2, 11, 1), (2, 11, 3) }.
 * The first vertex would be set to the start point at (1, 1, 1) and the
 * last vertex would be set to the diagonally opposite vertex at (2, 11, 3).
 *
 * @param steps Steps along the canonical axes representing box edges. They
 * may be negative but not zero.
 * @throws NullArgumentException if {@code steps} is {@code null}.
 * @throws ZeroException if one of the steps is zero.
 */
protected AbstractSimplex(final double[] steps) {
    if (steps == null) {
        throw new NullArgumentException();
    }
    if (steps.length == 0) {
        throw new ZeroException();
    }
    dimension = steps.length;

    // Only the relative position of the n final vertices with respect
    // to the first one are stored.
    startConfiguration = new double[dimension][dimension];
    for (int i = 0; i < dimension; i++) {
        final double[] vertexI = startConfiguration[i];
        for (int j = 0; j < i + 1; j++) {
            if (steps[j] == 0) {
                throw new ZeroException(LocalizedFormats.EQUAL_VERTICES_IN_SIMPLEX);
            }
            System.arraycopy(steps, 0, vertexI, 0, j + 1);
        }
    }
}
 
Example 7
Source File: AbstractSimplex.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * The start configuration for simplex is built from a box parallel to
 * the canonical axes of the space. The simplex is the subset of vertices
 * of a box parallel to the canonical axes. It is built as the path followed
 * while traveling from one vertex of the box to the diagonally opposite
 * vertex moving only along the box edges. The first vertex of the box will
 * be located at the start point of the optimization.
 * As an example, in dimension 3 a simplex has 4 vertices. Setting the
 * steps to (1, 10, 2) and the start point to (1, 1, 1) would imply the
 * start simplex would be: { (1, 1, 1), (2, 1, 1), (2, 11, 1), (2, 11, 3) }.
 * The first vertex would be set to the start point at (1, 1, 1) and the
 * last vertex would be set to the diagonally opposite vertex at (2, 11, 3).
 *
 * @param steps Steps along the canonical axes representing box edges. They
 * may be negative but not zero.
 * @throws NullArgumentException if {@code steps} is {@code null}.
 * @throws ZeroException if one of the steps is zero.
 */
protected AbstractSimplex(final double[] steps) {
    if (steps == null) {
        throw new NullArgumentException();
    }
    if (steps.length == 0) {
        throw new ZeroException();
    }
    dimension = steps.length;

    // Only the relative position of the n final vertices with respect
    // to the first one are stored.
    startConfiguration = new double[dimension][dimension];
    for (int i = 0; i < dimension; i++) {
        final double[] vertexI = startConfiguration[i];
        for (int j = 0; j < i + 1; j++) {
            if (steps[j] == 0) {
                throw new ZeroException(LocalizedFormats.EQUAL_VERTICES_IN_SIMPLEX);
            }
            System.arraycopy(steps, 0, vertexI, 0, j + 1);
        }
    }
}
 
Example 8
Source File: AbstractSimplex.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * The start configuration for simplex is built from a box parallel to
 * the canonical axes of the space. The simplex is the subset of vertices
 * of a box parallel to the canonical axes. It is built as the path followed
 * while traveling from one vertex of the box to the diagonally opposite
 * vertex moving only along the box edges. The first vertex of the box will
 * be located at the start point of the optimization.
 * As an example, in dimension 3 a simplex has 4 vertices. Setting the
 * steps to (1, 10, 2) and the start point to (1, 1, 1) would imply the
 * start simplex would be: { (1, 1, 1), (2, 1, 1), (2, 11, 1), (2, 11, 3) }.
 * The first vertex would be set to the start point at (1, 1, 1) and the
 * last vertex would be set to the diagonally opposite vertex at (2, 11, 3).
 *
 * @param steps Steps along the canonical axes representing box edges. They
 * may be negative but not zero.
 * @throws NullArgumentException if {@code steps} is {@code null}.
 * @throws ZeroException if one of the steps is zero.
 */
protected AbstractSimplex(final double[] steps) {
    if (steps == null) {
        throw new NullArgumentException();
    }
    if (steps.length == 0) {
        throw new ZeroException();
    }
    dimension = steps.length;

    // Only the relative position of the n final vertices with respect
    // to the first one are stored.
    startConfiguration = new double[dimension][dimension];
    for (int i = 0; i < dimension; i++) {
        final double[] vertexI = startConfiguration[i];
        for (int j = 0; j < i + 1; j++) {
            if (steps[j] == 0) {
                throw new ZeroException(LocalizedFormats.EQUAL_VERTICES_IN_SIMPLEX);
            }
            System.arraycopy(steps, 0, vertexI, 0, j + 1);
        }
    }
}
 
Example 9
Source File: AbstractSimplex.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * The start configuration for simplex is built from a box parallel to
 * the canonical axes of the space. The simplex is the subset of vertices
 * of a box parallel to the canonical axes. It is built as the path followed
 * while traveling from one vertex of the box to the diagonally opposite
 * vertex moving only along the box edges. The first vertex of the box will
 * be located at the start point of the optimization.
 * As an example, in dimension 3 a simplex has 4 vertices. Setting the
 * steps to (1, 10, 2) and the start point to (1, 1, 1) would imply the
 * start simplex would be: { (1, 1, 1), (2, 1, 1), (2, 11, 1), (2, 11, 3) }.
 * The first vertex would be set to the start point at (1, 1, 1) and the
 * last vertex would be set to the diagonally opposite vertex at (2, 11, 3).
 *
 * @param steps Steps along the canonical axes representing box edges. They
 * may be negative but not zero.
 * @throws NullArgumentException if {@code steps} is {@code null}.
 * @throws ZeroException if one of the steps is zero.
 */
protected AbstractSimplex(final double[] steps) {
    if (steps == null) {
        throw new NullArgumentException();
    }
    if (steps.length == 0) {
        throw new ZeroException();
    }
    dimension = steps.length;

    // Only the relative position of the n final vertices with respect
    // to the first one are stored.
    startConfiguration = new double[dimension][dimension];
    for (int i = 0; i < dimension; i++) {
        final double[] vertexI = startConfiguration[i];
        for (int j = 0; j < i + 1; j++) {
            if (steps[j] == 0) {
                throw new ZeroException(LocalizedFormats.EQUAL_VERTICES_IN_SIMPLEX);
            }
            System.arraycopy(steps, 0, vertexI, 0, j + 1);
        }
    }
}
 
Example 10
Source File: AbstractSimplex.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * The start configuration for simplex is built from a box parallel to
 * the canonical axes of the space. The simplex is the subset of vertices
 * of a box parallel to the canonical axes. It is built as the path followed
 * while traveling from one vertex of the box to the diagonally opposite
 * vertex moving only along the box edges. The first vertex of the box will
 * be located at the start point of the optimization.
 * As an example, in dimension 3 a simplex has 4 vertices. Setting the
 * steps to (1, 10, 2) and the start point to (1, 1, 1) would imply the
 * start simplex would be: { (1, 1, 1), (2, 1, 1), (2, 11, 1), (2, 11, 3) }.
 * The first vertex would be set to the start point at (1, 1, 1) and the
 * last vertex would be set to the diagonally opposite vertex at (2, 11, 3).
 *
 * @param steps Steps along the canonical axes representing box edges. They
 * may be negative but not zero.
 * @throws NullArgumentException if {@code steps} is {@code null}.
 * @throws ZeroException if one of the steps is zero.
 */
protected AbstractSimplex(final double[] steps) {
    if (steps == null) {
        throw new NullArgumentException();
    }
    if (steps.length == 0) {
        throw new ZeroException();
    }
    dimension = steps.length;

    // Only the relative position of the n final vertices with respect
    // to the first one are stored.
    startConfiguration = new double[dimension][dimension];
    for (int i = 0; i < dimension; i++) {
        final double[] vertexI = startConfiguration[i];
        for (int j = 0; j < i + 1; j++) {
            if (steps[j] == 0) {
                throw new ZeroException(LocalizedFormats.EQUAL_VERTICES_IN_SIMPLEX);
            }
            System.arraycopy(steps, 0, vertexI, 0, j + 1);
        }
    }
}
 
Example 11
Source File: AbstractSimplex.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * The real initial simplex will be set up by moving the reference
 * simplex such that its first point is located at the start point of the
 * optimization.
 *
 * @param referenceSimplex Reference simplex.
 * @throws NotStrictlyPositiveException if the reference simplex does not
 * contain at least one point.
 * @throws DimensionMismatchException if there is a dimension mismatch
 * in the reference simplex.
 * @throws IllegalArgumentException if one of its vertices is duplicated.
 */
protected AbstractSimplex(final double[][] referenceSimplex) {
    if (referenceSimplex.length <= 0) {
        throw new NotStrictlyPositiveException(LocalizedFormats.SIMPLEX_NEED_ONE_POINT,
                                               referenceSimplex.length);
    }
    dimension = referenceSimplex.length - 1;

    // Only the relative position of the n final vertices with respect
    // to the first one are stored.
    startConfiguration = new double[dimension][dimension];
    final double[] ref0 = referenceSimplex[0];

    // Loop over vertices.
    for (int i = 0; i < referenceSimplex.length; i++) {
        final double[] refI = referenceSimplex[i];

        // Safety checks.
        if (refI.length != dimension) {
            throw new DimensionMismatchException(refI.length, dimension);
        }
        for (int j = 0; j < i; j++) {
            final double[] refJ = referenceSimplex[j];
            boolean allEquals = true;
            for (int k = 0; k < dimension; k++) {
                if (refI[k] != refJ[k]) {
                    allEquals = false;
                    break;
                }
            }
            if (allEquals) {
                throw new MathIllegalArgumentException(LocalizedFormats.EQUAL_VERTICES_IN_SIMPLEX,
                                                       i, j);
            }
        }

        // Store vertex i position relative to vertex 0 position.
        if (i > 0) {
            final double[] confI = startConfiguration[i - 1];
            for (int k = 0; k < dimension; k++) {
                confI[k] = refI[k] - ref0[k];
            }
        }
    }
}
 
Example 12
Source File: AbstractSimplex.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * The real initial simplex will be set up by moving the reference
 * simplex such that its first point is located at the start point of the
 * optimization.
 *
 * @param referenceSimplex Reference simplex.
 * @throws NotStrictlyPositiveException if the reference simplex does not
 * contain at least one point.
 * @throws DimensionMismatchException if there is a dimension mismatch
 * in the reference simplex.
 * @throws IllegalArgumentException if one of its vertices is duplicated.
 */
protected AbstractSimplex(final double[][] referenceSimplex) {
    if (referenceSimplex.length <= 0) {
        throw new NotStrictlyPositiveException(LocalizedFormats.SIMPLEX_NEED_ONE_POINT,
                                               referenceSimplex.length);
    }
    dimension = referenceSimplex.length - 1;

    // Only the relative position of the n final vertices with respect
    // to the first one are stored.
    startConfiguration = new double[dimension][dimension];
    final double[] ref0 = referenceSimplex[0];

    // Loop over vertices.
    for (int i = 0; i < referenceSimplex.length; i++) {
        final double[] refI = referenceSimplex[i];

        // Safety checks.
        if (refI.length != dimension) {
            throw new DimensionMismatchException(refI.length, dimension);
        }
        for (int j = 0; j < i; j++) {
            final double[] refJ = referenceSimplex[j];
            boolean allEquals = true;
            for (int k = 0; k < dimension; k++) {
                if (refI[k] != refJ[k]) {
                    allEquals = false;
                    break;
                }
            }
            if (allEquals) {
                throw new MathIllegalArgumentException(LocalizedFormats.EQUAL_VERTICES_IN_SIMPLEX,
                                                       i, j);
            }
        }

        // Store vertex i position relative to vertex 0 position.
        if (i > 0) {
            final double[] confI = startConfiguration[i - 1];
            for (int k = 0; k < dimension; k++) {
                confI[k] = refI[k] - ref0[k];
            }
        }
    }
}
 
Example 13
Source File: AbstractSimplex.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * The real initial simplex will be set up by moving the reference
 * simplex such that its first point is located at the start point of the
 * optimization.
 *
 * @param referenceSimplex Reference simplex.
 * @throws NotStrictlyPositiveException if the reference simplex does not
 * contain at least one point.
 * @throws DimensionMismatchException if there is a dimension mismatch
 * in the reference simplex.
 * @throws IllegalArgumentException if one of its vertices is duplicated.
 */
protected AbstractSimplex(final double[][] referenceSimplex) {
    if (referenceSimplex.length <= 0) {
        throw new NotStrictlyPositiveException(LocalizedFormats.SIMPLEX_NEED_ONE_POINT,
                                               referenceSimplex.length);
    }
    dimension = referenceSimplex.length - 1;

    // Only the relative position of the n final vertices with respect
    // to the first one are stored.
    startConfiguration = new double[dimension][dimension];
    final double[] ref0 = referenceSimplex[0];

    // Loop over vertices.
    for (int i = 0; i < referenceSimplex.length; i++) {
        final double[] refI = referenceSimplex[i];

        // Safety checks.
        if (refI.length != dimension) {
            throw new DimensionMismatchException(refI.length, dimension);
        }
        for (int j = 0; j < i; j++) {
            final double[] refJ = referenceSimplex[j];
            boolean allEquals = true;
            for (int k = 0; k < dimension; k++) {
                if (refI[k] != refJ[k]) {
                    allEquals = false;
                    break;
                }
            }
            if (allEquals) {
                throw new MathIllegalArgumentException(LocalizedFormats.EQUAL_VERTICES_IN_SIMPLEX,
                                                       i, j);
            }
        }

        // Store vertex i position relative to vertex 0 position.
        if (i > 0) {
            final double[] confI = startConfiguration[i - 1];
            for (int k = 0; k < dimension; k++) {
                confI[k] = refI[k] - ref0[k];
            }
        }
    }
}
 
Example 14
Source File: AbstractSimplex.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * The real initial simplex will be set up by moving the reference
 * simplex such that its first point is located at the start point of the
 * optimization.
 *
 * @param referenceSimplex Reference simplex.
 * @throws NotStrictlyPositiveException if the reference simplex does not
 * contain at least one point.
 * @throws DimensionMismatchException if there is a dimension mismatch
 * in the reference simplex.
 * @throws IllegalArgumentException if one of its vertices is duplicated.
 */
protected AbstractSimplex(final double[][] referenceSimplex) {
    if (referenceSimplex.length <= 0) {
        throw new NotStrictlyPositiveException(LocalizedFormats.SIMPLEX_NEED_ONE_POINT,
                                               referenceSimplex.length);
    }
    dimension = referenceSimplex.length - 1;

    // Only the relative position of the n final vertices with respect
    // to the first one are stored.
    startConfiguration = new double[dimension][dimension];
    final double[] ref0 = referenceSimplex[0];

    // Loop over vertices.
    for (int i = 0; i < referenceSimplex.length; i++) {
        final double[] refI = referenceSimplex[i];

        // Safety checks.
        if (refI.length != dimension) {
            throw new DimensionMismatchException(refI.length, dimension);
        }
        for (int j = 0; j < i; j++) {
            final double[] refJ = referenceSimplex[j];
            boolean allEquals = true;
            for (int k = 0; k < dimension; k++) {
                if (refI[k] != refJ[k]) {
                    allEquals = false;
                    break;
                }
            }
            if (allEquals) {
                throw new MathIllegalArgumentException(LocalizedFormats.EQUAL_VERTICES_IN_SIMPLEX,
                                                       i, j);
            }
        }

        // Store vertex i position relative to vertex 0 position.
        if (i > 0) {
            final double[] confI = startConfiguration[i - 1];
            for (int k = 0; k < dimension; k++) {
                confI[k] = refI[k] - ref0[k];
            }
        }
    }
}
 
Example 15
Source File: AbstractSimplex.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * The real initial simplex will be set up by moving the reference
 * simplex such that its first point is located at the start point of the
 * optimization.
 *
 * @param referenceSimplex Reference simplex.
 * @throws NotStrictlyPositiveException if the reference simplex does not
 * contain at least one point.
 * @throws DimensionMismatchException if there is a dimension mismatch
 * in the reference simplex.
 * @throws IllegalArgumentException if one of its vertices is duplicated.
 */
protected AbstractSimplex(final double[][] referenceSimplex) {
    if (referenceSimplex.length <= 0) {
        throw new NotStrictlyPositiveException(LocalizedFormats.SIMPLEX_NEED_ONE_POINT,
                                               referenceSimplex.length);
    }
    dimension = referenceSimplex.length - 1;

    // Only the relative position of the n final vertices with respect
    // to the first one are stored.
    startConfiguration = new double[dimension][dimension];
    final double[] ref0 = referenceSimplex[0];

    // Loop over vertices.
    for (int i = 0; i < referenceSimplex.length; i++) {
        final double[] refI = referenceSimplex[i];

        // Safety checks.
        if (refI.length != dimension) {
            throw new DimensionMismatchException(refI.length, dimension);
        }
        for (int j = 0; j < i; j++) {
            final double[] refJ = referenceSimplex[j];
            boolean allEquals = true;
            for (int k = 0; k < dimension; k++) {
                if (refI[k] != refJ[k]) {
                    allEquals = false;
                    break;
                }
            }
            if (allEquals) {
                throw new MathIllegalArgumentException(LocalizedFormats.EQUAL_VERTICES_IN_SIMPLEX,
                                                       i, j);
            }
        }

        // Store vertex i position relative to vertex 0 position.
        if (i > 0) {
            final double[] confI = startConfiguration[i - 1];
            for (int k = 0; k < dimension; k++) {
                confI[k] = refI[k] - ref0[k];
            }
        }
    }
}
 
Example 16
Source File: AbstractSimplex.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * The real initial simplex will be set up by moving the reference
 * simplex such that its first point is located at the start point of the
 * optimization.
 *
 * @param referenceSimplex Reference simplex.
 * @throws NotStrictlyPositiveException if the reference simplex does not
 * contain at least one point.
 * @throws DimensionMismatchException if there is a dimension mismatch
 * in the reference simplex.
 * @throws IllegalArgumentException if one of its vertices is duplicated.
 */
protected AbstractSimplex(final double[][] referenceSimplex) {
    if (referenceSimplex.length <= 0) {
        throw new NotStrictlyPositiveException(LocalizedFormats.SIMPLEX_NEED_ONE_POINT,
                                               referenceSimplex.length);
    }
    dimension = referenceSimplex.length - 1;

    // Only the relative position of the n final vertices with respect
    // to the first one are stored.
    startConfiguration = new double[dimension][dimension];
    final double[] ref0 = referenceSimplex[0];

    // Loop over vertices.
    for (int i = 0; i < referenceSimplex.length; i++) {
        final double[] refI = referenceSimplex[i];

        // Safety checks.
        if (refI.length != dimension) {
            throw new DimensionMismatchException(refI.length, dimension);
        }
        for (int j = 0; j < i; j++) {
            final double[] refJ = referenceSimplex[j];
            boolean allEquals = true;
            for (int k = 0; k < dimension; k++) {
                if (refI[k] != refJ[k]) {
                    allEquals = false;
                    break;
                }
            }
            if (allEquals) {
                throw new MathIllegalArgumentException(LocalizedFormats.EQUAL_VERTICES_IN_SIMPLEX,
                                                       i, j);
            }
        }

        // Store vertex i position relative to vertex 0 position.
        if (i > 0) {
            final double[] confI = startConfiguration[i - 1];
            for (int k = 0; k < dimension; k++) {
                confI[k] = refI[k] - ref0[k];
            }
        }
    }
}
 
Example 17
Source File: AbstractSimplex.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * The real initial simplex will be set up by moving the reference
 * simplex such that its first point is located at the start point of the
 * optimization.
 *
 * @param referenceSimplex Reference simplex.
 * @throws NotStrictlyPositiveException if the reference simplex does not
 * contain at least one point.
 * @throws DimensionMismatchException if there is a dimension mismatch
 * in the reference simplex.
 * @throws IllegalArgumentException if one of its vertices is duplicated.
 */
protected AbstractSimplex(final double[][] referenceSimplex) {
    if (referenceSimplex.length <= 0) {
        throw new NotStrictlyPositiveException(LocalizedFormats.SIMPLEX_NEED_ONE_POINT,
                                               referenceSimplex.length);
    }
    dimension = referenceSimplex.length - 1;

    // Only the relative position of the n final vertices with respect
    // to the first one are stored.
    startConfiguration = new double[dimension][dimension];
    final double[] ref0 = referenceSimplex[0];

    // Loop over vertices.
    for (int i = 0; i < referenceSimplex.length; i++) {
        final double[] refI = referenceSimplex[i];

        // Safety checks.
        if (refI.length != dimension) {
            throw new DimensionMismatchException(refI.length, dimension);
        }
        for (int j = 0; j < i; j++) {
            final double[] refJ = referenceSimplex[j];
            boolean allEquals = true;
            for (int k = 0; k < dimension; k++) {
                if (refI[k] != refJ[k]) {
                    allEquals = false;
                    break;
                }
            }
            if (allEquals) {
                throw new MathIllegalArgumentException(LocalizedFormats.EQUAL_VERTICES_IN_SIMPLEX,
                                                       i, j);
            }
        }

        // Store vertex i position relative to vertex 0 position.
        if (i > 0) {
            final double[] confI = startConfiguration[i - 1];
            for (int k = 0; k < dimension; k++) {
                confI[k] = refI[k] - ref0[k];
            }
        }
    }
}
 
Example 18
Source File: AbstractSimplex.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * The real initial simplex will be set up by moving the reference
 * simplex such that its first point is located at the start point of the
 * optimization.
 *
 * @param referenceSimplex Reference simplex.
 * @throws NotStrictlyPositiveException if the reference simplex does not
 * contain at least one point.
 * @throws DimensionMismatchException if there is a dimension mismatch
 * in the reference simplex.
 * @throws IllegalArgumentException if one of its vertices is duplicated.
 */
protected AbstractSimplex(final double[][] referenceSimplex) {
    if (referenceSimplex.length <= 0) {
        throw new NotStrictlyPositiveException(LocalizedFormats.SIMPLEX_NEED_ONE_POINT,
                                               referenceSimplex.length);
    }
    dimension = referenceSimplex.length - 1;

    // Only the relative position of the n final vertices with respect
    // to the first one are stored.
    startConfiguration = new double[dimension][dimension];
    final double[] ref0 = referenceSimplex[0];

    // Loop over vertices.
    for (int i = 0; i < referenceSimplex.length; i++) {
        final double[] refI = referenceSimplex[i];

        // Safety checks.
        if (refI.length != dimension) {
            throw new DimensionMismatchException(refI.length, dimension);
        }
        for (int j = 0; j < i; j++) {
            final double[] refJ = referenceSimplex[j];
            boolean allEquals = true;
            for (int k = 0; k < dimension; k++) {
                if (refI[k] != refJ[k]) {
                    allEquals = false;
                    break;
                }
            }
            if (allEquals) {
                throw new MathIllegalArgumentException(LocalizedFormats.EQUAL_VERTICES_IN_SIMPLEX,
                                                       i, j);
            }
        }

        // Store vertex i position relative to vertex 0 position.
        if (i > 0) {
            final double[] confI = startConfiguration[i - 1];
            for (int k = 0; k < dimension; k++) {
                confI[k] = refI[k] - ref0[k];
            }
        }
    }
}
 
Example 19
Source File: AbstractSimplex.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * The real initial simplex will be set up by moving the reference
 * simplex such that its first point is located at the start point of the
 * optimization.
 *
 * @param referenceSimplex Reference simplex.
 * @throws NotStrictlyPositiveException if the reference simplex does not
 * contain at least one point.
 * @throws DimensionMismatchException if there is a dimension mismatch
 * in the reference simplex.
 * @throws IllegalArgumentException if one of its vertices is duplicated.
 */
protected AbstractSimplex(final double[][] referenceSimplex) {
    if (referenceSimplex.length <= 0) {
        throw new NotStrictlyPositiveException(LocalizedFormats.SIMPLEX_NEED_ONE_POINT,
                                               referenceSimplex.length);
    }
    dimension = referenceSimplex.length - 1;

    // Only the relative position of the n final vertices with respect
    // to the first one are stored.
    startConfiguration = new double[dimension][dimension];
    final double[] ref0 = referenceSimplex[0];

    // Loop over vertices.
    for (int i = 0; i < referenceSimplex.length; i++) {
        final double[] refI = referenceSimplex[i];

        // Safety checks.
        if (refI.length != dimension) {
            throw new DimensionMismatchException(refI.length, dimension);
        }
        for (int j = 0; j < i; j++) {
            final double[] refJ = referenceSimplex[j];
            boolean allEquals = true;
            for (int k = 0; k < dimension; k++) {
                if (refI[k] != refJ[k]) {
                    allEquals = false;
                    break;
                }
            }
            if (allEquals) {
                throw new MathIllegalArgumentException(LocalizedFormats.EQUAL_VERTICES_IN_SIMPLEX,
                                                       i, j);
            }
        }

        // Store vertex i position relative to vertex 0 position.
        if (i > 0) {
            final double[] confI = startConfiguration[i - 1];
            for (int k = 0; k < dimension; k++) {
                confI[k] = refI[k] - ref0[k];
            }
        }
    }
}
 
Example 20
Source File: AbstractSimplex.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * The real initial simplex will be set up by moving the reference
 * simplex such that its first point is located at the start point of the
 * optimization.
 *
 * @param referenceSimplex Reference simplex.
 * @throws NotStrictlyPositiveException if the reference simplex does not
 * contain at least one point.
 * @throws DimensionMismatchException if there is a dimension mismatch
 * in the reference simplex.
 * @throws IllegalArgumentException if one of its vertices is duplicated.
 */
protected AbstractSimplex(final double[][] referenceSimplex) {
    if (referenceSimplex.length <= 0) {
        throw new NotStrictlyPositiveException(LocalizedFormats.SIMPLEX_NEED_ONE_POINT,
                                               referenceSimplex.length);
    }
    dimension = referenceSimplex.length - 1;

    // Only the relative position of the n final vertices with respect
    // to the first one are stored.
    startConfiguration = new double[dimension][dimension];
    final double[] ref0 = referenceSimplex[0];

    // Loop over vertices.
    for (int i = 0; i < referenceSimplex.length; i++) {
        final double[] refI = referenceSimplex[i];

        // Safety checks.
        if (refI.length != dimension) {
            throw new DimensionMismatchException(refI.length, dimension);
        }
        for (int j = 0; j < i; j++) {
            final double[] refJ = referenceSimplex[j];
            boolean allEquals = true;
            for (int k = 0; k < dimension; k++) {
                if (refI[k] != refJ[k]) {
                    allEquals = false;
                    break;
                }
            }
            if (allEquals) {
                throw new MathIllegalArgumentException(LocalizedFormats.EQUAL_VERTICES_IN_SIMPLEX,
                                                       i, j);
            }
        }

        // Store vertex i position relative to vertex 0 position.
        if (i > 0) {
            final double[] confI = startConfiguration[i - 1];
            for (int k = 0; k < dimension; k++) {
                confI[k] = refI[k] - ref0[k];
            }
        }
    }
}