Skip to content

Use non-greek sopt interface #371

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions cpp/purify/algorithm_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ padmm_factory(const algo_distribution dist,
.l1_proximal_positivity_constraint(positive_constraint)
.l1_proximal_real_constraint(real_constraint)
.lagrange_update_scale(0.9)
.nu(op_norm * op_norm)
.sq_op_norm(op_norm * op_norm)
.Psi(*wavelets)
.Phi(*measurements);
#ifdef PURIFY_MPI
Expand All @@ -90,10 +90,11 @@ padmm_factory(const algo_distribution dist,
switch (dist) {
case (algo_distribution::serial):
padmm
->gamma((wavelets->adjoint() * (measurements->adjoint() * uv_data.vis).eval())
.cwiseAbs()
.maxCoeff() *
1e-3)
->regulariser_strength(
(wavelets->adjoint() * (measurements->adjoint() * uv_data.vis).eval())
.cwiseAbs()
.maxCoeff() *
1e-3)
.l2ball_proximal_epsilon(epsilon)
.residual_tolerance(epsilon * residual_tolerance_scaling);
return padmm;
Expand Down Expand Up @@ -132,8 +133,8 @@ padmm_factory(const algo_distribution dist,
std::weak_ptr<Algorithm> const padmm_weak(padmm);
// set epsilon
padmm->residual_tolerance(epsilon * residual_tolerance_scaling).l2ball_proximal_epsilon(epsilon);
// set gamma
padmm->gamma(comm.all_reduce(
// set regulariser_strength
padmm->regulariser_strength(comm.all_reduce(
utilities::step_size<Vector<t_complex>>(uv_data.vis, measurements, wavelets, sara_size) *
1e-3,
MPI_MAX));
Expand Down Expand Up @@ -173,12 +174,12 @@ fb_factory(const algo_distribution dist,
"one wavelet basis.");
auto fb = std::make_shared<Algorithm>(uv_data.vis);
fb->itermax(max_iterations)
.gamma(reg_parameter)
.regulariser_strength(reg_parameter)
.sigma(sigma * std::sqrt(2))
.beta(step_size * std::sqrt(2))
.step_size(step_size * std::sqrt(2))
.relative_variation(relative_variation)
.tight_frame(tight_frame)
.nu(op_norm * op_norm)
.sq_op_norm(op_norm * op_norm)
.Phi(*measurements);

if (f_function) fb->f_function(f_function); // only override f_function default if non-null
Expand Down Expand Up @@ -216,7 +217,7 @@ fb_factory(const algo_distribution dist,
#endif
}
case (g_proximal_type::Indicator): {
g = std::make_shared<RealIndicator<t_scalar>>();
g = std::make_shared<sopt::algorithm::RealIndicator<t_scalar>>();
break;
}
default: {
Expand Down Expand Up @@ -282,10 +283,11 @@ primaldual_factory(
switch (dist) {
case (algo_distribution::serial): {
primaldual
->gamma((wavelets->adjoint() * (measurements->adjoint() * uv_data.vis).eval())
.cwiseAbs()
.maxCoeff() *
1e-3)
->regulariser_strength(
(wavelets->adjoint() * (measurements->adjoint() * uv_data.vis).eval())
.cwiseAbs()
.maxCoeff() *
1e-3)
.l2ball_proximal_epsilon(epsilon)
.residual_tolerance(epsilon * residual_tolerance_scaling);
return primaldual;
Expand Down Expand Up @@ -345,8 +347,8 @@ primaldual_factory(
// set epsilon
primaldual->residual_tolerance(epsilon * residual_tolerance_scaling)
.l2ball_proximal_epsilon(epsilon);
// set gamma
primaldual->gamma(comm.all_reduce(
// set regulariser_strength
primaldual->regulariser_strength(comm.all_reduce(
utilities::step_size<Vector<t_complex>>(uv_data.vis, measurements, wavelets, sara_size) *
1e-3,
MPI_MAX));
Expand Down
25 changes: 14 additions & 11 deletions cpp/purify/update_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,19 @@ void add_updater(std::weak_ptr<Algo> const algo_weak, const t_real step_size_sca
step_size_scale, update_header_sol, update_header_res, sara_size, comm,
beam_units](const Vector<T> &x, const Vector<T> &res) -> bool {
auto algo = algo_weak.lock();
if (comm.is_root()) PURIFY_MEDIUM_LOG("Step size γ {}", algo->gamma());
if (algo->gamma() > 0) {
if (comm.is_root()) PURIFY_MEDIUM_LOG("Step size γ {}", algo->regulariser_strength());
if (algo->regulariser_strength() > 0) {
Vector<t_complex> const alpha = algo->Psi().adjoint() * x;
const t_real new_gamma =
comm.all_reduce((sara_size > 0) ? alpha.real().cwiseAbs().maxCoeff() : 0., MPI_MAX) *
step_size_scale;
if (comm.is_root()) PURIFY_MEDIUM_LOG("Step size γ update {}", new_gamma);
// updating parameter
algo->gamma(((std::abs(algo->gamma() - new_gamma) > update_tol) and *iter < update_iters)
? new_gamma
: algo->gamma());
algo->regulariser_strength(
((std::abs(algo->regulariser_strength() - new_gamma) > update_tol) and
*iter < update_iters)
? new_gamma
: algo->regulariser_strength());
}
Vector<t_complex> const residual = algo->Phi().adjoint() * (res / beam_units).eval();
PURIFY_MEDIUM_LOG("RMS of residual map in Jy/beam {}",
Expand Down Expand Up @@ -86,16 +88,17 @@ void add_updater(std::weak_ptr<Algo> const algo_weak, const t_real step_size_sca
#endif
](const Vector<T> &x, const Vector<T> &res) -> bool {
auto algo = algo_weak.lock();
if (algo->gamma() > 0) {
PURIFY_MEDIUM_LOG("Step size γ {}", algo->gamma());
if (algo->regulariser_strength() > 0) {
PURIFY_MEDIUM_LOG("Step size γ {}", algo->regulariser_strength());
Vector<T> const alpha = algo->Psi().adjoint() * x;
const t_real new_gamma = alpha.real().cwiseAbs().maxCoeff() * step_size_scale;
PURIFY_MEDIUM_LOG("Step size γ update {}", new_gamma);
// updating parameter
algo->gamma(((std::abs((algo->gamma() - new_gamma) / algo->gamma()) > update_tol) and
*iter < update_iters)
? new_gamma
: algo->gamma());
algo->regulariser_strength(((std::abs((algo->regulariser_strength() - new_gamma) /
algo->regulariser_strength()) > update_tol) and
*iter < update_iters)
? new_gamma
: algo->regulariser_strength());
}
Vector<t_complex> const residual = algo->Phi().adjoint() * (res / beam_units).eval();
PURIFY_MEDIUM_LOG("RMS of residual map in Jy/beam {}",
Expand Down