ocra-recipes
Doxygen documentation for the ocra-recipes repository
OneLevelSolver.cpp
Go to the documentation of this file.
2 
3 using namespace ocra;
4 
5 
6 
7 
12  : ocra::Solver()
13  , ocra::NamedInstance("OneLevelSolver")
14  , ni(0),ne(0)
15 {
16 }
17 
22 {
23 
24 }
25 
31 {
32  std::cout<<"TODO: 'printValuesAtSolution' method not implemented yet!"<<std::endl;
33 }
34 
41 // void OneLevelSolver::addObjective(ObjectiveType& obj)
42 // {
43 // internalAddObjective(obj);
44 // _objectives.push_back(&obj);
45 // }
46 
53 // void OneLevelSolver::removeObjective(ObjectiveType& obj)
54 // {
55 // internalRemoveObjective(obj);
56 // _objectives.erase(std::find(_objectives.begin(), _objectives.end(), &obj));
57 // }
58 
66 {
67  internalAddConstraint(constraint);
68  if(constraint.isEquality())
69  _equalityConstraints.push_back(&constraint);
70  else
71  _inequalityConstraints.push_back(&constraint);
72 }
73 
79 {
80  internalRemoveConstraint(constraint);
81  if(constraint.isEquality())
82  _equalityConstraints.erase(std::find(_equalityConstraints.begin(), _equalityConstraints.end(), &constraint));
83  else
84  _inequalityConstraints.erase(std::find(_inequalityConstraints.begin(), _inequalityConstraints.end(), &constraint));
85 }
86 
87 
88 
89 
94 {
95  Xsolution.resize(n());
96 }
97 
107 {
108  // prepareRecorder.initializeTime();
109 
110  prepareMatrices();
113 
114  // prepareRecorder.saveRelativeTime();
115 }
116 
122 {
123 
124 }
125 
126 
137 void OneLevelSolver::writePerformanceInStream(std::ostream& outstream, bool addCommaAtEnd)
138 {
139  // prepareRecorder.writeInStream("solver_prepare", outstream, true);
140  // solveRecorder.writeInStream("solver_solve", outstream, addCommaAtEnd);
141 }
142 
147 
168 void OneLevelSolver::reduceConstraints(const Eigen::MatrixXd& A, const Eigen::VectorXd& b, Eigen::MatrixXd& Ar, Eigen::VectorXd& br, double tolerance)
169 {
170  if (A.rows()>0)
171  {
172  Eigen::JacobiSVD<Eigen::MatrixXd> svdOfMat(A, Eigen::ComputeThinU | Eigen::ComputeThinV);
173  Eigen::VectorXd S = svdOfMat.singularValues();
174  Eigen::MatrixXd Ur = svdOfMat.matrixU();
175  Eigen::MatrixXd Vr = svdOfMat.matrixV();
176 
177  int r;
178  for (r = 0; r<S.size(); r++)
179  {
180  if (S[r] <= tolerance)
181  break;
182  }
183 
184  Eigen::VectorXd Sr = S.segment(0,r);
185  Ur.conservativeResize(Eigen::NoChange, r);
186  Vr.conservativeResize(Eigen::NoChange, r);
187 
188  Ar = Sr.asDiagonal() * Vr.transpose();
189  br = Ur.transpose() * b;
190  }
191  else
192  {
193  Ar = A;
194  br = b;
195  }
196 }
197 
198 
199 //#include <sstream>
200 
206 {
207  std::stringstream ss;
208  ss<<"-----------------------------------------------\n";
209  ss<<"probvar:\n";
211  ss<<"C:\n"<<_C<<"\n";
212  ss<<"d:\n"<<-_d.transpose()<<"\n";
213  ss<<"\n";
214  ss<<"A:\n"<<_Atotal<<"\n";
215  ss<<"b:\n"<<-_btotal.transpose()<<"\n";
216  ss<<"\n";
217  ss<<"G:\n"<<_G<<"\n";
218  ss<<"h:\n"<<-_h.transpose()<<"\n";
219 
220  return ss.str();
221 
222 }
223 
224 
225 
226 
228 //
229 // Hierarchy Solver with QuadProg sub-Solver
230 //
232 
237  : ocra::NamedInstance("One Level Solver with QuadProg++ subSolver")
238  , OneLevelSolver()
239 {
240  std::cout << "-- " << getName() << " --" << std::endl;
241 }
242 
247 {
248 
249 }
250 
255 {
256 // _C = _Pbase;
257  _C.setZero(n(), n());
258  _d.setZero(n());
259 
260  for(auto& obj : _objectives)
261  {
262 
263  auto& f = obj->getFunction();
264  double weight = obj->getWeight();
265 
266  const std::vector<int>& objMap = findMapping(f.getVariable());
267 
268  ocra::utils::addCompressed2d( f.getPi(), _C, objMap, weight);
269  ocra::utils::addCompressedByRow(f.getqi(), _d, objMap, weight);
270 
271  }
272 
273 }
274 
279 {
280  this->mutex.lock();
281  // UPDATE EQUALITY CONSTRAINTS
282  this->ne = 0;
283  int initialSize = (int) _equalityConstraints.size();
284  for (int i=0; i<_equalityConstraints.size(); ++i)
285  ne += _equalityConstraints[i]->getDimension();
286 
287 // OCRA_WARNING("Going to update constraints with " << ne << " equalities and " << n() <<" variables");
288 
289  _A.resize(ne, n()); _A.setZero();
290  _b.resize(ne); _b.setZero();
291 
292  int initialRows = ne;
293 
294  int idx = 0;
295  for (int i=0; i<_equalityConstraints.size(); ++i)
296  {
297  // WARNING The size of _equalityConstraints may change after _A has been resized before this for-loop
298  // if a new request for a contact task deactivation arrives. The ocra::Task class would update the size
299  // of _equalityConstraints thus making this for-loop access add more rows to _A than originally intended,
300  // thus causing a memory corruption and crashing the server.
301 // std::cout << "Going to access constraint: " << i << std::endl;
303  int dim = cstr->getDimension();
304 // std::cout << "Dimension obtained: " << dim << std::endl;
305  if (dim > 0)
306  {
307  if (_equalityConstraints.size() != initialSize) {
308  OCRA_ERROR("The size of equality constraints changed after _A had been resized.");
309  std::cout << "Initial number of equality constraints was: " << initialSize << std::endl;
310  std::cout << "New size of equality constraints is: " << _equalityConstraints.size() << std::endl;
311  std::cout << "Resizing A accordingly... " << std::endl;
312  // First copy current A with the initial size into a temporary
313  Eigen::MatrixXd Atmp(initialRows, n());
314  Atmp = _A.block(0,0,initialRows, n());
315  // Then get the new number of rows
316  for (int i=0; i<_equalityConstraints.size(); ++i)
317  ne += _equalityConstraints[i]->getDimension();
318  // Resize _A accordingly
319  _A.resize(ne, n());
320  // Copy the previous content
321  _A.block(0,0,initialRows, n()) = Atmp;
322  initialSize = _equalityConstraints.size();
323  }
324 
325  Eigen::Block<Eigen::MatrixXd> _A_block = _A.block(idx, 0, dim, n());
326  Eigen::VectorBlock<Eigen::VectorXd> _b_segment = _b.segment(idx, dim);
327 
328  Eigen::VectorXd v; // ?? is it useless ??
329  ocra::utils::convert(*cstr, findMapping(cstr->getVariable()), ocra::CSTR_PLUS_EQUAL, _A_block, _b_segment, v);
330 
331  if (_equalityConstraints.size() != 1 && i > 0) {
332 // std::cout << "Equality constraint (" << i << ") is of size: " << dim << "x" << n() << std::endl;
333 // std::cout << "_A equality: \n " << _A_block << std::endl;
334  }
335 
336  idx += dim;
337  }
338 
339  }
340 
342  this->mutex.unlock();
343 
344 
345 
346  // UPDATE INEQUALITY CONSTRAINTS
347  this->ni = 0;
348  for (int i=0; i<_inequalityConstraints.size(); ++i)
349  {
350  ni += _inequalityConstraints[i]->getDimension();
351  }
352 
353  _G.setZero(ni, n());
354  _h.setZero(ni);
355 
356  idx = 0;
357  for (int i=0; i<_inequalityConstraints.size(); ++i)
358  {
360  int dim = cstr->getDimension();
361 
362  if (dim > 0)
363  {
364  Eigen::Block<Eigen::MatrixXd > _G_block = _G.block(idx, 0, dim, n());
365  Eigen::VectorBlock<Eigen::VectorXd> _h_segment = _h.segment(idx, dim);
366  Eigen::VectorXd v; // ?? is it useless ??
367  ocra::utils::convert(*cstr, findMapping(cstr->getVariable()), ocra::CSTR_PLUS_GREATER, _G_block, _h_segment, v);
368 
369  idx += dim;
370  }
371 
372  }
373 }
374 
375 
380 {
381  // solveRecorder.initializeTime();
382 
384 
386  _result.info = ocra::RETURN_SUCCESS; //TODO: should be dfined through the result of the QuadProgPP::solve_quadprog
387 
388  // solveRecorder.saveRelativeTime();
389 }
390 
391 
392 //#ifdef USE_QPOASES
394 
396 : ocra::NamedInstance("One Level Solver with qpOASES")
397 , OneLevelSolver()
398 , _nWSR_every_run(200) // NOTE: totally random value
399 {
400  std::cout << "-- " << getName() << " -- "<<this<< std::endl;
401  sqp_options.setToMPC();
402  sqp_options.enableRegularisation = qpOASES::BT_TRUE;
403  sqp_options.enableEqualities = qpOASES::BT_TRUE;
404 }
405 
407 {
408  // UPDATE EQUALITY CONSTRAINTS
409  this->ne = 0;
410  for (int i=0; i<_equalityConstraints.size(); ++i)
411  ne += _equalityConstraints[i]->getDimension();
412 
413  _A.setZero(ne, n());
414  _lbA.setZero(ne);
415  _ubA.setZero(ne);
416 
417  for (int i=0,idx=0; i<_equalityConstraints.size(); ++i)
418  {
420  int dim = cstr->getDimension();
421 
422  if (dim > 0)
423  {
424  Eigen::Block<Eigen::MatrixXd> _A_block = _A.block(idx, 0, dim, n());
425  Eigen::VectorBlock<Eigen::VectorXd> _ubA_segment = _ubA.segment(idx, dim);
426  Eigen::VectorXd v;
427  ocra::utils::convert(*cstr, findMapping(cstr->getVariable()), ocra::CSTR_MINUS_EQUAL, _A_block, _ubA_segment, v);
428 
429  idx += dim;
430  }
431 
432  }
433 
434  _lbA = _ubA;
435 
436  // UPDATE INEQUALITY CONSTRAINTS
437  this->ni = 0;
438  for (int i=0; i<_inequalityConstraints.size(); ++i)
439  ni += _inequalityConstraints[i]->getDimension();
440 
441  _G.setZero(ni, n());
442  _lbG.setZero(ni);
443  _ubG.setZero(ni);
444 
445  for (int i=0,idx=0; i<_inequalityConstraints.size(); ++i)
446  {
448  int dim = cstr->getDimension();
449 
450  if (dim > 0)
451  {
452  Eigen::Block<Eigen::MatrixXd > _G_block = _G.block(idx, 0, dim, n());
453 
454  Eigen::VectorBlock<Eigen::VectorXd> _lbG_segment = _lbG.segment(idx, dim);
455  Eigen::VectorBlock<Eigen::VectorXd> _ubG_segment = _ubG.segment(idx, dim);
456 
457  // So we have _lbG_segment < _G_block.x < _ubG_segment
458  ocra::utils::convert(*cstr,findMapping(cstr->getVariable()),ocra::CSTR_DOUBLE_BOUNDS,_G_block,_ubG_segment,_lbG_segment,1e6);
459 
460  idx += dim;
461  }
462 
463  }
464 
465  // Verification
466  for(int i=0;i<_lbG.size();i++)
467  {
468  if(_lbG[i] > _ubG[i])
469  {
470 
471  std::cout << "[ERROR] Lower bound "<<i<<"("<<_lbG[i]<<") higher than upper ("<<_ubG[i]<<")"<<std::endl;
472  double tmp = _lbG[i];
473  _lbG[i] = _ubG[i];
474  _ubG[i] = tmp;
475 
476  }
477  }
478  // Combining Matrices
479  if ( ( _AandG.rows() != _A.rows()+_G.rows() ) || ( _AandG.cols() != _A.cols() ) )
480  {
481  _ubAandG.resize(_ubA.size() + _ubG.size());
482  _lbAandG.resize(_lbA.size() + _lbG.size());
483  _AandG.resize(_A.rows()+_G.rows(),n());
484  }
485 
486 
487  _AandG.topRows(_A.rows()) = _A;
488  _AandG.bottomRows(_G.rows()) = _G;
489 
490  _ubAandG.head(_ubA.size()) = _ubA;
491  _ubAandG.tail(_ubG.size()) = _ubG;
492 
493  _lbAandG.head(_lbA.size()) = _lbA;
494  _lbAandG.tail(_lbG.size()) = _lbG;
495 
496  if (_xl.size() != n())
497  {
498  _xl = - 1e6 * Eigen::VectorXd::Ones(n()); // X lower bound
499  _xu = 1e6 * Eigen::VectorXd::Ones(n()); // X upper bound
500 
501  }
502 
503  A = _AandG.data();
504  ubA = _ubAandG.data();
505  lbA = _lbAandG.data();
506  lb = _xl.data();
507  ub = _xu.data();
508  //std::cout << "G\n"<<_G<<std::endl;
509 // std::cout << "A : \n"<<_A<<std::endl<<std::endl;
510 // std::cout << "_AandG : \n"<<_AandG<<std::endl<<std::endl;
511 // std::cout << "_ubAandG: "<<_ubAandG.transpose()<<std::endl;
512 // std::cout << "_lbAandG: "<<_lbAandG.transpose()<<std::endl;
513 // std::cout << "_ubG: "<<_ubG.transpose()<<std::endl;
514 // std::cout << "_lbG: "<<_lbG.transpose()<<std::endl;
515 // std::cout << "_xl: "<<_xl.transpose()<<std::endl;
516 // std::cout << "_xu: "<<_xu.transpose()<<std::endl;
517 }
518 
520 {
521  _C.setZero(n(), n());
522  _d.setZero(n());
523 
524  for(int i=0; i<_objectives.size(); i++)
525  {
526 
527  ocra::QuadraticFunction& obj = _objectives[i]->getFunction();
528  double weight = _objectives[i]->getWeight();
529  const std::vector<int>& objMap = findMapping(obj.getVariable());
530 
531  ocra::utils::addCompressed2d( obj.getPi(), _C, objMap, weight);
532  ocra::utils::addCompressedByRow(obj.getqi(), _d, objMap, weight);
533 
534  }
535 
536 
537  if(H.size() != _C.rows()*_C.cols())
538  H.resize(_C.rows()*_C.cols());
539 
540  if(_RegTerm.cols() != _C.cols() || _RegTerm.rows() != _C.rows())
541  _RegTerm = 1.e-8*Eigen::MatrixXd::Identity(_C.rows(),_C.cols());
542 
543  Eigen::Map<MatrixXdRm>(H.data(),_C.rows(),_C.cols()) = _C /*+ _RegTerm*/;
544  _d *= -1.0; // TODO: Find out why everybody's doing this :/
545  g = _d.data();
546 }
548 {
549  switch(ret)
550  {
551  case qpOASES::SUCCESSFUL_RETURN:
552  return ocra::RETURN_SUCCESS;
553  case qpOASES::RET_QP_INFEASIBLE:
555  default:
556  return ocra::RETURN_ERROR;
557  }
558 }
559 
561 {
562  static bool first_time;
563 
564  if(!sqp_prob || sqp_prob->getNV() != n() || sqp_prob->getNC() != (ni+ne))
565  {
566  std::cout << "Creating "<<getName()<<" Solver with params : n:"<<n()<<" ni:"<<ni<<" ne:"<<ne<<std::endl;
567  sqp_prob.reset(new qpOASES::SQProblem(n(),ni+ne,qpOASES::HST_POSDEF));
568  sqp_prob->setOptions( sqp_options );
569  sqp_prob->setPrintLevel(qpOASES::PL_NONE);
570  first_time = true;
571  }
572 
573 
574  //sqp_prob->printProperties();
575  qpOASES::returnValue ret;
577  if(first_time){
578  ret = sqp_prob->init( H.data(),g,A,lb,ub,lbA,ubA, nWSR,NULL);
579  if(ret == qpOASES::SUCCESSFUL_RETURN)
580  first_time = false;
581  }else{
582  ret = sqp_prob->hotstart( H.data(),g,A,lb,ub,lbA,ubA, nWSR,NULL);
583  }
584  if(ret == qpOASES::SUCCESSFUL_RETURN)
585  sqp_prob->getPrimalSolution(_result.solution.data());
586 // else
587 // _result.solution = Eigen::VectorXd::Zero(n());
588  _result.info = toOcraRetValue(ret);
589 }
590 
591 //#endif
592 
593 
594 
596 
601  : ocra::NamedInstance("One Level Solver with QLD subSolver")
602  , OneLevelSolver()
603  , _QLDsolver( new ocra::ObjQLD() )
604  , MapP(NULL, 0,0)
605  , Mapq(NULL,0)
606  , MapAandG(NULL,0,0)
607  , Mapbandh(NULL,0)
608  , MapXsol(NULL,0)
609  , MapXl(NULL,0)
610  , MapXu(NULL,0)
611 {
612  std::cout << "-- " << getName() << " --" << std::endl;
613 }
614 
619 {
620 
621 }
622 
623 
624 
629 {
630 // _C = _Pbase;
631  _C.setZero(n(), n());
632  _d.setZero(n());
633 
634  if (MapP.size() != _C.size())
635  {
636  new (&MapP) MatrixMap(_C.data(), _C.rows(), _C.cols());
637  new (&Mapq) VectorMap(_d.data(), _d.size());
638  }
639 
640  for(int i=0; i<_objectives.size(); i++)
641  {
642 
643  ocra::QuadraticFunction& obj = _objectives[i]->getFunction();
644  double weight = _objectives[i]->getWeight();
645  const std::vector<int>& objMap = findMapping(obj.getVariable());
646 
647  ocra::utils::addCompressed2d( obj.getPi(), _C, objMap, weight);
648  ocra::utils::addCompressedByRow(obj.getqi(), _d, objMap, weight);
649 
650  }
651 
652 }
653 
658 {
659  // UPDATE EQUALITY CONSTRAINTS
660  this->ne = 0;
661  for (int i=0; i<_equalityConstraints.size(); ++i)
662  {
663  ne += _equalityConstraints[i]->getDimension();
664  }
665 
666  _A.setZero(ne, n());
667  _b.setZero(ne);
668 
669  int idx = 0;
670  for (int i=0; i<_equalityConstraints.size(); ++i)
671  {
673  int dim = cstr->getDimension();
674 
675  if (dim > 0)
676  {
677  Eigen::Block<Eigen::MatrixXd> _A_block = _A.block(idx, 0, dim, n());
678  Eigen::VectorBlock<Eigen::VectorXd> _b_segment = _b.segment(idx, dim);
679 
680  Eigen::VectorXd v; // ?? is it useless ??
681  ocra::utils::convert(*cstr, findMapping(cstr->getVariable()), ocra::CSTR_PLUS_EQUAL, _A_block, _b_segment, v);
682 
683  idx += dim;
684  }
685 
686  }
687 
689 
690 
691 
692  // UPDATE INEQUALITY CONSTRAINTS
693  this->ni = 0;
694  for (int i=0; i<_inequalityConstraints.size(); ++i)
695  {
696  ni += _inequalityConstraints[i]->getDimension();
697  }
698 
699  _G.setZero(ni, n());
700  _h.setZero(ni);
701 
702  idx = 0;
703  for (int i=0; i<_inequalityConstraints.size(); ++i)
704  {
706  int dim = cstr->getDimension();
707 
708  if (dim > 0)
709  {
710  Eigen::Block<Eigen::MatrixXd > _G_block = _G.block(idx, 0, dim, n());
711  Eigen::VectorBlock<Eigen::VectorXd> _h_segment = _h.segment(idx, dim);
712  Eigen::VectorXd v; // ?? is it useless ??
713  ocra::utils::convert(*cstr, findMapping(cstr->getVariable()), ocra::CSTR_PLUS_GREATER, _G_block, _h_segment, v);
714 
715  idx += dim;
716  }
717 
718  }
719 
720  if ( ( AandG.rows() != _Atotal.rows()+_G.rows() ) || ( AandG.cols() != _Atotal.cols() ) )
721  {
722  AandG.resize(_Atotal.rows()+_G.rows(), n());
723  bandh.resize(_btotal.size()+_h.size());
724  new (&MapAandG) MatrixMap(AandG.data(), AandG.rows(), AandG.cols());
725  new (&Mapbandh) VectorMap(bandh.data(), bandh.size());
726  }
727  AandG.topRows(_Atotal.rows()) = _Atotal;
728  AandG.bottomRows(_G.rows()) = _G;
729  bandh.head(_btotal.size()) = _btotal;
730  bandh.tail(_h.size()) = _h;
731 
732  if (_xl.size() != n())
733  {
734  _xl = - 1e10 * Eigen::VectorXd::Ones(n()); // X lower bound
735  _xu = 1e10 * Eigen::VectorXd::Ones(n()); // X upper bound
736  new (&MapXl) VectorMap(_xl.data(), _xl.size());
737  new (&MapXu) VectorMap(_xu.data(), _xu.size());
738  new (&MapXsol) VectorMap(Xsolution.data(), Xsolution.size()); // if bounds have changed, so has Xsolution
739  }
740 }
741 
742 
747 {
748  // solveRecorder.initializeTime();
749 
750 
751 // if (MapXsol.size() != Xsolution.size()) // this test is done in #updateConstraintEquations()
752 // new (&MapXsol) VectorMap(Xsolution.data(), Xsolution.size());
753 
754  _d = -_d; // this is to set -Mapq
755 
756  int res = _QLDsolver->solve(MapP, Mapq, MapAandG, Mapbandh, _Atotal.rows(), MapXsol, MapXl, MapXu, false);
757 
759 
760  _result.info = ocra::RETURN_SUCCESS; //TODO: should be dfined through the result of the QuadProgPP::solve_quadprog
761 
762  // solveRecorder.saveRelativeTime();
763 }
const Variable & getVariable() const
Definition: Function.cpp:46
Eigen::MatrixXd _A
Eigen::MatrixXd _C
virtual void doPrepare()
void internalAddConstraint(const GenericConstraint &constraint)
Definition: Solver.cpp:91
Eigen::Map< Eigen::VectorXd > VectorMap
Eigen::VectorXd _h
Eigen::VectorXd Xsolution
#define OCRA_ERROR(msg)
Definition: ErrorsHelper.h:32
void internalRemoveConstraint(const GenericConstraint &constraint)
Definition: Solver.cpp:121
void addCompressed2d(const MatrixBase< Derived1 > &in, MatrixBase< Derived2 > const &_out, const std::vector< int > &mapping, double scale, bool reverseMapping)
Define the internal solver class that can be used in the wOcra controller.
int solve(Map< MatrixXd > &C, const Map< VectorXd > &d, const Map< MatrixXd > &A, const Map< VectorXd > &b, int me, Map< VectorXd > &x, const Map< VectorXd > &xl, const Map< VectorXd > &xu, bool factorizedC=false)
Definition: ObjQLD.cpp:15
ObjQLD class.
Definition: ObjQLD.h:52
OptimizationResult _result
Definition: Solver.h:215
const std::string & getName() const
const std::vector< int > & findMapping(Variable &var)
Definition: Solver.cpp:12
virtual void prepareMatrices()
std::vector< ocra::LinearConstraint * > _inequalityConstraints
Eigen::Map< Eigen::MatrixXd > MatrixMap
virtual void updateObjectiveEquations()
void writePerformanceInStream(std::ostream &myOstream, bool addCommaAtEnd)
Optimization-based Robot Controller namespace. a library of classes to write and solve optimization p...
double solve_quadprog(const Eigen::MatrixXd &_G, const Eigen::VectorXd &g0, const Eigen::MatrixXd &_CE, const Eigen::VectorXd &ce0, const Eigen::MatrixXd &_CI, const Eigen::VectorXd &ci0, Eigen::VectorXd &x)
Definition: QuadProg++.cpp:75
virtual void updateObjectiveEquations()=0
Constraint class.
Definition: Constraint.h:100
Variable & getProblemVariable()
Definition: Solver.h:148
virtual std::string toString()
void convert(const LinearConstraint &cstr, const std::vector< int > &mapping, eConstraintOutput type, MatrixBase< Derived > &A, VectorBase1 &b, VectorBase2 &l, double infinity=0.)
const VectorXd & getqi(int index=0) const
virtual void doConclude()
void reduceConstraints(const Eigen::MatrixXd &A, const Eigen::VectorXd &b, Eigen::MatrixXd &Ar, Eigen::VectorXd &br, double tolerance=1e-6)
virtual void updateConstraintEquations()
void removeConstraint(ocra::LinearConstraint &constraint)
void addConstraint(ocra::LinearConstraint &constraint)
void addCompressedByRow(const MatrixBase< Derived1 > &in, MatrixBase< Derived2 > const &_out, const std::vector< int > &mapping, double scale, bool reverseMapping)
const MatrixXd & getPi(int index=0) const
virtual void updateConstraintEquations()=0
A generic abstract class the solvers that can be used in the wOcra Controller.
virtual void printValuesAtSolution()
Eigen::VectorXd _btotal
Eigen::MatrixXd _G
std::vector< qpOASES::real_t > H
std::unique_ptr< qpOASES::SQProblem > sqp_prob
Eigen::VectorXd _b
Eigen::VectorXd _d
virtual void printSubTree(int depth, std::ostream &os) const =0
Overload in ComponentDerived and CompositeDerived to simply call printTree_impl().
int n()
Definition: Solver.h:146
Eigen::MatrixXd _Atotal
QuadraticFunction class.
std::vector< ObjectiveType * > _objectives
Solver class.
Definition: Solver.h:70
std::vector< ocra::LinearConstraint * > _equalityConstraints
static ocra::eReturnInfo toOcraRetValue(const qpOASES::returnValue &ret)