alpaqa guanaqo
Nonconvex constrained optimization
Loading...
Searching...
No Matches
gradient-checker.cpp File Reference
#include <alpaqa/config/config.hpp>
#include <alpaqa/problem/sparsity-conversions.hpp>
#include <alpaqa/util/print.hpp>
#include <guanaqo/demangled-typename.hpp>
#include <alpaqa-version.h>
#include "options.hpp"
#include "problem.hpp"
#include <Eigen/Sparse>
#include <algorithm>
#include <filesystem>
#include <fstream>
#include <iostream>
#include <random>
#include <span>
#include <stdexcept>
#include <string>
#include <string_view>
#include <tuple>
#include <type_traits>
Include dependency graph for gradient-checker.cpp:

Go to the source code of this file.

Classes

struct  CheckGradientsOpts

Functions

void print_usage (const char *a0)
auto split_once (std::string_view s, char tok='.')
 Split the string s on the first occurrence of tok.
auto get_problem_path (const char *const *argv)
void check_gradients (LoadedProblem &, std::ostream &, const CheckGradientsOpts &)
int main (int argc, const char *argv[])
void default_eval_lagrangian_gradient (const alpaqa::TypeErasedProblem< config_t > problem, crvec x, crvec y, rvec grad_L, rvec work_n)
auto default_eval_augmented_lagrangian_and_gradient (const alpaqa::TypeErasedProblem< config_t > &problem, crvec x, crvec y, crvec Σ, rvec grad_ψ, rvec work_n, rvec work_m) -> real_t
auto finite_diff (const std::function< real_t(crvec)> &f, crvec x)
auto finite_diff_hess_sparse (const std::function< void(crvec, rvec)> &grad_L, crvec x)
auto finite_diff_hess (const std::function< void(crvec, rvec)> &grad_L, crvec x)

Variables

const auto * docs

Class Documentation

◆ CheckGradientsOpts

struct CheckGradientsOpts
Collaboration diagram for CheckGradientsOpts:
Class Members
bool print_full
bool hessians
real_t scale_perturbations

Function Documentation

◆ print_usage()

void print_usage ( const char * a0)

Definition at line 62 of file gradient-checker.cpp.

Here is the caller graph for this function:

◆ split_once()

auto split_once ( std::string_view s,
char tok = '.' )

Split the string s on the first occurrence of tok.

Returns ("", s) if tok was not found.

Definition at line 88 of file gradient-checker.cpp.

Here is the caller graph for this function:

◆ get_problem_path()

auto get_problem_path ( const char *const * argv)

Definition at line 97 of file gradient-checker.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_gradients()

void check_gradients ( LoadedProblem & lproblem,
std::ostream & log,
const CheckGradientsOpts & opts )

Definition at line 275 of file gradient-checker.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( int argc,
const char * argv[] )

Definition at line 117 of file gradient-checker.cpp.

Here is the call graph for this function:

◆ default_eval_lagrangian_gradient()

void default_eval_lagrangian_gradient ( const alpaqa::TypeErasedProblem< config_t > problem,
crvec x,
crvec y,
rvec grad_L,
rvec work_n )

Definition at line 186 of file gradient-checker.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ default_eval_augmented_lagrangian_and_gradient()

auto default_eval_augmented_lagrangian_and_gradient ( const alpaqa::TypeErasedProblem< config_t > & problem,
crvec x,
crvec y,
crvec Σ,
rvec grad_ψ,
rvec work_n,
rvec work_m ) -> real_t

Definition at line 196 of file gradient-checker.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ finite_diff()

auto finite_diff ( const std::function< real_t(crvec)> & f,
crvec x )

Definition at line 216 of file gradient-checker.cpp.

Here is the caller graph for this function:

◆ finite_diff_hess_sparse()

auto finite_diff_hess_sparse ( const std::function< void(crvec, rvec)> & grad_L,
crvec x )

Definition at line 232 of file gradient-checker.cpp.

◆ finite_diff_hess()

auto finite_diff_hess ( const std::function< void(crvec, rvec)> & grad_L,
crvec x )

Definition at line 257 of file gradient-checker.cpp.

Here is the caller graph for this function:

Variable Documentation

◆ docs

const auto* docs
Initial value:
= R"==(
problem types:
dl: Dynamically loaded problem using the DLProblem class.
Specify the name of the registration function using the
problem.register option, e.g. problem.register=register_alpaqa_problem.
Further options can be passed to the problem using
problem.<key>[=<value>].
cs: Load a CasADi problem using the CasADiProblem class.
If a .tsv file with the same name as the shared library file exists,
the bounds and parameters will be loaded from that file. See
CasADiProblem::load_numerical_data for more details.
The problem parameter can be set using the problem.param option.
cu: Load a CUTEst problem using the CUTEstProblem class.
options:
--full-print
Print the full gradients.
--no-hessians
Do not check any Hessian matrices.
--seed=<seed>
Seed for the random number generator.
)=="

Definition at line 39 of file gradient-checker.cpp.