grid_search.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #ifndef IGL_GRID_SEARCH_H
  2. #define IGL_GRID_SEARCH_H
  3. #include "igl_inline.h"
  4. #include <Eigen/Core>
  5. #include <functional>
  6. namespace igl
  7. {
  8. /// Global optimization via grid search. Solve the problem:
  9. ///
  10. /// minimize f(x)
  11. /// subject to lb ≤ x ≤ ub
  12. ///
  13. /// by exhaustive grid search.
  14. ///
  15. /// @param[in] f function to minimize
  16. /// @param[in] LB #X vector of finite lower bounds
  17. /// @param[in] UB #X vector of finite upper bounds
  18. /// @param[in] I #X vector of number of steps for each variable
  19. /// @param[out] X #X optimal parameter vector
  20. /// @return f(X)
  21. ///
  22. template <
  23. typename Scalar,
  24. typename DerivedX,
  25. typename DerivedLB,
  26. typename DerivedUB,
  27. typename DerivedI>
  28. IGL_INLINE Scalar grid_search(
  29. const std::function< Scalar (DerivedX &) > f,
  30. const Eigen::MatrixBase<DerivedLB> & LB,
  31. const Eigen::MatrixBase<DerivedUB> & UB,
  32. const Eigen::MatrixBase<DerivedI> & I,
  33. DerivedX & X);
  34. }
  35. #ifndef IGL_STATIC_LIBRARY
  36. # include "grid_search.cpp"
  37. #endif
  38. #endif