alpaqa 1.0.0a17
Nonconvex constrained optimization
Loading...
Searching...
No Matches
Classes | Functions | Variables
gradient-checker.cpp File Reference
#include <alpaqa/config/config.hpp>
#include <alpaqa/problem/sparsity-conversions.hpp>
#include <alpaqa/util/demangled-typename.hpp>
#include <alpaqa/util/print.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[])
 
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

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 241 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 116 of file gradient-checker.cpp.

+ Here is the call graph for this function:

◆ finite_diff()

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

Definition at line 182 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 198 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 223 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.