46 "num_collect::ode::inexact_newton_update_equation_solver");
64template <concepts::differentiable_problem Problem>
83template <concepts::single_variate_differentiable_problem Problem>
86 inexact_newton_update_equation_solver<Problem>> {
103 static_assert(!problem_type::allowed_evaluations.mass,
104 "Mass matrix is not supported.");
157 constexpr auto exponent =
static_cast<scalar_type>(0.8);
158 constexpr auto min_rate =
static_cast<scalar_type>(0.5);
190 this->logger(),
"Initialization must be done before iterations.");
218 bool converged =
false;
229 return converged || (
iterations_ > max_iterations);
240 iteration_logger.template append<index_type>(
242 iteration_logger.template append<scalar_type>(
366template <concepts::multi_variate_differentiable_problem Problem>
367class inexact_newton_update_equation_solver<Problem>
369 inexact_newton_update_equation_solver<Problem>> {
386 static_assert(!problem_type::allowed_evaluations.mass,
387 "Mass matrix is not supported.");
407 template <
typename VariableExpression>
410 const Eigen::MatrixBase<VariableExpression>& variable,
422 lu_.compute(jacobian_type::Identity(dim, dim) -
435 template <
typename OffsetExpression>
442 constexpr auto exponent =
static_cast<scalar_type>(0.8);
443 constexpr auto min_rate =
static_cast<scalar_type>(0.5);
463 template <
typename OffsetExpression>
479 this->logger(),
"Initialization must be done before iterations.");
489 if (!
update_.array().isFinite().all()) {
491 "Failed to solve an equation. step_size={}, cond={}.",
512 bool converged =
false;
523 return converged || (
iterations_ > max_iterations);
534 iteration_logger.template append<index_type>(
536 iteration_logger.template append<scalar_type>(
592 problem_type* problem_{
nullptr};
598 scalar_type step_size_{};
601 scalar_type slope_coeff_{};
604 variable_type variable_{};
607 variable_type solution_offset_{};
610 variable_type* solution_{
nullptr};
613 Eigen::PartialPivLU<jacobian_type>
lu_{};
616 variable_type temp_variable_{};
619 variable_type residual_{};
622 variable_type update_{};
625 std::optional<scalar_type> update_norm_{};
628 std::optional<scalar_type> update_reduction_rate_{};
631 static constexpr auto default_tolerance_rate =
632 static_cast<scalar_type
>(1e-2);
635 scalar_type tolerance_rate_{default_tolerance_rate};
641 error_tolerances<variable_type> tolerances_{};
Definition of iterative_solver_base class.
Class of exception on failure in algorithm.
Base class of iterative solvers.
Class to write logs of iterations.
Class of tags of logs without memory management.
Class of error tolerances hairer1993.
void update_jacobian(problem_type &problem, scalar_type time, scalar_type step_size, const Eigen::MatrixBase< VariableExpression > &variable, scalar_type slope_coeff)
Update Jacobian and internal parameters.
static constexpr auto default_tolerance_rate
Default rate of tolerance in this solver.
typename problem_type::jacobian_type jacobian_type
Type of Jacobian.
typename problem_type::scalar_type scalar_type
Type of scalars.
variable_type residual_
Residual vector.
std::optional< scalar_type > update_reduction_rate_
Rate in which update is reduced from the previous step.
variable_type solution_offset_
Offset of the solution added to the term of slopes.
auto update_norm() const -> scalar_type
Get the norm of update.
inexact_newton_update_equation_solver()
Constructor.
void update_jacobian(problem_type &problem, scalar_type time, scalar_type step_size, const variable_type &variable, scalar_type slope_coeff)
Update Jacobian and internal parameters.
Eigen::PartialPivLU< jacobian_type > lu_
LU decomposition of the current coefficient matrix.
auto solution_offset() const -> const variable_type &
Get the offset of the solution added to the term of slopes.
void iterate()
Iterate the algorithm once.
scalar_type tolerance_rate_
Rate of tolerance in this solver.
std::optional< scalar_type > update_norm_
Norm of update.
auto iterations() const -> index_type
Get the number of iterations.
void init(const Eigen::MatrixBase< OffsetExpression > &solution_offset, variable_type &solution)
Initialize for solving an equation.
void configure_iteration_logger(logging::iterations::iteration_logger< this_type > &iteration_logger) const
Configure an iteration logger.
void configure_iteration_logger(logging::iterations::iteration_logger< inexact_newton_update_equation_solver< Problem > > &iteration_logger) const
Configure an iteration logger.
scalar_type slope_coeff_
Coefficient to multiply to slope in the equation.
auto tolerances(const error_tolerances< variable_type > &val) -> inexact_newton_update_equation_solver &
Set the error tolerances.
auto tolerances() const -> const error_tolerances< variable_type > &
Get the error tolerances.
typename problem_type::variable_type variable_type
Type of variables.
void init(const scalar_type &time, const Eigen::MatrixBase< OffsetExpression > &solution_offset, variable_type &solution)
Initialize for solving an equation.
inexact_newton_update_equation_solver< Problem > this_type
This class.
variable_type variable_
Variable.
variable_type update_
Update vector.
scalar_type step_size_
Step size.
void init(const variable_type &solution_offset, variable_type &solution)
Initialize for solving an equation.
index_type iterations_
Number of iterations.
void init(const scalar_type &time, const variable_type &solution_offset, variable_type &solution)
Initialize for solving an equation.
auto is_stop_criteria_satisfied() const -> bool
Determine if stopping criteria of the algorithm are satisfied.
problem_type * problem_
Pointer to the problem.
variable_type coeff_inverse_
Inverse of the current coefficient.
variable_type temp_variable_
Temporary variable.
Problem problem_type
Type of problem.
error_tolerances< variable_type > tolerances_
Error tolerances.
variable_type * solution_
Solution.
Class to solve equations of implicit updates using inexact Newton method.
Definition of differentiable_problem concept.
Definition of error_tolerances class.
Definition of evaluation_type enumeration.
Definition of exceptions.
Definition of index_type type.
Definition of iteration_logger class.
Definition of log_tag_view class.
Definition of macros for logging.
#define NUM_COLLECT_LOG_AND_THROW(EXCEPTION_TYPE,...)
Write an error log and throw an exception for an error.
Definition of multi_variate_differentiable_problem concept.
std::ptrdiff_t index_type
Type of indices in this library.
auto isfinite(const T &val) -> bool
Check whether a number is finite.
Namespace of solvers of ordinary differential equations (ODE).
constexpr auto inexact_newton_update_equation_solver_tag
Log tag.
Definition of NUM_COLLECT_PRECONDITION macro.
#define NUM_COLLECT_PRECONDITION(CONDITION,...)
Check whether a precondition is satisfied and throw an exception if not.
Definition of single_variate_differentiable_problem concept.
Struct to specify types of evaluations.