GithubHelp home page GithubHelp logo

juliasmoothoptimizers / amd.jl Goto Github PK

View Code? Open in Web Editor NEW
20.0 5.0 12.0 608 KB

Approximate Minimum Degree Ordering in Julia

License: Other

Julia 98.94% Shell 1.06%
amd permutation factorization sparse-matrices julia julia-language linear-algebra sparse-matrix

amd.jl's Introduction

AMD

DOI Stable Dev CI Build Status codecov.io

Given a square sparse matrix, compute an approximate minimum degree ordering. This package is an interface to the AMD library (Amestoy, Davis and Duff) and COLAMD library (Liromore, Davis, Gilberg an Ng).

Installing

julia> ]
pkg> add AMD
pkg> test AMD

Algorithms

amd: an approximate minimum degree ordering algorithm for the sparse factorization of square matrices.

symamd: an approximate minimum degree ordering algorithm for the sparse factorization of symmetric matrices.

colamd: an approximate minimum degree column ordering algorithm for the sparse factorization of arbitrary, square or rectangular, matrices.

Examples

In the simplest case:

using AMD
A = sprand(10, 10, .5)
p_amd = amd(A)
p_symamd = symamd(A)
p_colamd = colamd(A)

If statistics on the permutation are of interest and/or for changing the default control parameters:

julia> meta = Amd{Clong}();  # because A's index type is Int64 on my platform
julia> # optionally change meta.control: ?Amd
julia> p = amd(A, meta)
julia> print(meta)
Control:
  dense row parameter: 10.0
  aggressive absorption: 1.0
Info:
  status: ok
  matrix size: 10.0
  number of nonzeros: 54.0
  pattern symmetry: 0.5
  number of nonzeros on diagonal: 6.0
  number of nonzeros in A + A': 72.0
  number of dense columns: 0.0
  memory used: 1408.0
  number of garbage collections: 0.0
  approx number of nonzers in factor: 38.0
  number of float divides: 38.0
  number of float * or - for LDL: 114.0
  number of float * or - for LU: 190.0
  max nonzeros in any column of factor: 8.0

The amd algorithm computes a fill-reducing permutation based on the sparsity pattern of A + Aᵀ. The input pattern can be anything: diagonal entries will be ignored and the rest will be used to implicitly work on the pattern of A + Aᵀ. Thus if A is symmetric, it is sufficient to supply the strict lower or upper triangle only.

References

  1. P. R. Amestoy, T. A. Davis and I. S. Duff. An Approximate Minimum Degree Ordering Algorithm. SIAM Journal on Matrix Analysis and Applications, 17(4), pp. 886–905, 1996. DOI 10.1137/S0895479894278952
  2. P. R. Amestoy, T. A. Davis, and I. S. Duff. Algorithm 837: An approximate minimum degree ordering algorithm. ACM Transactions on Mathematical Software, 30(3), pp. 381–388, 2004. DOI 10.1145/1024074.1024081
  3. T. A. Davis, J. R. Gilbert, S. Larimore, E. Ng. Algorithm 836: COLAMD, an approximate column minimum degree ordering algorithm, ACM Transactions on Mathematical Software, 30(3), pp. 377–380, 2004. DOI 10.1145/1024074.1024080

amd.jl's People

Contributors

abelsiqueira avatar amontoison avatar dpo avatar jsobot avatar juliatagbot avatar masuday avatar monssaftoukal avatar staticfloat avatar tkelman avatar tmigot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

amd.jl's Issues

TagBot trigger issue

This issue is used to trigger TagBot; feel free to unsubscribe.

If you haven't already, you should update your TagBot.yml to include issue comment triggers.
Please see this post on Discourse for instructions and more details.

If you'd like for me to do this for you, comment TagBot fix on this issue.
I'll open a PR within a few hours, please be patient!

Precompile error - Julia v0.7/1.0 compatibility

When I

add AMD#master
using AMD

try to precompile the package under Julia v0.7/1.0 I get the following error:

ERROR: LoadError: syntax: extra token "Amd" after end of expression
Stacktrace:
 [1] include at ./boot.jl:317 [inlined]
 [2] include_relative(::Module, ::String) at ./loading.jl:1038
 [3] include(::Module, ::String) at ./sysimg.jl:29
 [4] top-level scope at none:2
 [5] eval at ./boot.jl:319 [inlined]
 [6] eval(::Expr) at ./client.jl:389
 [7] top-level scope at ./none:3
in expression starting at /~/.julia/packages/AMD/k9NUS/src/AMD.jl:59

Fails on Win64

It seems that on Windows, int and long are both a 32 bit integer, so Cint and Clong are the same. For some reason, that is causing a failure on Win64.

Precompilation fails on x86 with Julia 1.10+

Changes to https://github.com/JuliaSmoothOptimizers/AMD.jl/blob/main/src/amd_julia.jl#L75 introduced in c65293e cause precompilation of the AMD.jl package to fail on x86 systems with Julia 1.10-nightly and 1.11-nightly.

Failed to precompile Preconditioners [af69fa37-3177-5a40-98ee-561f696e4fcd] to "/home/runner/.julia/compiled/v1.10/Preconditioners/jl_p5AFKc".
WARNING: Method definition amd_valid(SparseArrays.SparseMatrixCSC{F, Int32}) where {F} in module AMD at /home/runner/.julia/packages/AMD/0QFZL/src/amd_julia.jl:77 overwritten on the same line (check for duplicate calls to `include`).
ERROR: LoadError: Method overwriting is not permitted during Module precompile.
Stacktrace:
 [1] top-level scope
   @ ~/.julia/packages/AMD/0QFZL/src/amd_julia.jl:77
 [2] eval(m::Module, e::Any)
   @ Core ./boot.jl:383
 [3] top-level scope
   @ ~/.julia/packages/AMD/0QFZL/src/amd_julia.jl:76
 [4] include(mod::Module, _path::String)
   @ Base ./Base.jl:489
 [5] include(x::String)
   @ AMD ~/.julia/packages/AMD/0QFZL/src/AMD.jl:1
 [6] top-level scope
   @ ~/.julia/packages/AMD/0QFZL/src/AMD.jl:16
 [7] include
   @ Base ./Base.jl:489 [inlined]
 [8] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{…}, dl_load_path::Vector{…}, load_path::Vector{…}, concrete_deps::Vector{…}, source::String)
   @ Base ./loading.jl:2216
 [9] top-level scope
   @ stdin:3
Some type information was truncated. Use `show(err)` to see complete types.
in expression starting at /home/runner/.julia/packages/AMD/0QFZL/src/amd_julia.jl:75
in expression starting at /home/runner/.julia/packages/AMD/0QFZL/src/AMD.jl:1
in expression starting at stdin:3
ERROR: LoadError: Failed to precompile AMD [14f7f29c-3bd6-536c-9a0b-7339e30b5a3e] to "/home/runner/.julia/compiled/v1.10/AMD/jl_BlSBhB".

I think the affected method is overwritten on 32-bit platforms due to Cint and SS_Int referring to the same type Int32. Method overwriting during precompilation seems to be an error since Julia 1.10 (JuliaLang/julia@016edf2)

symamd is not comparable with OCTAVE/MATLAB

I have been trying to convert some code from MATLAB to Julia. But I observe that symamd operation is not very comparable to MATLAB's.
I am pasting the whole code snippet for comparison:

Julia Code

H   =   2;                                 #Height of the container
L   =   5;                                 #Length of the container

nx    =   10;
ny    =   7; 

dx  =   L/(nx-1);                         #Width of space step(x)
dy  =   H/(ny-1);                         #Width of space step(y)
dt   = 0.01

e       =   ones(nx-2);
i       =   ones(ny-2);

Tx      =   spdiagm(-1 => e[1:end-1], 0 => -2*e, 1 => e[1:end-1]);      
Ty      =   spdiagm(-1 => i[1:end-1], 0 => -2*i, 1 => i[1:end-1]);

Tx[1,1] =   -1; 
Tx[end,end]=-1;

Tt      =   kron(Ty/dy^2,   sparse(I, nx-2, nx-2))    +   kron(sparse(I, ny-2, ny-2),   Tx/dx^2);
N       =   (nx-2)*(ny-2)
Tt      =   sparse(I, N, N)     -   dt*Tt/Pe;
pt      =   symamd(Tt);

Output in Julia:

pt = [1, 8, 33, 40, 39, 32, 34, 25, 16, 7, 9, 2, 4, 36, 37, 5, 10, 15, 26, 31, 19, 21, 24, 23, 30, 14, 22, 29, 38, 13, 6, 28, 12, 20, 27, 35, 18, 17, 11, 3]

Output in OCTAVE:

debug> pt
pt =

 Columns 1 through 11:

    1    9    2   10   33   34   25   26   19    4    5

 Columns 12 through 22:

   36   37   21    8   16    7   15   40   39   32   31

 Columns 23 through 33:

   24   23   30   14   22   29   38   13    6   28   12

 Columns 34 through 40:

   20   27   35   18   17   11    3

Any help/suggestion/insight is greatly appreciated,
Thanks!

New release

Needs a new release supporting 0.7. Needed for LDL.

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.