SOPT
Sparse OPTimisation
Typedefs | Functions | Variables
padmm_warm_start.cc File Reference
#include <catch2/catch_all.hpp>
#include <random>
#include <Eigen/Dense>
#include "sopt/padmm.h"
#include "sopt/proximal.h"
#include "sopt/types.h"
+ Include dependency graph for padmm_warm_start.cc:

Go to the source code of this file.

Typedefs

using Scalar = sopt::t_real
 
using t_Vector = sopt::Vector< Scalar >
 
using t_Matrix = sopt::Matrix< Scalar >
 

Functions

 SCENARIO ("ProximalADMM with warm start", "[padmm][integration]")
 

Variables

constexpr auto N = 30
 

Typedef Documentation

◆ Scalar

Definition at line 10 of file padmm_warm_start.cc.

◆ t_Matrix

Definition at line 12 of file padmm_warm_start.cc.

◆ t_Vector

Definition at line 11 of file padmm_warm_start.cc.

Function Documentation

◆ SCENARIO()

SCENARIO ( "ProximalADMM with warm start"  ,
""  [padmm][integration] 
)

Definition at line 15 of file padmm_warm_start.cc.

15  {
16  using namespace sopt;
17 
18  GIVEN("A ProximalADMM instance with its input") {
19  t_Vector const target0 = t_Vector::Random(N);
20  t_Vector const target1 = t_Vector::Random(N) * 4;
21  auto const g0 = proximal::translate(proximal::EuclidianNorm(), -target0);
22  auto const g1 = proximal::translate(proximal::EuclidianNorm(), -target1);
23  t_Matrix const mId = -t_Matrix::Identity(N, N);
24 
25  auto convergence = [&target1, &target0](t_Vector const &x) -> bool {
26  t_Vector const segment = (target1 - target0).normalized();
27  t_real const alpha = (x - target0).transpose() * segment;
28  SOPT_TRACE(" {} {}", alpha, (x - target0 - alpha * segment).stableNorm());
29  return alpha >= 0e0 and (target1 - target0).transpose() * segment >= alpha and
30  (x - target0 - alpha * segment).stableNorm() < 1e-8;
31  };
32 
33  auto padmm = algorithm::ProximalADMM<Scalar>(g0, g1, t_Vector::Zero(N))
34  .Phi(mId)
35  .itermax(3000)
36  .regulariser_strength(0.5)
37  .is_converged(convergence);
38 
39  WHEN("the algorithms runs") {
40  auto const full = padmm();
41  THEN("it converges") {
42  CHECK(full.niters > 20);
43  CHECK(full.good);
44  }
45 
46  WHEN("It is set to stop before convergence") {
47  auto const first_half = padmm.itermax(full.niters - 5)();
48  THEN("It is not converged") { CHECK(not first_half.good); }
49 
50  WHEN("A warm restart is attempted") {
51  auto const second_half = padmm.itermax(5000)(first_half);
52  THEN("The warm restart is validated by the fast convergence") {
53  CHECK(second_half.niters < 10);
54  }
55  }
56  }
57  }
58  }
59 }
sopt::Vector< Scalar > t_Vector
sopt::Matrix< Scalar > t_Matrix
Proximal Alternate Direction method of mutltipliers.
Definition: padmm.h:19
ProximalADMM< Scalar > & is_converged(std::function< bool(t_Vector const &x)> const &func)
Convergence function that takes only the output as argument.
Definition: padmm.h:112
ProximalADMM &::type Phi(ARGS &&... args)
Definition: padmm.h:174
Proximal of euclidian norm.
Definition: proximal.h:18
#define SOPT_TRACE(...)
Definition: logging.h:220
Translation< FUNCTION, VECTOR > translate(FUNCTION const &func, VECTOR const &translation)
Translates given proximal by given vector.
Definition: proximal.h:362
double t_real
Root of the type hierarchy for real numbers.
Definition: types.h:17
constexpr auto N

References sopt::algorithm::ProximalADMM< SCALAR >::is_converged(), N, sopt::algorithm::ProximalADMM< SCALAR >::Phi(), SOPT_TRACE, and sopt::proximal::translate().

Variable Documentation

◆ N

constexpr auto N = 30
constexpr

Definition at line 14 of file padmm_warm_start.cc.

Referenced by SCENARIO().