Subgradient Method¶
Defined in algorithms/subgradient_method.hpp
-
namespace
sarma
::
subgradient_method
¶ Functions
-
template<typename
Int
, typenameValue
, typenameGen
>
autorandom_init
(const Int P, const Value total_load, Gen &gen)¶
-
template<typename
pis_to_rs_t
>
autopartition
(std::vector<std::vector<double>> &pis, pis_to_rs_t to_rs, const std::size_t C = 10, const double eps = 0.001)¶ Implements the SubGradient Optimization algorithm. This algorithm initializes the cut vectors randomly and tries to refine them at each iteration by moving all the cuts in the negative direction of the gradient to minimize the maximum load.
- Return
vector of cut vector parametrizations
- Parameters
pis
: vector of cut vector parametrizationsto_rs
: lambda function to compute gradients given pisC
: number of iterations to wait when objective value flattenseps
: the improvement in the optimization objective expected
-
template<typename
Int
, typenameValue
>
autopartition
(const std::string s, const std::vector<std::reference_wrapper<const Matrix<Int, Value>>> As, const std::vector<Int> Ps, int seed = 1)¶ An easy to use wrapper for the the SubGradient Optimization algorithm. This algorithm initializes the cut vectors randomly and tries to refine them at each iteration by moving all the cuts in the negative direction of the gradient to minimize the maximum load. The first parameter, the string s describes the optimization objective. Each term in the optimization objective is made up of a digit indicating the index of the matrix, the name of the first dimension of the matrix and the name of the second dimension of the matrix separated by “+” signs inbetween. As examples, sgo_2dr -> “0ij”, sgo_2ds -> “0ij,i=j”, sgo_3ds -> “0ij+0jk+0ik” and sgo_3dr -> “0ij+1jk”. As one can guess, the part before the comma represents the optimization objective and after the comma includes constraints that can’t be derived automatically from the optimization objective. As an example, for sgo_2ds, we had to explicitly put the constraint that the two cut vectors in the two dimensions need to be the same via stating “i=j”. However, sgo_3ds can do that automatically because the same matrix dimension is named different letters “i” and “j” etc. that that causes all the dimensions to collapse into one removing the need to put the constraints explicitly.
- Return
a vector of cut vectors
- Parameters
s
: a string describing the optimization objectiveA
: a vector of references to matrices used in the optimization objectiveP
: number of parts in each dimension of the resulting cut vectorsseed
:
-
template<typename
Int
, typenameValue
>
autopartition_spmv
(const Matrix<Int, Value> &A, const Int P, const double alpha, const double beta, const int seed = 1)¶
-
template<typename
Int
, typenameValue
>
autopartition_tri
(const Matrix<Int, Value> &A, const Int P, const int seed = 1)¶ Implements the SubGradient Optimization algorithm, where each task is made of 3 tiles and tries to minimize task size. This algorithm initializes the cut vectors randomly and tries to refine them at each iteration by moving all the cuts in the negative direction of the gradient to minimize the maximum load.
- Return
a cut vector
- Parameters
A
: MatrixP
: number of partsseed
:
-
template<typename
Int
, typenameValue
>
autopartition
(const Matrix<Int, Value> &A, const Matrix<Int, Value> &B, const Int P, const Int Q, const Int R, int seed = 1)¶ Implements the SubGradient Optimization algorithm, where each task is made up of 2 tiles from each matrix in SpGEMM matrix multiplication and tries to minimize task size. This algorithm initializes the cut vectors randomly and tries to refine them at each iteration by moving all the cuts in the negative direction of the gradient to minimize the maximum load.
-
template<typename
Int
, typenameValue
>
autopartition
(const Matrix<Int, Value> &A, const Int P, const int seed = 1)¶ Implements the SubGradient Optimization algorithm. This algorithm initializes the cut vectors randomly and tries to refine them at each iteration by moving all the cuts in the negative direction of the gradient to minimize the maximum load.
- Return
a cut vector
- Parameters
A
: MatrixP
: number of partsseed
:
-
template<typename
Int
, typenameValue
>
autopartition
(const Matrix<Int, Value> &A, const Int P, const Int Q, const int seed = 1)¶ Implements the SubGradient Optimization algorithm. This algorithm initializes the cut vectors randomly and tries to refine them at each iteration by moving all the cuts in the negative direction of the gradient to minimize the maximum load.
- Return
a cut vector
- Parameters
A
: MatrixP
: number of parts in row dimensionQ
: number of parts in column dimensionseed
:
-
template<typename