grid_search.h 969 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. // Solve the problem:
  9. //
  10. // minimize f(x)
  11. // subject to lb ≤ x ≤ ub
  12. //
  13. // by exhaustive grid search.
  14. //
  15. // Inputs:
  16. // f function to minimize
  17. // LB #X vector of finite lower bounds
  18. // UB #X vector of finite upper bounds
  19. // I #X vector of number of steps for each variable
  20. // Outputs:
  21. // X #X optimal parameter vector
  22. // Returns f(X)
  23. //
  24. template <
  25. typename Scalar,
  26. typename DerivedX,
  27. typename DerivedLB,
  28. typename DerivedUB,
  29. typename DerivedI>
  30. IGL_INLINE Scalar grid_search(
  31. const std::function< Scalar (DerivedX &) > f,
  32. const Eigen::MatrixBase<DerivedLB> & LB,
  33. const Eigen::MatrixBase<DerivedUB> & UB,
  34. const Eigen::MatrixBase<DerivedI> & I,
  35. DerivedX & X);
  36. }
  37. #ifndef IGL_STATIC_LIBRARY
  38. # include "grid_search.cpp"
  39. #endif
  40. #endif