.. _program_listing_file_environment_plasma_tec_neldermead.h: Program Listing for File neldermead.h ===================================== |exhale_lsh| :ref:`Return to documentation for file ` (``environment/plasma/tec/neldermead.h``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp #pragma once #include #include #include #include #include #include "lupnt/environment/plasma/core/definitions.h" // Vec2d definition namespace pecsim { struct SimplexVertex { Vec2d x; double fval; }; class NelderMead { public: NelderMead(std::function func); NelderMead(std::function func, Vec2d x0, double step = 1.0, bool debug = false); Vec2d minimize(int max_iters = 200, double tol = 1e-6, double fval_tol = 0.0, bool debug = false); void set_initial_simplex(Vec2d x0, double step = 1.0, bool debug = false); void set_initial_simplex(Vec2d x0, double f0, double step = 1.0, bool debug = false); int get_iter() const { return iter_; } double get_min_val() const { return min_val_; } private: int iter_ = 0; // Current iteration number double min_val_ = 0.0; // Minimum function value found std::function f; std::array simplex; Vec2d mean_point(const std::array& points); Vec2d reflect(const Vec2d& c, const Vec2d& worst, double alpha = 1.0); Vec2d expand(const Vec2d& c, const Vec2d& reflected, double gamma = 2.0); Vec2d contract(const Vec2d& c, const Vec2d& worst, double rho = 0.5); void shrink(double sigma = 0.5); }; }; // namespace pecsim