xref: /petsc/src/tao/leastsquares/impls/brgn/brgn.h (revision b27f53d5f5b22630ba5fcad3f213a141cee9e1d9)
1737f463aSAlp Dener /*
26e9726d0SXiang Huang Context for Bounded Regularized Gauss-Newton algorithm.
36e9726d0SXiang Huang Extended with L1-regularizer with a linear transformation matrix D:
46e9726d0SXiang Huang 0.5*||Ax-b||^2 + lambda*||D*x||_1
56e9726d0SXiang Huang When D is an identity matrix, we have the classic lasso, aka basis pursuit denoising in compressive sensing problem.
6737f463aSAlp Dener */
7737f463aSAlp Dener 
8a4963045SJacob Faibussowitsch #pragma once
9737f463aSAlp Dener 
108e85b1b3SXiang Huang #include <../src/tao/bound/impls/bnk/bnk.h> /* BNLS, a sub-type of BNK, is used in brgn solver */
11*c0b7dd19SHansol Suh #include <petsc/private/taoimpl.h>
12737f463aSAlp Dener 
1334b254c5SRichard Tran Mills #define BRGN_REGULARIZATION_USER   0
1434b254c5SRichard Tran Mills #define BRGN_REGULARIZATION_L2PROX 1
1534b254c5SRichard Tran Mills #define BRGN_REGULARIZATION_L2PURE 2
1634b254c5SRichard Tran Mills #define BRGN_REGULARIZATION_L1DICT 3
1734b254c5SRichard Tran Mills #define BRGN_REGULARIZATION_LM     4
1834b254c5SRichard Tran Mills #define BRGN_REGULARIZATION_TYPES  5
1934b254c5SRichard Tran Mills 
20737f463aSAlp Dener typedef struct {
21a3c390cfSAlp Dener   PetscErrorCode (*regularizerobjandgrad)(Tao, Vec, PetscReal *, Vec, void *);
22a3c390cfSAlp Dener   PetscErrorCode (*regularizerhessian)(Tao, Vec, Mat, void *);
23a3c390cfSAlp Dener   void                     *reg_obj_ctx;
24a3c390cfSAlp Dener   void                     *reg_hess_ctx;
2530eeff36SXiang Huang   Mat                       H, Hreg, D;                             /* Hessian, Hessian for regulization part, and Dictionary matrix have size N*N, and K*N respectively. (Jacobian M*N not used here) */
268e85b1b3SXiang Huang   Vec                       x_old, x_work, r_work, diag, y, y_work; /* x, r=J*x, and y=D*x have size N, M, and K respectively. */
27cd1c4666STristan Konolige   Vec                       damping;                                /* Optional diagonal damping matrix. */
28e1e80dc8SAlp Dener   Tao                       subsolver, parent;
29cd1c4666STristan Konolige   PetscReal                 lambda, epsilon, fc_old;                      /* lambda is regularizer weight for both L2-norm Gaussian-Newton and L1-norm, ||x||_1 is approximated with sum(sqrt(x.^2+epsilon^2)-epsilon)*/
30cd1c4666STristan Konolige   PetscReal                 downhill_lambda_change, uphill_lambda_change; /* With the lm regularizer lambda diag(J^T J),
31cd1c4666STristan Konolige                                                                  lambda = downhill_lambda_change * lambda on steps that decrease the objective.
32cd1c4666STristan Konolige                                                                  lambda = uphill_lambda_change * lambda on steps that increase the objective. */
33*c0b7dd19SHansol Suh   TaoBRGNRegularizationType reg_type;
345eb5f4d6SAlp Dener   PetscBool                 mat_explicit;
35737f463aSAlp Dener } TAO_BRGN;
36