|
NASA Astrobee Robot Software
0.19.1
Flight software for the Astrobee robots operating inside the International Space Station.
|
Go to the documentation of this file.
19 #ifndef TRAJ_OPT_PRO_NONLINEAR_SOLVER_H_
20 #define TRAJ_OPT_PRO_NONLINEAR_SOLVER_H_
25 #include <Eigen/Sparse>
26 #include <Eigen/SparseCholesky>
27 #include <Eigen/SparseLU>
28 #ifdef EIGEN_USE_MKL_VML
29 #include <Eigen/PardisoSupport>
31 #include <boost/make_shared.hpp>
32 #include <boost/shared_ptr.hpp>
33 #include <opencv2/core/core.hpp>
34 #include <opencv2/highgui/highgui.hpp>
35 #include <opencv2/imgproc/imgproc.hpp>
44 typedef Eigen::Triplet<decimal_t>
ET;
45 typedef std::vector<ET>
ETV;
46 typedef Eigen::SparseMatrix<decimal_t>
SpMat;
58 explicit Variable(
int id_,
double val_ = 2.0)
59 : id(id_), val(val_) {}
70 const int getId()
const {
return id; }
75 typedef std::pair<Variable *, decimal_t>
EqPair;
80 std::vector<EqPair> coeff;
85 std::pair<ETV, ET> get_presolve();
127 std::vector<Variable> vars;
128 std::vector<boost::shared_ptr<IneqConstraint> > ineq_con;
129 std::vector<boost::shared_ptr<EqConstraint> > eq_con;
130 boost::shared_ptr<CostFunction> cost;
131 const uint max_vars_;
133 bool iterate_time(std::vector<Variable *> times);
135 bool specialized_presolve();
138 void updateInfo(std::vector<Variable *> times = std::vector<Variable *>());
140 void draw_matrix(
const SpMat &mat);
141 bool presolved_{
false};
148 if (max_vars_ > 10000)
throw std::runtime_error(
"License error!");
149 vars.reserve(max_vars_);
152 if (vars.size() == max_vars_) {
153 throw std::runtime_error(
154 "Requesting more variables than allocated. There be mem leaks "
158 Variable(
static_cast<int>(vars.size()), val));
159 return &(vars.at(vars.size() - 1));
165 void setCost(boost::shared_ptr<CostFunction> func) { cost = func; }
168 std::vector<Variable *> times = std::vector<Variable *>(),
169 int max_iterations = 200);
176 #endif // TRAJ_OPT_PRO_NONLINEAR_SOLVER_H_
std::vector< Variable * > vars
Definition: nonlinear_solver.h:105
Variable * addVar(decimal_t val=10.0)
Definition: nonlinear_solver.h:151
Definition: nonlinear_trajectory.h:45
friend std::ostream & operator<<(std::ostream &os, const Variable &var)
Definition: nonlinear_solver.cpp:48
Eigen::SparseMatrix< decimal_t > SpMat
Definition: nonlinear_solver.h:46
static ETV transpose(const ETV &vec)
Definition: nonlinear_solver.cpp:155
double decimal_t
Definition: types.h:35
std::vector< Variable * > vars
Definition: nonlinear_solver.h:121
Definition: nonlinear_solver.h:116
int id
Definition: nonlinear_solver.h:112
void addConstraint(boost::shared_ptr< IneqConstraint > con)
Definition: nonlinear_solver.cpp:139
const decimal_t getVal() const
Definition: nonlinear_solver.h:69
virtual decimal_t evaluate()=0
Definition: traj_data.h:74
Definition: msg_traj.h:27
Variable * var_u
Definition: nonlinear_solver.h:102
Variable * var_s
Definition: nonlinear_solver.h:103
void update_slack()
Definition: nonlinear_solver.cpp:92
std::pair< Variable *, decimal_t > EqPair
Definition: nonlinear_solver.h:75
SolverInfo solver_info
Definition: nonlinear_solver.h:170
Definition: nonlinear_solver.h:56
bool solve(bool verbose=false, decimal_t epsilon=1e-8, std::vector< Variable * > times=std::vector< Variable * >(), int max_iterations=200)
Definition: nonlinear_solver.cpp:459
Eigen::Triplet< decimal_t > ET
Definition: nonlinear_solver.h:44
virtual decimal_t evaluate()=0
Definition: nonlinear_solver.h:92
const int getId() const
Definition: nonlinear_solver.h:70
Definition: nonlinear_solver.h:125
Definition: nonlinear_solver.h:73
void setCost(boost::shared_ptr< CostFunction > func)
Definition: nonlinear_solver.h:165
friend std::ostream & operator<<(std::ostream &os, const EqConstraint &var)
Definition: nonlinear_solver.cpp:52
Eigen::Matrix< decimal_t, Eigen::Dynamic, 1 > VecD
Definition: types.h:49
NonlinearSolver(uint max_vars)
Definition: nonlinear_solver.h:147
std::vector< ET > ETV
Definition: nonlinear_solver.h:45
Definition: nonlinear_trajectory.h:80