GraphBasedSystems.jl

Author janbruedigam
Popularity
3 Stars
Updated Last
1 Year Ago
Started In
June 2021

GraphBasedSystems

Build Status codecov

A package for efficiently solving block-based linear systems of equations based on graph properties. Any matrix representing an underlying real-world system can be represented by a graph, for example mechanical system, robots, chemical molecules, ... The package is currently used for the robotics simulator Dojo.jl

By providing the adjacency matrix of a graph-based system, the GraphBasedSystems package can automatically exploit existing sparsity when solving the linear system to speed up calculations. Currently, the LDU, LU, LDLt, and LLt decomposition/backsubstitution are implemented. LLt is currently slow due to memory allocations.

using GraphBasedSystems

graph_matrix = [  # The adjacency matrix for the underlying graph
  0 1 1 0
  1 0 1 0
  1 1 0 1
  0 0 1 0
]

dimensions = [2; 3; 0; 1] # The dimension of row/column

system = System{Float64}(graph_matrix, dimensions; symmetric=false) # The resulting linear system. Set symmetric=true for symmetric systems

initialize!(system, randn) # initialize all system entries randomly
system.matrix_entries[1,2].value = rand(2,3) # Directly set the value of a matrix entry
system.vector_entries[4].value = rand(1) # Directly set the value of a vector entry

A = full_matrix(system) # Inspect the matrix
b = full_vector(system) # Inspect the vector

ldu_solve!(system) # Solve the system inplace

x = full_vector(system) # Inspect the result
x - A\b # Compare to classical implementation