1 |
|
|
#ifdef CROCODDYL_WITH_IPOPT |
2 |
|
|
|
3 |
|
|
#include "crocoddyl/core/solvers/ipopt.hpp" |
4 |
|
|
|
5 |
|
|
#include "python/crocoddyl/core/core.hpp" |
6 |
|
|
#include "python/crocoddyl/utils/copyable.hpp" |
7 |
|
|
|
8 |
|
|
namespace crocoddyl { |
9 |
|
|
namespace python { |
10 |
|
|
|
11 |
|
20 |
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(SolverIpopt_solves, SolverIpopt::solve, |
12 |
|
|
0, 5) |
13 |
|
|
|
14 |
|
10 |
void exposeSolverIpopt() { |
15 |
|
10 |
bp::register_ptr_to_python<boost::shared_ptr<SolverIpopt>>(); |
16 |
✓✗ |
10 |
bp::class_<SolverIpopt, bp::bases<SolverAbstract>>( |
17 |
|
|
"SolverIpopt", |
18 |
✓✗ |
10 |
bp::init<const boost::shared_ptr<crocoddyl::ShootingProblem>&>( |
19 |
|
20 |
bp::args("self", "problem"), "Initialize solver")) |
20 |
|
|
.def("solve", &SolverIpopt::solve, |
21 |
✓✗ |
10 |
SolverIpopt_solves( |
22 |
✓✗ |
20 |
bp::args("self", "init_xs", "init_us", "maxiter", "is_feasible", |
23 |
|
|
"init_reg"), |
24 |
|
|
"Compute the optimal trajectory xopt, uopt as lists of T+1 and " |
25 |
|
|
"T terms.\n\n" |
26 |
|
|
"From an initial guess init_xs,init_us (feasible or not), " |
27 |
|
|
"iterate\n" |
28 |
|
|
"over computeDirection and tryStep until stoppingCriteria is " |
29 |
|
|
"below\n" |
30 |
|
|
"threshold. It also describes the globalization strategy used\n" |
31 |
|
|
"during the numerical optimization.\n" |
32 |
|
|
":param init_xs: initial guess for state trajectory with T+1 " |
33 |
|
|
"elements (default []).\n" |
34 |
|
|
":param init_us: initial guess for control trajectory with T " |
35 |
|
|
"elements (default []) (default []).\n" |
36 |
|
|
":param maxiter: maximum allowed number of iterations (default " |
37 |
|
|
"100).\n" |
38 |
|
|
":param is_feasible: true if the init_xs are obtained from " |
39 |
|
|
"integrating the init_us (rollout) (default " |
40 |
|
|
"False).\n" |
41 |
|
|
":param init_reg: initial guess for the regularization value. " |
42 |
|
|
"Very low values are typical\n" |
43 |
|
|
" used with very good guess points (init_xs, " |
44 |
|
|
"init_us) (default None).\n" |
45 |
|
|
":returns the optimal trajectory xopt, uopt and a boolean that " |
46 |
✓✗ |
10 |
"describes if convergence was reached.")) |
47 |
|
|
.def("setStringIpoptOption", &SolverIpopt::setStringIpoptOption, |
48 |
✓✗ |
20 |
bp::args("self", "param_name", "param_value"), |
49 |
✓✗ |
10 |
"Sets a string option for IPOPT\n\n") |
50 |
|
|
.def("setNumericIpoptOption", &SolverIpopt::setNumericIpoptOption, |
51 |
✓✗ |
20 |
bp::args("self", "param_name", "param_value"), |
52 |
✓✗ |
10 |
"Sets a numeric option for IPOPT\n\n") |
53 |
✓✗ |
10 |
.add_property("th_stop", bp::make_function(&SolverIpopt::get_th_stop), |
54 |
✓✗ |
20 |
bp::make_function(&SolverIpopt::set_th_stop), |
55 |
✓✗ |
10 |
"threshold for stopping criteria") |
56 |
✓✗ |
10 |
.def(CopyableVisitor<SolverIpopt>()); |
57 |
|
10 |
} |
58 |
|
|
|
59 |
|
|
} // namespace python |
60 |
|
|
} // namespace crocoddyl |
61 |
|
|
|
62 |
|
|
#endif |