mosek_linprog.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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_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:
  19. //
  20. // min c'x
  21. // s.t. lc <= A x <= uc
  22. // lx <= x <= ux
  23. //
  24. // Inputs:
  25. // c #x list of linear objective coefficients
  26. // A #A by #x matrix of linear inequality constraint coefficients
  27. // lc #A list of lower constraint bounds
  28. // uc #A list of upper constraint bounds
  29. // lx #x list of lower variable bounds
  30. // ux #x list of upper variable bounds
  31. // Outputs:
  32. // x #x list of solution values
  33. // Returns true iff success.
  34. IGL_INLINE bool mosek_linprog(
  35. const Eigen::VectorXd & c,
  36. const Eigen::SparseMatrix<double> & A,
  37. const Eigen::VectorXd & lc,
  38. const Eigen::VectorXd & uc,
  39. const Eigen::VectorXd & lx,
  40. const Eigen::VectorXd & ux,
  41. Eigen::VectorXd & x);
  42. // Wrapper that keeps mosek environment alive (if licence checking is
  43. // becoming a bottleneck)
  44. IGL_INLINE bool mosek_linprog(
  45. const Eigen::VectorXd & c,
  46. const Eigen::SparseMatrix<double> & A,
  47. const Eigen::VectorXd & lc,
  48. const Eigen::VectorXd & uc,
  49. const Eigen::VectorXd & lx,
  50. const Eigen::VectorXd & ux,
  51. const MSKenv_t & env,
  52. Eigen::VectorXd & x);
  53. }
  54. }
  55. #ifndef IGL_STATIC_LIBRARY
  56. # include "mosek_linprog.cpp"
  57. #endif
  58. #endif