45 "num_collect::ode::inexact_newton_slope_equation_solver");
61template <concepts::differentiable_problem Problem>
78template <concepts::single_variate_differentiable_problem Problem>
81 inexact_newton_slope_equation_solver<Problem>> {
98 static_assert(!problem_type::allowed_evaluations.mass,
99 "Mass matrix is not supported.");
149 constexpr auto exponent =
static_cast<scalar_type>(0.8);
150 constexpr auto min_rate =
static_cast<scalar_type>(0.5);
168 this->logger(),
"Initialization must be done before iterations.");
195 bool converged =
false;
206 return converged || (
iterations_ > max_iterations);
217 iteration_logger.template append<index_type>(
219 iteration_logger.template append<scalar_type>(
329template <concepts::multi_variate_differentiable_problem Problem>
330class inexact_newton_slope_equation_solver<Problem>
332 inexact_newton_slope_equation_solver<Problem>> {
349 static_assert(!problem_type::allowed_evaluations.mass,
350 "Mass matrix is not supported.");
370 template <
typename VariableExpression>
373 const Eigen::MatrixBase<VariableExpression>& variable,
385 lu_.compute(jacobian_type::Identity(dim, dim) -
398 constexpr auto exponent =
static_cast<scalar_type>(0.8);
399 constexpr auto min_rate =
static_cast<scalar_type>(0.5);
417 this->logger(),
"Initialization must be done before iterations.");
426 if (!
update_.array().isFinite().all()) {
428 "Failed to solve an equation. step_size={}, cond={}.",
449 bool converged =
false;
460 return converged || (
iterations_ > max_iterations);
471 iteration_logger.template append<index_type>(
473 iteration_logger.template append<scalar_type>(
520 problem_type* problem_{
nullptr};
526 scalar_type step_size_{};
529 scalar_type solution_coeff_{};
532 variable_type variable_{};
535 variable_type* solution_{
nullptr};
538 Eigen::PartialPivLU<jacobian_type>
lu_{};
541 variable_type temp_variable_{};
544 variable_type residual_{};
547 variable_type update_{};
550 std::optional<scalar_type> update_norm_{};
553 std::optional<scalar_type> update_reduction_rate_{};
556 static constexpr auto default_tolerance_rate =
557 static_cast<scalar_type
>(1e-2);
560 scalar_type tolerance_rate_{default_tolerance_rate};
566 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.
scalar_type solution_coeff_
Coefficient to multiply to solution in the equation.
typename problem_type::scalar_type scalar_type
Type of scalars.
Eigen::PartialPivLU< jacobian_type > lu_
LU decomposition of the current coefficient matrix.
variable_type update_
Update vector.
scalar_type tolerance_rate_
Rate of tolerance in this solver.
error_tolerances< variable_type > tolerances_
Error tolerances.
typename problem_type::jacobian_type jacobian_type
Type of Jacobian.
auto tolerances(const error_tolerances< variable_type > &val) -> inexact_newton_slope_equation_solver &
Set the error tolerances.
auto is_stop_criteria_satisfied() const -> bool
Determine if stopping criteria of the algorithm are satisfied.
Problem problem_type
Type of problem.
index_type iterations_
Number of iterations.
static constexpr auto default_tolerance_rate
Default rate of tolerance in this solver.
variable_type temp_variable_
Temporary variable.
inexact_newton_slope_equation_solver< Problem > this_type
This class.
std::optional< scalar_type > update_reduction_rate_
Rate in which update is reduced from the previous step.
void configure_iteration_logger(logging::iterations::iteration_logger< this_type > &iteration_logger) const
Configure an iteration logger.
void update_jacobian(problem_type &problem, scalar_type time, scalar_type step_size, const Eigen::MatrixBase< VariableExpression > &variable, scalar_type solution_coeff)
Update Jacobian and internal parameters.
scalar_type step_size_
Step size.
void iterate()
Iterate the algorithm once.
void update_jacobian(problem_type &problem, scalar_type time, scalar_type step_size, const variable_type &variable, scalar_type solution_coeff)
Update Jacobian and internal parameters.
variable_type coeff_inverse_
Inverse of the current coefficient.
void init(variable_type &solution)
Initialize for solving an equation.
std::optional< scalar_type > update_norm_
Norm of update.
variable_type * solution_
Solution.
typename problem_type::variable_type variable_type
Type of variables.
variable_type residual_
Residual vector.
auto update_norm() const -> scalar_type
Get the norm of update.
problem_type * problem_
Pointer to the problem.
auto iterations() const -> index_type
Get the number of iterations.
auto tolerances() const -> const error_tolerances< variable_type > &
Get the error tolerances.
variable_type variable_
Variable.
inexact_newton_slope_equation_solver()
Constructor.
Class to solve equations of implicit slopes 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_slope_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.