py_active_set.cpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2017 Sebastian Koch <s.koch@tu-berlin.de> and Daniele Panozzo <daniele.panozzo@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. // Wrap the params struct
  9. py::class_<igl::active_set_params > active_set_params(m, "active_set_params");
  10. active_set_params
  11. .def("__init__", [](igl::active_set_params &m)
  12. {
  13. new (&m) igl::active_set_params();
  14. m.Auu_pd = false;
  15. m.max_iter = 100;
  16. m.inactive_threshold = igl::DOUBLE_EPS;
  17. m.constraint_threshold = igl::DOUBLE_EPS;
  18. m.solution_diff_threshold = igl::DOUBLE_EPS;
  19. })
  20. .def_readwrite("Auu_pd", &igl::active_set_params::Auu_pd)
  21. .def_readwrite("max_iter", &igl::active_set_params::max_iter)
  22. .def_readwrite("inactive_threshold", &igl::active_set_params::inactive_threshold)
  23. .def_readwrite("constraint_threshold", &igl::active_set_params::constraint_threshold)
  24. .def_readwrite("solution_diff_threshold", &igl::active_set_params::solution_diff_threshold)
  25. .def_readwrite("Auu_pd", &igl::active_set_params::Auu_pd)
  26. ;
  27. m.def("active_set", []
  28. (
  29. const Eigen::SparseMatrix<double>& A,
  30. const Eigen::MatrixXd& B,
  31. const Eigen::MatrixXi& known,
  32. const Eigen::MatrixXd& Y,
  33. const Eigen::SparseMatrix<double>& Aeq,
  34. const Eigen::MatrixXd& Beq,
  35. const Eigen::SparseMatrix<double>& Aieq,
  36. const Eigen::MatrixXd& Bieq,
  37. const Eigen::MatrixXd& lx,
  38. const Eigen::MatrixXd& ux,
  39. const igl::active_set_params& params,
  40. Eigen::MatrixXd& Z
  41. )
  42. {
  43. assert_is_VectorX("B",B);
  44. assert_is_VectorX("known",known);
  45. assert_is_VectorX("Y",Y);
  46. assert_is_VectorX("Beq",Beq);
  47. assert_is_VectorX("Bieq",Bieq);
  48. assert_is_VectorX("Z",Z);
  49. return igl::active_set(A,B,known,Y,Aeq,Eigen::VectorXd(Beq),Aieq,Bieq,lx,ux,params,Z);
  50. }, __doc_igl_active_set,
  51. py::arg("A"), py::arg("B"), py::arg("known"), py::arg("Y"), py::arg("Aeq"), py::arg("Beq")
  52. , py::arg("Aieq"), py::arg("Bieq"), py::arg("lx"), py::arg("ux"), py::arg("params"), py::arg("Z"));