v0.16.3
Loading...
Searching...
No Matches
TaoNullSpace.hpp
Go to the documentation of this file.
1/** \file TaoNullSpace.hpp
2 * \brief TAO shell interface for null-space constrained optimization.
3 */
4
5#ifndef MOFEM_TAO_NULL_SPACE_HPP
6#define MOFEM_TAO_NULL_SPACE_HPP
7
8namespace MoFEM {
9
10/** Registered TAOSHELL-based null-space constrained optimizer.
11 * \ingroup mofem_petsc_solvers
12 */
13inline constexpr char TAONULLSPACE[] = "nullspace";
14
15/** Register TAONULLSPACE before TaoSetType() or TaoSetFromOptions().
16 *
17 * The shell consumes the same objective/gradient, inequality and inequality
18 * Jacobian callbacks as TAOALMM, with c_i >= 0. Both combined and separate
19 * objective/gradient callbacks are supported. The null-space flow follows
20 * Feppon, Allaire and Dapogny, ESAIM: COCV 26 (2020), article 90.
21 * Objective-only trial evaluations use the parent objective and constraint
22 * values without requesting the objective gradient or constraint Jacobian.
23 * Applications providing only a combined callback retain PETSc's combined
24 * evaluation fallback. The default backtracking and the More--Thuente domain
25 * safeguard request a derivative only after a trial passes the merit check;
26 * native More--Thuente still evaluates the derivative for its curvature test.
27 *
28 * At each accepted iterate, rows with c_i <= h * ||J_i||_2 form the multiplier
29 * candidates, following Section 4.1, equation (4.3), of Feppon et al. Here
30 * h = active_tol is a control-space activation distance in the Euclidean Vec
31 * metric. This replaces the former uniform tolerance on constraint values.
32 * Positive scaling of a constraint and its Jacobian row leaves this candidate
33 * classification unchanged. A nonnegative least-squares solve fits
34 * J_c^T lambda to grad f; multipliers above multiplier_tol select the binding
35 * rows B. The restoration rows R contain B and all rows with c_i <= 0.
36 * Ordered row selections and their accepted-iterate Jacobians are copied
37 * before constructing C C^T inverse
38 * actions for projection and restoration.
39 *
40 * The default inner TAOSHELL takes one flow step in direction -grad Phi at
41 * the accepted base point, with projection and merit data frozen. The default
42 * "nullspace" line search follows Algorithm 1: halve the step until the
43 * frozen merit strictly decreases, or accept the final valid trial when the
44 * trial budget is reached. That terminal fallback may increase the merit.
45 * Invalid physical evaluations cannot be accepted. After the inner solve
46 * returns, the accepted outer update immediately rebuilds row selections and
47 * multipliers, including constraints newly violated by the step. Convergence uses
48 * stationarity, complementarity and primal feasibility through standard TAO
49 * monitoring and convergence callbacks.
50 * An iterative multiplier solve reaching its iteration limit emits a warning
51 * and uses its current estimate; the outer convergence checks still apply. Other
52 * multiplier-solver failures remain errors.
53 *
54 * Options following the parent TAO prefix:
55 * - -tao_nullspace_monitor_kkt: print stationarity, projected-gradient and
56 * complementarity Euclidean norms at each outer iteration, default false.
57 * - -tao_nullspace_alpha_j: objective scale, default 1.
58 * - -tao_nullspace_alpha_c: restoration scale, default 1.
59 * - -tao_nullspace_active_tol: finite nonnegative control-space activation
60 * distance h, default 1e-6; h = 0 selects saturated or violated candidates.
61 * - -tao_nullspace_multiplier_tol: binding-row tolerance, default 1e-10.
62 * - -tao_nullspace_min_step: minimum accepted step norm, default 1e-14.
63 *
64 * The inner solver uses the additional prefix "tao_nullspace_". Its default
65 * TAO type is "shell" and its line-search type is "nullspace".
66 * -tao_nullspace_tao_ls_stepinit sets the initial time step (default 1), and
67 * -tao_nullspace_tao_ls_max_funcs sets the trial budget (PETSc default 30).
68 * The last valid trial may return TAOLINESEARCH_SUCCESS_USER without a merit
69 * decrease; the outer solver honors this fallback. Invalid/nonfinite physical
70 * data and a step below the configured minimum still cause failure.
71 * A completed shell step returns TAO_CONVERGED_USER; the outer TAO checks KKT.
72 * Explicit LMVM or other line-search choices are alternatives to this default
73 * Algorithm 1 step. Iterative inner types honor -tao_nullspace_tao_max_it.
74 * LMVM history recycling follows -tao_nullspace_tao_lmvm_recycle (PETSc
75 * default false). With one inner iteration, recycling allows curvature history
76 * to accumulate across outer iterations. The frozen merit changes when its
77 * active sets, multipliers or restoration matrix change, so retained history
78 * is an approximation; the outer acceptance and KKT checks still apply.
79 * With More--Thuente, invalid physical data stop cubic interpolation and
80 * trigger geometric backtracking using the true merit and gradient.
81 * Its sufficient-decrease safeguard does not guarantee Wolfe curvature.
82 * Every option above also receives the parent TAO prefix.
83 *
84 * Multiplier selection defaults to TAOBLMVM under "tao_nullspace_dual_".
85 * For orthogonal nonzero constraint rows, select
86 * -tao_nullspace_dual_tao_type diagonal. TAODIAGONALNNLS then evaluates
87 * lambda = max(0, (J * grad f) / diag(J J^T)) directly, without an iterative
88 * solve or line search, as in Remark 3.10 of Feppon et al. Cellwise P0 plastic
89 * rows have disjoint control supports, which satisfies this condition even
90 * after volume scaling. The diagonal solver checks the normalized Gram matrix
91 * for orthogonality; coupled rows require a general solver such as TAOBLMVM.
92 * Its monitor and convergence test use the actual bound-projected gradient.
93 * The reusable API is declared in TaoDiagonalNNLS.hpp:
94 * TaoRegisterDiagonalNNLS() and TaoDiagonalNNLSSetProblem(tao, J, target)
95 * define min_{lambda >= 0} 0.5 * ||J^T lambda - target||^2 for type
96 * TAODIAGONALNNLS ("diagonal").
97 * For a P0 constraint c = sqrt(V) * (delta_kappa - alpha), the Jacobian-row
98 * norm is sqrt(V) * sqrt(1 + ||grad alpha||_2^2), so volume cancels from candidate
99 * selection. This does not normalize the multiplier, feasibility or stopping
100 * tolerances.
101 *
102 * Projection KSPs use
103 * "tao_nullspace_binding_" and "tao_nullspace_restoration_"; both default to
104 * PREONLY with LU factorization through MUMPS. These prefixes all follow the
105 * parent prefix, and PETSc options can override the defaults.
106 * The MPI regression sets mat_mumps_icntl_20 to 0 under both KSP prefixes
107 * for centralized RHS input with empty local active-row partitions.
108 *
109 * This implementation handles the supplied inequality system; separate TAO
110 * variable bounds and equality constraints are rejected. Express
111 * variable bounds as inequality rows. The nonlinear epigraph regression
112 * exercises smooth points. At a cone apex, choosing an appropriate generalized
113 * Jacobian remains the application's responsibility and is not covered by that
114 * test. Selected-row Gram systems must admit the configured inverse action.
115 */
117
118/** Bind the inequality storage already registered on the parent TAO.
119 *
120 * Call after selecting TAONULLSPACE and before TaoSetUp(). The shell retains
121 * PETSc references to all supplied objects, and releases them on a type change
122 * or parent destruction. The constraint DM carries application numbering and
123 * may be null for purely algebraic problems. A null preconditioner uses the
124 * Jacobian. Callbacks remain registered through the standard TAO setters.
125 */
126MoFEMErrorCode TaoNullSpaceSetConstraints(Tao tao, DM constraint_dm,
127 Vec constraints, Mat jacobian,
128 Mat preconditioner = nullptr);
129
130/** Borrow the owned inner TAO for configuration; do not destroy it.
131 * After parent TaoSetUp(), it has its own solution and gradient vectors and
132 * separate and combined objective/gradient callbacks for the frozen merit
133 *
134 * Phi(x) = alpha_j [f(x) - lambda_B^T c_B(x)]
135 * + alpha_c/2 c_R(x)^T S_R c_R(x).
136 *
137 * Here S_R = (C_R C_R^T)^(-1), and lambda_B is the projection multiplier
138 * obtained from the accepted-iterate binding Jacobian and objective gradient.
139 * These quantities remain fixed while trial f and c are evaluated. Trial
140 * gradients and Jacobians are evaluated only for gradient or combined
141 * callbacks; the inner gradient is the derivative of Phi, not a separately
142 * projected trial gradient.
143 *
144 * Callbacks require a frozen outer iterate established by TaoSolve(); calling
145 * them earlier returns PETSC_ERR_ARG_WRONGSTATE. Binding/restoration rows and
146 * projection data remain frozen until the inner solve returns. The default
147 * shell takes exactly one flow step. An explicitly selected iterative solver
148 * resets history between outer iterations and may use it within its configured
149 * inner solve. A retained inner TAO loses
150 * these callbacks when the parent context is destroyed or changes type.
151 */
153
154/** Borrow the inequality multiplier vector after TaoSetUp().
155 * It is initially zero and uses the parent constraint layout and the
156 * nonnegative-multiplier convention for c_i >= 0. Applications may initialise
157 * it as for TAOALMM; the outer solver updates it through nonnegative
158 * least-squares selection at each accepted iterate. The stationarity balance
159 * is grad f - J_c^T lambda = 0, so scaling a constraint also changes the units
160 * of its returned multiplier.
161 */
163
164} // namespace MoFEM
165
166#endif // MOFEM_TAO_NULL_SPACE_HPP
SmartPetscObj< Mat > jacobian
SmartPetscObj< Mat > preconditioner
SmartPetscObj< Tao > subsolver
SmartPetscObj< Vec > constraints
SmartPetscObj< Vec > multipliers
constexpr char TAONULLSPACE[]
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
implementation of Data Operators for Forces and Sources
Definition Common.hpp:10
MoFEMErrorCode TaoNullSpaceGetMultipliers(Tao tao, Vec *multipliers)
MoFEMErrorCode TaoNullSpaceSetConstraints(Tao tao, DM constraint_dm, Vec constraints, Mat jacobian, Mat preconditioner)
MoFEMErrorCode TaoNullSpaceGetSubsolver(Tao tao, Tao *subsolver)
MoFEMErrorCode TaoRegisterNullSpace()