MFEM v4.9.0
Finite element discretization library
Loading...
Searching...
No Matches
ip.hpp
Go to the documentation of this file.
1// Copyright (c) 2010-2025, Lawrence Livermore National Security, LLC. Produced
2// at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3// LICENSE and NOTICE for details. LLNL-CODE-806117.
4//
5// This file is part of the MFEM library. For more information and source code
6// availability visit https://mfem.org.
7//
8// MFEM is free software; you can redistribute it and/or modify it under the
9// terms of the BSD-3 license. We welcome feedback and contributions, see file
10// CONTRIBUTING.md for details.
11
12#ifndef MFEM_IPSOLVER
13#define MFEM_IPSOLVER
14
15#include "optcontactproblem.hpp"
16
17namespace mfem
18{
19
20/**
21 * @class IPSolver
22 * @brief Class for interior-point solvers of contact-problems
23 * described by a OptContactProblem
24 *
25 * IPSolver is an implementation of a primal-dual interior-point
26 * algorithm as described in
27 * Wächter, Andreas, and Lorenz T. Biegler.
28 * "On the implementation of an interior-point filter line-search algorithm for large-scale nonlinear programming."
29 * Mathematical programming 106.1 (2006): 25-57.
30 *
31 * With inertia-free regularization as described in
32 * Chiang, Nai-Yuan, and Victor M. Zavala.
33 * "An inertia-free filter line-search algorithm for large-scale nonlinear programming."
34 * Computational Optimization and Applications 64.2 (2016): 327-354.
35 *
36 * This solver contains less solver options than say ipopt
37 * but the user has full control over the linear solver.
38 *
39 * This solver is intended to solve problems of the form
40 *
41 * $$ \min_{u, m} f(u, m) \qquad \text{s.t.} \quad c(u, m) = 0, m \geq 0 $$
42 *
43 * In the context of frictionless quasi-static
44 * contact mechanics for the displacement variable $d$
45 * and slack variable $s$ we have
46 *
47 * $$ \min_{d, s} E(d, s) \qquad \text{s.t.} \quad g(d) - s = 0, \; s \geq 0 $$
48 *
49 * ## Typical usage
50 * 1. Initialize IPSolver object.
51 * 2. Set solver options e.g., SetTol, SetMaxIter, SetLinearSolver
52 * 3. Use Mult to apply the solver.
53 */
55{
56public:
57 /// Construct interior-point solver
59
60 /// Apply the interior-point solver
61 void Mult(const Vector&, Vector &);
62
63 /// Apply the interior-point solver
64 void Mult(const BlockVector&, BlockVector&);
65
66 /// Set absolute tolerance
67 void SetTol(real_t tol) {abs_tol = tol;}
68
69 /// Set maximum number of interior-point steps
70 void SetMaxIter(int max_it) {max_iter = max_it;}
71
72 /// Set linear solver
73 void SetLinearSolver(Solver * solver_) { solver = solver_; };
74
75 /// Set print level
76 void SetPrintLevel(int print_level_) { print_level = print_level_; };
77
78 /// Get convergence status of most recent Mult call
79 bool GetConverged() const {return converged;}
80
81 /// get number of interior-point iterations of most recent Mult call
82 int GetNumIterations() {return iter;};
83
84 /// Get solver iteration counts
86
87 virtual ~IPSolver();
88protected:
89 /// OptContactProblem (not owned).
91
92 /// Linear solver (not owned)
93 Solver * solver = nullptr;
94
97 int iter=0;
100
101 /// interior-point algorithm parameters
104
105 // filter
107
108 // quantities computed in lineSearch
112 bool switchCondition = false;
113 bool sufficientDecrease = false;
114 bool lineSearchSuccess = false;
115
119
120 /// Operators (not owned)
121 HypreParMatrix * Huu = nullptr;
122 HypreParMatrix * Hmm = nullptr;
123 HypreParMatrix * Wuu = nullptr;
124 HypreParMatrix * Wmm = nullptr;
125 HypreParMatrix * Ju = nullptr;
126 HypreParMatrix * Jm = nullptr;
127 HypreParMatrix * JuT = nullptr;
128 HypreParMatrix * JmT = nullptr;
129
130 /// Lumped masses
134
135 /// inertia-regularization parameters
141
142 /// inertia-regularization rate parameters
146
148
149 bool converged = false;
150
151 int myid = -1;
152
153 /// print level, 0: no printing, > 0 various solver progress output is shown
154 int print_level = 0;
155 MPI_Comm comm;
156private:
157 /// Form (regularized) IP-Newton linear system matrix
158 void FormIPNewtonMat(BlockVector&, Vector&, Vector&, BlockOperator &,
159 real_t delta = 0.0);
160
161 /// Solve the (regularized) IP-Newton linear system
162 void IPNewtonSolve(BlockVector&, Vector&, Vector&, Vector&, BlockVector&,
163 bool &, real_t, real_t delta = 0.0);
164
165 /// Max step length that satisfies fraction-to-boundary rule
166 real_t GetMaxStepSize(Vector&, Vector&, real_t);
167
168 /// Globalizing line search
169 void LineSearch(BlockVector&, BlockVector&, real_t);
170
171 /// check if a point is acceptable to the filter
172 bool FilterCheck(real_t, real_t);
173
174 /// Project inequality constraint multiplier
175 void ProjectZ(const Vector &, Vector &, real_t);
176
177 /// Evaluate theta (equality constraint violation measure)
178 real_t GetTheta(const BlockVector &);
179
180 /// Evaluate log-barrier objective phi
181 real_t GetPhi(const BlockVector &, real_t, int eval_err = 0);
182
183 /// Gradient of log-barrier objective w.r.t. primal variables
184 void GetDxphi(const BlockVector &, real_t, BlockVector &);
185
186 /// Evaluate the primal-dual Lagrangian
187 real_t EvalLangrangian(const BlockVector &, const Vector &, const Vector &);
188
189 /// Gradient of the primal-dual Lagrangian w.r.t. primal variables
190 void EvalLagrangianGradient(const BlockVector &, const Vector &, const Vector &,
191 BlockVector &);
192
193 /// curvature test to detect negative-curvature
194 bool CurvatureTest(const BlockOperator & A, const BlockVector & Xhat,
195 const Vector &l, const BlockVector & b, const real_t & delta);
196
197 /// Compute the optimality error
198 real_t OptimalityError(const BlockVector &, const Vector &, const Vector &,
199 real_t mu = 0.0);
200 /// Update the barrier parameter
201 void UpdateBarrierSubProblem()
202 {
203 // reduced barrier parameter
204 mu_k = std::max(abs_tol / 10., std::min(kMu * mu_k, pow(mu_k, thetaMu)));
205 // clear subproblem filter
206 F1.DeleteAll();
207 F2.DeleteAll();
208 }
209};
210
211}
212
213#endif
void DeleteAll()
Delete the whole array.
Definition array.hpp:1033
A class to handle Block systems in a matrix-free implementation.
A class to handle Vectors in a block fashion.
Wrapper for hypre's ParCSR matrix class.
Definition hypre.hpp:419
Class for interior-point solvers of contact-problems described by a OptContactProblem.
Definition ip.hpp:55
bool GetConverged() const
Get convergence status of most recent Mult call.
Definition ip.hpp:79
int GetNumIterations()
get number of interior-point iterations of most recent Mult call
Definition ip.hpp:82
real_t tauMin
Definition ip.hpp:102
virtual ~IPSolver()
Definition ip.cpp:839
real_t deltaRegMin
Definition ip.hpp:138
real_t thetaMax
Definition ip.hpp:103
real_t kRegPlus
Definition ip.hpp:145
int print_level
print level, 0: no printing, > 0 various solver progress output is shown
Definition ip.hpp:154
Vector Mlump
Definition ip.hpp:133
real_t kMu
Definition ip.hpp:102
real_t deltaRegMax
Definition ip.hpp:139
OptContactProblem * problem
OptContactProblem (not owned).
Definition ip.hpp:90
Array< int > lin_solver_iterations
Definition ip.hpp:147
HypreParMatrix * JuT
Definition ip.hpp:127
Vector Mvlump
Definition ip.hpp:132
real_t thetaMin
Definition ip.hpp:102
Array< real_t > F2
Definition ip.hpp:106
real_t kRegMinus
inertia-regularization rate parameters
Definition ip.hpp:143
HypreParMatrix * JmT
Definition ip.hpp:128
bool lineSearchSuccess
Definition ip.hpp:114
void SetTol(real_t tol)
Set absolute tolerance.
Definition ip.hpp:67
real_t alphaCurvatureTest
inertia-regularization parameters
Definition ip.hpp:136
real_t deltaReg0
Definition ip.hpp:140
HypreParMatrix * Hmm
Definition ip.hpp:122
real_t kRegBarPlus
Definition ip.hpp:144
Vector Mcslump
Lumped masses.
Definition ip.hpp:131
void SetLinearSolver(Solver *solver_)
Set linear solver.
Definition ip.hpp:73
IPSolver(OptContactProblem *)
Construct interior-point solver.
Definition ip.cpp:17
real_t deltaRegLast
Definition ip.hpp:137
real_t gTheta
Definition ip.hpp:103
bool switchCondition
Definition ip.hpp:112
real_t thx0
Definition ip.hpp:110
real_t mu_k
Definition ip.hpp:98
Array< real_t > F1
Definition ip.hpp:106
HypreParMatrix * Ju
Definition ip.hpp:125
Array< int > constraint_offsets
Definition ip.hpp:117
real_t thetaMu
Definition ip.hpp:102
Array< int > block_offsetsx
Definition ip.hpp:118
Vector zlk
Definition ip.hpp:99
real_t alphaz
Definition ip.hpp:109
real_t eta
Definition ip.hpp:102
Array< int > & GetLinearSolverIterations()
Get solver iteration counts.
Definition ip.hpp:85
void SetPrintLevel(int print_level_)
Set print level.
Definition ip.hpp:76
void Mult(const Vector &, Vector &)
Apply the interior-point solver.
Definition ip.cpp:132
Array< int > block_offsetsumlz
Definition ip.hpp:118
real_t abs_tol
Definition ip.hpp:95
void SetMaxIter(int max_it)
Set maximum number of interior-point steps.
Definition ip.hpp:70
real_t alpha
Definition ip.hpp:109
HypreParMatrix * Huu
Operators (not owned)
Definition ip.hpp:121
real_t delta
Definition ip.hpp:102
bool converged
Definition ip.hpp:149
int max_iter
Definition ip.hpp:96
Vector lk
Definition ip.hpp:99
MPI_Comm comm
Definition ip.hpp:155
HypreParMatrix * Wuu
Definition ip.hpp:123
Array< int > block_offsetsuml
Definition ip.hpp:118
real_t sTheta
Definition ip.hpp:102
real_t kSig
interior-point algorithm parameters
Definition ip.hpp:102
real_t gPhi
Definition ip.hpp:103
HypreParMatrix * Wmm
Definition ip.hpp:124
real_t sPhi
Definition ip.hpp:102
Solver * solver
Linear solver (not owned)
Definition ip.hpp:93
HypreParMatrix * Jm
Definition ip.hpp:126
bool sufficientDecrease
Definition ip.hpp:113
real_t phx0
Definition ip.hpp:111
real_t kEps
Definition ip.hpp:103
Contact optimization problem with mortar and non-mortar interfaces.
Base class for solvers.
Definition operator.hpp:792
Vector data type.
Definition vector.hpp:82
real_t mu
Definition ex25.cpp:140
real_t b
Definition lissajous.cpp:42
float real_t
Definition config.hpp:46