Software:SuanShu

From HandWiki
Jump to: navigation, search
SuanShu
Stable release
20120606 / 2012-06-06
Written inJava
TypeMath
LicenseApache License 2.0
Websitegithub.com/nmdev2020/SuanShu

SuanShu is a Java numerical library[1]. It is the only open source Java implementation of a complete suite of standard optimization algorithms: linear programming, quadratic programming, second order conic programming, semi-definite programming, sequential quadratic programming and heuristic methods.[2] It implements the adaptive strassen’s algorithm for matrix multiplication. SuanShu has been quoted and used in a number of academic works.[3][4]

Features

  • linear algebra
  • unconstrained and constrained optimization
  • statistical analysis
  • ordinary and partial differential equation solvers

License terms

SuanShu is released under the terms of the Apache License 2.0

Examples of usage

The following code solves a Second Order Conic Programming problem using the Interior Point Method.

public final class SOCP {
    /**
     * The objective function.
     */
    public static final Vector f = new DenseVector(1., 0., 0., 0., 0.);
    /**
     * The A's in the conic constraints.
     */
    public static final Matrix A1t = new DenseMatrix(new double[][]{
        {0, -1, 0, 1, 0},
        {0, 0, 1, 0, -1}
    });
    public static final Matrix A2t = new DenseMatrix(new double[][]{
        {0, 0.5, 0, 0, 0},
        {0, 0, 1, 0, 0}
    });
    public static final Matrix A3t = new DenseMatrix(new double[][]{
        {0, 0, 0, -0.7071, -0.7071},
        {0, 0, 0, -0.3536, 0.3536}
    });
    /**
     * The b's in the conic constraints.
     */
    public static final Vector b1 = f;
    public static final Vector b2 = f.ZERO();
    public static final Vector b3 = f.ZERO();
    /**
     * The c's in the conic constraints.
     */
    public static final Vector c1 = new DenseVector(2);//zero
    public static final Vector c2 = new DenseVector(-0.5, 0.);
    public static final Vector c3 = new DenseVector(4.2426, -0.7071);
    /**
     * The d's in the conic constraints.
     */
    public static final double[] d = new double[]{0., 1, 1};
    private static final List<SOCPGeneralConstraint> constraints = Arrays.asList(
        new SOCPGeneralConstraint(A1t.t(), c1, b1, d[0]),
        new SOCPGeneralConstraint(A2t.t(), c2, b2, d[1]),
        new SOCPGeneralConstraint(A3t.t(), c3, b3, d[2]));
    /**
     * The SOCP problem to be solved.
     */
    public static final SOCPGeneralProblem problem = new SOCPGeneralProblem(f, constraints);
    private SOCP() {
    }
    public static void main(String[] args) throws Exception {
        System.out.println("This class demonstrates how to solve Second-order cone programming "
            + "problems in Java using SuanShu.");
        solveSOCP_0010(problem, 0.00001, 20);
        solveSOCP_0020(problem, 0.00001, 20);
    }
    /**
     * Uses interior point method to solve the given problem from the given starting point.
     *
     * @param problem      the dual SDP problem that is to be solved
     * @param epsilon      the precision of the computed result
     * @param maxIteration the maximum number of iterations
     * @throws Exception if an error occurs solving the problem
     */
    public static void solveSOCP_0010(SOCPGeneralProblem problem, double epsilon, int maxIteration)
        throws Exception {
        /**
         * initial guess of solution
         */
        Vector x0 = new DenseVector(1, 0, 0, 0.1, 0, 0, 0.1, 0, 0);
        Vector s0 = new DenseVector(3.7, 1, -3.5, 1, 0.25, 0.5, 1, -0.35355, -0.1767);
        Vector y0 = new DenseVector(-3.7, -1.5, -0.5, -2.5, -4);
        PrimalDualSolution soln0 = new PrimalDualSolution(x0, s0, y0);
        PrimalDualInteriorPointMinimizer socp = new PrimalDualInteriorPointMinimizer(epsilon, maxIteration);
        IterativeSolution<PrimalDualSolution> soln = socp.solve(problem);
        soln.search(soln0);
        System.out.println("minimizer: " + soln.minimizer().y);
    }
    /**
     * Uses interior point method to solve the given problem from the initials as in SDPT3.
     * Users do not provide initial guess.
     *
     * @param problem      the dual SDP problem that is to be solved
     * @param epsilon      the precision of the computed result
     * @param maxIteration the maximum number of iterations
     * @throws Exception if an error occurs solving the problem
     */
    public static void solveSOCP_0020(SOCPGeneralProblem problem, double epsilon, int maxIteration)
        throws Exception {
        PrimalDualInteriorPointMinimizer socp = new PrimalDualInteriorPointMinimizer(epsilon, maxIteration);
        IterativeSolution<PrimalDualSolution> soln = socp.solve(problem);
        soln.search();
        System.out.println("minimizer: " + soln.minimizer().y);
    }
}

See also

References




References

  1. Li, Haksun (2021-08-16) (in en). Numerical Methods Using Java: For Data Science, Analysis, and Engineering. Apress. ISBN 978-1-4842-6796-7. https://books.google.com/books?id=t28NzgEACAAJ&newbks=0&hl=en. 
  2. "Java Numerics: Main". https://math.nist.gov/javanumerics/. 
  3. Möhlmann, Eike (2018). Automatic stability verification via Lyapunov functions: representations, transformations, and practical issues (phd thesis). Universität Oldenburg.
  4. Christou, Ioannis T.; Vassilaras, Spyridon (2013-10-01). "A parallel hybrid greedy branch and bound scheme for the maximum distance-2 matching problem" (in en). Computers & Operations Research 40 (10): 2387–2397. doi:10.1016/j.cor.2013.04.009. ISSN 0305-0548. https://www.sciencedirect.com/science/article/pii/S0305054813001159. 

describe suanshu a popular numerical library





Hostmonster hHosting DataMelt statistical framewwork for data scientists RTextDoc LaTeX editor HandWiki ads