7#ifndef WEIGHT_OPTIMIZER_H
8#define WEIGHT_OPTIMIZER_H
10#include <ceres/dynamic_autodiff_cost_function.h>
11#include <ceres/dynamic_numeric_diff_cost_function.h>
12#include <ceres/loss_function.h>
13#include <ceres/solver.h>
14#include <ceres/tiny_solver.h>
41 auto operator()(Eigen::DenseBase<T>& parameters, Eigen::DenseBase<T>&
residuals)
const noexcept ->
void
43 return (*
this)(parameters.data(),
residuals.data());
72 std::reference_wrapper<Dataset const>
dataset_;
73 std::reference_wrapper<ArrayXf const>
y_true_;
87 if (program.get_n_weights() == 0)
96 ceres::TinySolver<CFType>
solver;
97 solver.options.max_num_iterations = 10;
99 typename decltype(
solver)::Parameters parameters = program.get_weights();
111 if (
solver.summary.final_cost <
solver.summary.initial_cost)
113 program.set_weights(parameters);
void bind_engine(py::module &m, string name)
< nsga2 selection operator for getting the front
auto NumResiduals() const -> size_t
std::reference_wrapper< Dataset const > dataset_
ResidualEvaluator(PT &program, Dataset const &dataset)
auto operator()(Eigen::DenseBase< T > ¶meters, Eigen::DenseBase< T > &residuals) const noexcept -> void
auto NumParameters() const -> size_t
std::reference_wrapper< PT > program_
auto operator()(T const *parameters, T *residuals) const -> bool
std::reference_wrapper< ArrayXf const > y_true_
void update(PT &program, const Dataset &dataset)
Update program weights using non-linear least squares.