random_search.h 993 B

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