mosek_linprog.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
  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_LINPROG_H
  9. #define IGL_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. // Solve a linear program using mosek:
  17. //
  18. // min c'x
  19. // s.t. lc <= A x <= uc
  20. // lx <= x <= ux
  21. //
  22. // Inputs:
  23. // c #x list of linear objective coefficients
  24. // A #A by #x matrix of linear inequality constraint coefficients
  25. // lc #A list of lower constraint bounds
  26. // uc #A list of upper constraint bounds
  27. // lx #x list of lower variable bounds
  28. // ux #x list of upper variable bounds
  29. // Outputs:
  30. // x #x list of solution values
  31. // Returns 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. // Wrapper that keeps mosek environment alive (if licence checking is
  41. // becoming a bottleneck)
  42. IGL_INLINE bool mosek_linprog(
  43. const Eigen::VectorXd & c,
  44. const Eigen::SparseMatrix<double> & A,
  45. const Eigen::VectorXd & lc,
  46. const Eigen::VectorXd & uc,
  47. const Eigen::VectorXd & lx,
  48. const Eigen::VectorXd & ux,
  49. const MSKenv_t & env,
  50. Eigen::VectorXd & x);
  51. }
  52. #ifndef IGL_STATIC_LIBRARY
  53. # include "mosek_linprog.cpp"
  54. #endif
  55. #endif