Git Product home page Git Product logo

polysolve's Introduction

PolySolve

Build codecov

This library contains a cross-platform Eigen wrapper for many different external linear solvers including (but not limited to):

  • CHOLMOD
  • Hypre
  • AMGCL
  • Pardiso

Example Usage

const std::string solver_name = "Hypre"
auto solver = Solver::create(solver_name, "");

// Configuration parameters like iteration or accuracy for iterative solvers
// solver->set_parameters(params);

// System sparse matrix
Eigen::SparseMatrix<double> A;

// Right-hand side
Eigen::VectorXd b;

// Solution
Eigen::VectorXd x(b.size());

solver->analyze_pattern(A, A.rows());
solver->factorize(A);
solver->solve(b, x);

You can use Solver::available_solvers() to obtain the list of available solvers.

Parameters

Polysolve uses a json file to provide parameters to the individual solvers. The following template can be used as a starting points, and a more detailed explanation of the parameters is below.

{
    "Eigen::LeastSquaresConjugateGradient": {
        "max_iter": 1000,
        "tolerance": 1e-6
    },
    "Eigen::DGMRES": {
        "max_iter": 1000,
        "tolerance": 1e-6
    },
    "Eigen::ConjugateGradient": {
        "max_iter": 1000,
        "tolerance": 1e-6
    },
    "Eigen::BiCGSTAB": {
        "max_iter": 1000,
        "tolerance": 1e-6
    },
    "Eigen::GMRES": {
        "max_iter": 1000,
        "tolerance": 1e-6
    },
    "Eigen::MINRES": {
        "max_iter": 1000,
        "tolerance": 1e-6
    },
    "Pardiso": {
        "mtype": -1
    },
    "Hypre": {
        "max_iter": 1000,
        "pre_max_iter": 1000,
        "tolerance": 1e-6
    },
    "AMGCL": {
        "precond": {
            "relax": {
                "degree": 16,
                "type": "chebyshev",
                "power_iters": 100,
                "higher": 2,
                "lower": 0.008333333333,
                "scale": true
            },
            "class": "amg",
            "max_levels": 6,
            "direct_coarse": false,
            "ncycle": 2,
            "coarsening": {
                "type": "smoothed_aggregation",
                "estimate_spectral_radius": true,
                "relax": 1,
                "aggr": {
                    "eps_strong": 0
                }
            }
        },
        "solver": {
            "tol": 1e-10,
            "maxiter": 1000,
            "type": "cg"
        }
    }
}

Iterative solvers (AMGCL, Eigen Internal Solvers, HYPRE)

  • max_iter controls the solver's iterations, default 1000
  • conv_tol, tolerance controls the convergence tolerance, default 1e-10

Hypre Only

  • pre_max_iter, number of pre iterations, default 1

AMGCL Only

The default parameters of the AMGCL solver are:

{
    "precond": {
        "relax": {
            "degree": 16,
            "type": "chebyshev",
            "power_iters": 100,
            "higher": 2,
            "lower": 0.008333333333,
            "scale": true
        },
        "class": "amg",
        "max_levels": 6,
        "direct_coarse": false,
        "ncycle": 2,
        "coarsening": {
            "type": "smoothed_aggregation",
            "estimate_spectral_radius": true,
            "relax": 1,
            "aggr": {
                "eps_strong": 0
            }
        }
    },
    "solver": {
        "tol": 1e-10,
        "maxiter": 1000,
        "type": "cg"
    }
}

For a more details and options refer to the AMGCL documentation.

Pardiso

mtype, sets the matrix type, default 11

mtype Description
1 real and structurally symmetric
2 real and symmetric positive definite
-2 real and symmetric indefinite
3 complex and structurally symmetric
4 complex and Hermitian positive definite
-4 complex and Hermitian indefinite
6 complex and symmetric
11 real and nonsymmetric
13 complex and nonsymmetric

Troubleshooting

Compilation error: use of undeclared identifier 'SuiteSparse_config'

This error is cause by having a more recent version of SuiteSparse (โ‰ฅ v7.0.0) installed on your system than the version we download and build. We use @sergiud's fork of SuiteSparse which includes CMake support. However, the fork is not up to date with the latest version of SuiteSparse (currently v5.12.0 while the official release is at version v7.0.1). Version v7.0.0 changed the SuiteSparse_config.h header and no longer includes the necessary struct definitions.

Solution

For now, if you can, please downgrade (< v7.0.0) or uninstall your system version of SuiteSparse. In the meantime, we will work with the SuiteSparse developers to resolve this issue.

polysolve's People

Contributors

arvigj avatar danielepanozzo avatar huangzizhou avatar jdumas avatar jiangzhongshi avatar map9959 avatar njsyw1997 avatar ryansynk avatar teseoch avatar xdarklemon avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.