Skip to content

Commit

Permalink
remove prints
Browse files Browse the repository at this point in the history
  • Loading branch information
Rojas Rafael committed Aug 25, 2021
1 parent e0e65b2 commit 9e51e8e
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 9 deletions.
17 changes: 9 additions & 8 deletions src/ipopt_problem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,26 @@ minimum_time_bouded_acceleration(gsplines::functions::FunctionExpression &_trj,
nlp.AddConstraintSet(diffeo_con);
nlp.AddConstraintSet(acc_con);
nlp.AddCostSet(cost_function);
nlp.PrintCurrent();

printf("-----------------------------\n");
printf("Number of variables %i \n", nlp.GetNumberOfOptimizationVariables());
printf("Number of constraints %i \n", nlp.GetNumberOfConstraints());
printf("-----------------------------\n");

// nlp.PrintCurrent();
/*
printf("-----------------------------\n");
printf("Number of variables %i \n", nlp.GetNumberOfOptimizationVariables());
printf("Number of constraints %i \n", nlp.GetNumberOfConstraints());
printf("-----------------------------\n");
*/
// 3. Instantiate ipopt solver
ifopt::IpoptSolver ipopt;
// 3.1 Customize the solver
ipopt.SetOption("linear_solver", "mumps");
ipopt.SetOption("jacobian_approximation", "exact");
ipopt.SetOption("hessian_approximation", "limited-memory");
ipopt.SetOption("print_level", 0);

// 4. Ask the solver to solve the problem
ipopt.Solve(nlp);
Eigen::VectorXd x = nlp.GetOptVariables()->GetValues();

printf("Ts = %lf sf = %lf ti = %lf\n", x(0), x(1), _ti);
// printf("Ts = %lf sf = %lf ti = %lf\n", x(0), x(1), _ti);

return get_diffeo(_ti, x(0), x(1));
}
Expand Down
27 changes: 27 additions & 0 deletions tests/minimum_time_bounded_acceleration.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <chrono> // for high_resolution_clock
#include <gsplines/BasisLegendre.hpp>
#include <gsplines/ipopt_solver.hpp>
#include <iostream>
Expand Down Expand Up @@ -64,5 +65,31 @@ int main() {
assert(vel_value < 1.0e-9);
assert(acc_value < 1.0e-9);

double mean_time = 0.0;
std::size_t number_of_tests = 200;
for (std::size_t _ = 0; _ < number_of_tests; _++) {
auto t1 = std::chrono::high_resolution_clock::now();
gsplines::functions::FunctionExpression _diffeo =
minimum_time_bouded_acceleration(trj, ti, 10);
gsplines::functions::FunctionExpression _diffeo_diff_1 = _diffeo.derivate();
gsplines::functions::FunctionExpression _diffeo_diff_2 =
_diffeo_diff_1.derivate();

double _T = diffeo.get_domain().second;

Eigen::VectorXd _time_span =
Eigen::VectorXd::LinSpaced((T - ti) / 0.01, ti, T);

Eigen::MatrixXd _diffeo_hist = diffeo(time_span);

Eigen::MatrixXd _diffeo_diff_1_hist = diffeo_diff_1(time_span);
Eigen::MatrixXd _diffeo_diff_2_hist = diffeo_diff_2(time_span);
auto t2 = std::chrono::high_resolution_clock::now();
std::chrono::duration<double, std::milli> ms_double = t2 - t1;
mean_time += ms_double.count();
}
mean_time /= number_of_tests;
assert(mean_time < 100.0);
printf("total execution time is %+14.7e\n", mean_time);
return 0;
}
1 change: 1 addition & 0 deletions tests/torque_constraint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ int main() {
Eigen::MatrixXd show_matrix(jac_nom.rows(), 1 + 3 * jac_nom.cols());
show_matrix << numerate, jac_nom, jac_test, err_mat;
std::cout << "\n ----- \n" << show_matrix << "\n ----- \n";
fflush(stdout);

double max_err =
err_mat.array().abs().maxCoeff() / jac_nom.array().abs().maxCoeff();
Expand Down

0 comments on commit 9e51e8e

Please sign in to comment.