Solvers#
This page provides C++ class references for the publicly-exposed elements of the iterative and combinatorial solvers package.
Linear Assignment Problem#
#include <raft/solver/linear_assignment.cuh>
-
template<typename vertex_t, typename weight_t>
class LinearAssignmentProblem# CUDA Implementation of O(n^3) alternating tree Hungarian Algorithm.
See also
Date, Ketan, and Rakesh Nagi. “GPU-accelerated Hungarian algorithms
for the Linear Assignment Problem.” Parallel Computing 57 (2016): 52-72.
Note
This is a port to RAFT from original authors Ketan Date and Rakesh Nagi
- Template Parameters:
vertex_t –
weight_t –
Public Functions
- inline LinearAssignmentProblem( )#
Constructor.
- Parameters:
handle – raft handle for managing resources
size – size of square matrix
batchsize –
epsilon –
- inline void solve( )#
Executes Hungarian algorithm on the input cost matrix.
- Parameters:
d_cost_matrix –
d_row_assignment –
d_col_assignment –
- inline std::pair<const weight_t*, vertex_t> getRowDualVector(
- int spId
Function for getting optimal row dual vector for subproblem spId.
- Parameters:
spId –
- Returns:
- inline std::pair<const weight_t*, vertex_t> getColDualVector(
- int spId
Function for getting optimal col dual vector for subproblem spId.
- Parameters:
spId –
- Returns:
Batched Non-negative Least Squares#
#include <raft/solver/nnls.cuh>
-
struct nnls_params#
Parameters of raft::solver::nnls.
Public Members
-
double tol = 1e-6#
Optimality (KKT) tolerance on the projected gradient A^T (b - A x). The solver also allows for the rounding error of that gradient, which grows with the magnitude of the data; for large-scale inputs, and for float32 in general, it can exceed
tol. Normalize A and B if an absolute tolerance matters.
-
int max_iter = 0#
Cap on the number of iterations per problem; <= 0 selects a default that scales with n.
-
double tol = 1e-6#
-
template<typename T>
void nnls( - raft::resources const &res,
- nnls_params const ¶ms,
- raft::device_matrix_view<const T, std::int64_t, raft::col_major> A,
- raft::device_matrix_view<const T, std::int64_t, raft::col_major> B,
- raft::device_matrix_view<T, std::int64_t, raft::col_major> X,
- std::optional<raft::device_matrix_view<const std::uint8_t, std::int64_t, raft::col_major>> masks = std::nullopt,
- std::optional<raft::device_vector_view<T, std::int64_t>> rnorm = std::nullopt
Solve a batch of non-negative least-squares problems that share one matrix.
For every problem p, solves
min_{x >= 0} ||A x - b_p||_2, where the columns b_p of B are the right-hand sides. Optionally, each problem can be restricted to a subset of the columns of A.Problems whose min(m, n) is too large for the device raise a
raft::logic_errorbefore any work is done.The outputs
Xandrnormmust not overlap each other or any input (A,B,masks).- Template Parameters:
T – float or double
- Parameters:
res – [in] RAFT resources
params – [in] tolerance and iteration cap
A – [in] (m x n) column-major matrix
B – [in] (m x P) column-major right-hand sides, one problem per column
X – [out] (n x P) column-major solutions
masks – [in] optional (n x P) column-major support: problem p may only use the columns j of A with masks(j, p) != 0 (the others are 0 in X)
rnorm – [out] optional length-P residual norms:
rnorm(p) = ||b_p - A x_p||_2
Minimum Spanning Tree#
#include <raft/sparse/solver/mst.cuh>
Warning
doxygenfunction: Unable to resolve function “raft::sparse::solver::mst” with arguments None in doxygen xml output for project “RAFT” from directory: ../../cpp/doxygen/_xml/. Potential matches:
- template<typename vertex_t, typename edge_t, typename weight_t, typename alteration_t = weight_t> Graph_COO<vertex_t, edge_t, weight_t> mst(raft::resources const &handle, edge_t const *offsets, vertex_t const *indices, weight_t const *weights, vertex_t const v, edge_t const e, vertex_t *color, bool symmetrize_output = true, bool initialize_colors = true, int iterations = 0)
- template<typename vertex_t, typename edge_t, typename weight_t, typename alteration_t = weight_t> Graph_COO<vertex_t, edge_t, weight_t> mst(raft::resources const &handle, edge_t const *offsets, vertex_t const *indices, weight_t const *weights, vertex_t const v, edge_t const e, vertex_t *color, cudaStream_t stream, bool symmetrize_output = true, bool initialize_colors = true, int iterations = 0)