mosek_linprog.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2015 Alec Jacobson <[email protected]>
  4. //
  5. // This Source Code Form is subject to the terms of the Mozilla Public License
  6. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  7. // obtain one at http://mozilla.org/MPL/2.0/.
  8. #ifndef IGL_MOSEK_MOSEK_LINPROG_H
  9. #define IGL_MOSEK_MOSEK_LINPROG_H
  10. #include "../igl_inline.h"
  11. #include <Eigen/Core>
  12. #include <Eigen/Sparse>
  13. #include <mosek.h>
  14. namespace igl
  15. {
  16. namespace mosek
  17. {
  18. /// Solve a linear program using mosek. Given in the form:
  19. ///
  20. /// min c'x
  21. /// s.t. lc <= A x <= uc
  22. /// lx <= x <= ux
  23. ///
  24. /// @param[in] c #x list of linear objective coefficients
  25. /// @param[in] A #A by #x matrix of linear inequality constraint coefficients
  26. /// @param[in] lc #A list of lower constraint bounds
  27. /// @param[in] uc #A list of upper constraint bounds
  28. /// @param[in] lx #x list of lower variable bounds
  29. /// @param[in] ux #x list of upper variable bounds
  30. /// @param[out] x #x list of solution values
  31. /// @return true iff success.
  32. IGL_INLINE bool mosek_linprog(
  33. const Eigen::VectorXd & c,
  34. const Eigen::SparseMatrix<double> & A,
  35. const Eigen::VectorXd & lc,
  36. const Eigen::VectorXd & uc,
  37. const Eigen::VectorXd & lx,
  38. const Eigen::VectorXd & ux,
  39. Eigen::VectorXd & x);
  40. /// \overload
  41. ///
  42. /// \brief Wrapper that keeps mosek environment alive (if licence checking is
  43. /// becoming a bottleneck)
  44. ///
  45. /// @param[in] env mosek environment
  46. IGL_INLINE bool mosek_linprog(
  47. const Eigen::VectorXd & c,
  48. const Eigen::SparseMatrix<double> & A,
  49. const Eigen::VectorXd & lc,
  50. const Eigen::VectorXd & uc,
  51. const Eigen::VectorXd & lx,
  52. const Eigen::VectorXd & ux,
  53. const MSKenv_t & env,
  54. Eigen::VectorXd & x);
  55. }
  56. }
  57. #ifndef IGL_STATIC_LIBRARY
  58. # include "mosek_linprog.cpp"
  59. #endif
  60. #endif