9 #include "spdlog/spdlog.h" 
   15     m_Logger(std::move(logger)) {
 
   26     if(init.size() != n) {
 
   27         throw std::invalid_argument(
"Weight vector incompatible with problem size");
 
   30     auto start = std::chrono::steady_clock::now();
 
   32     result.Duration = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - start);
 
   52             result.
Duration = std::chrono::milliseconds(4242);    
 
   60         [[nodiscard]] 
long num_variables() const noexcept
 override { 
return 12; }
 
   64                                      Eigen::Ref<DenseRealVector> target)
 override {};
 
   83     SUBCASE(
"init vector verifier") {
 
   84         CHECK_THROWS(mnm.minimize(goal, vec));
 
   89         vec.resize(goal.num_variables());
 
   90         auto result = mnm.minimize(goal, vec);
 
   91         CHECK(result.Duration != std::chrono::milliseconds(4242));
 
   95     SUBCASE(
"result passing") {
 
   96         vec.resize(goal.num_variables());
 
   97         auto result = mnm.minimize(goal, vec);
 
   99         CHECK(result.FinalGrad == 5.0);
 
  100         CHECK(result.FinalValue == 2.0);
 
  101         CHECK(result.NumIters == 55);
 
A minimizer to be used in test cases that returns a fixed result.
MinimizationResult run(Objective &objective, Eigen::Ref< DenseRealVector > init) override
An Eigen vector with versioning information, to implement simple caching of results.
Class that models an optimization objective.
Minimizer(std::shared_ptr< spdlog::logger > logger={})
MinimizationResult minimize(objective::Objective &objective, Eigen::Ref< DenseRealVector > init)
virtual MinimizationResult run(objective::Objective &objective, Eigen::Ref< DenseRealVector > init)=0
std::shared_ptr< spdlog::logger > m_Logger
void set_logger(std::shared_ptr< spdlog::logger > logger)
sets the logger object that is used for progress tracking.
TEST_CASE("minimizer base class minimize")
@ DIVERGED
The optimization objective appears to be unbounded.
Main namespace in which all types, classes, and functions are defined.
types::DenseVector< real_t > DenseRealVector
Any dense, real values vector.
float real_t
The default type for floating point values.
An objective to be used in test cases. Does not do any computations, but just resturns constants.
void hessian_times_direction_unchecked(const HashVector &location, const DenseRealVector &direction, Eigen::Ref< DenseRealVector > target) override
void project_to_line_unchecked(const HashVector &location, const DenseRealVector &direction) override
real_t lookup_on_line(real_t position) override
Looks up the value of the objective on the line defined by the last call to project_to_line().
real_t value_unchecked(const HashVector &location) override
long num_variables() const noexcept override
void gradient_unchecked(const HashVector &location, Eigen::Ref< DenseRealVector > target) override
std::chrono::milliseconds Duration