ocra-recipes
Doxygen documentation for the ocra-recipes repository
|
A generic abstract class the solvers that can be used in the wOcra Controller. More...
#include <OneLevelSolver.h>
Public Types | |
using | ObjectiveType = ocra::QuadraticObjective |
Public Member Functions | |
OneLevelSolver () | |
virtual | ~OneLevelSolver () |
virtual void | printValuesAtSolution () |
void | addObjective (ObjectiveType &obj) |
void | removeObjective (ObjectiveType &obj) |
void | addConstraint (ocra::LinearConstraint &constraint) |
void | removeConstraint (ocra::LinearConstraint &constraint) |
void | writePerformanceInStream (std::ostream &myOstream, bool addCommaAtEnd) |
virtual void | setObjectiveLevel (ocra::GenericObjective &obj, int level) |
virtual std::string | toString () |
virtual OneLevelSolver::Ptr | clone () const =0 |
const std::vector< ObjectiveType * > & | getObjectives () |
const Eigen::MatrixXd & | getQuadraticMatrix () |
const Eigen::VectorXd & | getQuadraticVector () |
Public Member Functions inherited from ocra::Solver | |
const std::vector< int > & | findMapping (Variable &var) |
virtual | ~Solver () |
const OptimizationResult & | solve () |
const OptimizationResult & | getLastResult () const |
void | printStatus (std::ostream &os) |
virtual const std::string & | getMoreInfo () const |
void | setMemoryLevel (int level) |
void | setAutoDumpFile (const std::string &file) |
void | activateAutoDump () |
void | deactivateAutoDump () |
void | dump (const std::string &file="") const |
int | n () |
Variable & | getProblemVariable () |
void | setVariableValue (const VectorXd &value) |
Public Member Functions inherited from ocra::ObserverSubject | |
ObserverSubject () | |
virtual | ~ObserverSubject () |
Public Member Functions inherited from ocra::Observer | |
virtual | ~Observer () |
template<int EVT> | |
void | bind (SubjectBase< EVT > &subject) |
Call this method to automatically propagate observed events to observers connected to the subject given in argument. More... | |
template<int EVT> | |
void | stopPropagation () |
Public Member Functions inherited from ocra::ObserverBase< EVT_RESIZE > | |
void | bind (subject_type &subject) |
Call this method to automatically propagate observed events to observers connected to the subject given in argument. More... | |
Public Member Functions inherited from ocra::ObserverBase< EVT_CHANGE_DEPENDENCIES > | |
void | bind (subject_type &subject) |
Call this method to automatically propagate observed events to observers connected to the subject given in argument. More... | |
Public Member Functions inherited from ocra::ObserverBase< EVT_CHANGE_VALUE > | |
void | bind (subject_type &subject) |
Call this method to automatically propagate observed events to observers connected to the subject given in argument. More... | |
Public Member Functions inherited from ocra::Subject | |
virtual | ~Subject () |
template<int EVT, class Derived , class Base > | |
void | connect (Derived &object, void(Base::*newCallback)(int)) const |
Call this method to register a non-static method as a callback. More... | |
template<int EVT> | |
void | connect (void(*newCallback)(int)) const |
Call this method to register a free function as a callback. More... | |
template<int EVT, class Derived , class Base > | |
void | disconnect (Derived &object, void(Base::*callbackToErase)(int)) const |
Disconnect non-static method. More... | |
template<int EVT> | |
void | disconnect (void(*callbackToErase)(int)) const |
Disconnect free function. More... | |
template<int EVT> | |
void | propagate () const |
template<int EVT> | |
void | propagate (int timestamp) const |
Public Member Functions inherited from ocra::SubjectBase< EVT_RESIZE > | |
void | connect (T &object, typename SubjectBaseTraits< EVT, T >::callback_type newCallback) const |
Call this method to register a non-static method as a callback. More... | |
void | connect (typename SubjectBaseTraits< EVT, void >::callback_type newCallback) const |
Call this method to register a free function as a callback. More... | |
void | disconnect (T &object, typename SubjectBaseTraits< EVT, T >::callback_type callback) const |
Disconnect non-static method. More... | |
void | disconnect (typename SubjectBaseTraits< EVT, void >::callback_type callbackToErase) const |
Disconnect free function. More... | |
void | propagate (int timestamp) const |
void | propagate () const |
Public Member Functions inherited from ocra::SubjectBase< EVT_CHANGE_DEPENDENCIES > | |
void | connect (T &object, typename SubjectBaseTraits< EVT, T >::callback_type newCallback) const |
Call this method to register a non-static method as a callback. More... | |
void | connect (typename SubjectBaseTraits< EVT, void >::callback_type newCallback) const |
Call this method to register a free function as a callback. More... | |
void | disconnect (T &object, typename SubjectBaseTraits< EVT, T >::callback_type callback) const |
Disconnect non-static method. More... | |
void | disconnect (typename SubjectBaseTraits< EVT, void >::callback_type callbackToErase) const |
Disconnect free function. More... | |
void | propagate (int timestamp) const |
void | propagate () const |
Public Member Functions inherited from ocra::SubjectBase< EVT_CHANGE_VALUE > | |
void | connect (T &object, typename SubjectBaseTraits< EVT, T >::callback_type newCallback) const |
Call this method to register a non-static method as a callback. More... | |
void | connect (typename SubjectBaseTraits< EVT, void >::callback_type newCallback) const |
Call this method to register a free function as a callback. More... | |
void | disconnect (T &object, typename SubjectBaseTraits< EVT, T >::callback_type callback) const |
Disconnect non-static method. More... | |
void | disconnect (typename SubjectBaseTraits< EVT, void >::callback_type callbackToErase) const |
Disconnect free function. More... | |
void | propagate (int timestamp) const |
void | propagate () const |
Public Member Functions inherited from ocra::NamedInstance | |
NamedInstance (const std::string &name) | |
const std::string & | getName () const |
virtual | ~NamedInstance () |
Protected Member Functions | |
virtual void | doPrepare () |
virtual void | doConclude () |
virtual void | doSolve ()=0 |
virtual void | prepareMatrices () |
virtual void | updateObjectiveEquations ()=0 |
virtual void | updateConstraintEquations ()=0 |
void | reduceConstraints (const Eigen::MatrixXd &A, const Eigen::VectorXd &b, Eigen::MatrixXd &Ar, Eigen::VectorXd &br, double tolerance=1e-6) |
Protected Member Functions inherited from ocra::Solver | |
Solver () | |
void | internalAddObjective (const GenericObjective &objective) |
void | internalAddConstraint (const GenericConstraint &constraint) |
void | internalRemoveObjective (const GenericObjective &objective) |
void | internalRemoveConstraint (const GenericConstraint &constraint) |
virtual void | onConstraintResize (int timestamp) |
virtual void | onObjectiveResize (int timestamp) |
Protected Member Functions inherited from ocra::ObserverBase< EVT_RESIZE > | |
void | stopPropagation () |
Call this method from your callbacks to avoid propagation to the bound subject (if any). More... | |
ObserverBase () | |
~ObserverBase () | |
Protected Member Functions inherited from ocra::ObserverBase< EVT_CHANGE_DEPENDENCIES > | |
void | stopPropagation () |
Call this method from your callbacks to avoid propagation to the bound subject (if any). More... | |
ObserverBase () | |
~ObserverBase () | |
Protected Member Functions inherited from ocra::ObserverBase< EVT_CHANGE_VALUE > | |
void | stopPropagation () |
Call this method from your callbacks to avoid propagation to the bound subject (if any). More... | |
ObserverBase () | |
~ObserverBase () | |
Protected Member Functions inherited from ocra::SubjectBase< EVT_RESIZE > | |
SubjectBase () | |
~SubjectBase () | |
Protected Member Functions inherited from ocra::SubjectBase< EVT_CHANGE_DEPENDENCIES > | |
SubjectBase () | |
~SubjectBase () | |
Protected Member Functions inherited from ocra::SubjectBase< EVT_CHANGE_VALUE > | |
SubjectBase () | |
~SubjectBase () | |
Protected Attributes | |
std::vector< ObjectiveType * > | _objectives |
std::vector< ocra::LinearConstraint * > | _equalityConstraints |
Eigen::MatrixXd | _A |
Eigen::VectorXd | _b |
Eigen::MatrixXd | _Atotal |
Eigen::VectorXd | _btotal |
int | ne |
std::vector< ocra::LinearConstraint * > | _inequalityConstraints |
Eigen::MatrixXd | _G |
Eigen::VectorXd | _h |
int | ni |
Eigen::VectorXd | Xsolution |
Eigen::MatrixXd | _C |
Eigen::VectorXd | _d |
Protected Attributes inherited from ocra::Solver | |
OptimizationResult | _result |
Additional Inherited Members | |
Protected Types inherited from ocra::ObserverBase< EVT_RESIZE > | |
typedef SubjectBase< EVT > | subject_type |
typedef InvokerBase< EVT > | invoker_type |
Protected Types inherited from ocra::ObserverBase< EVT_CHANGE_DEPENDENCIES > | |
typedef SubjectBase< EVT > | subject_type |
typedef InvokerBase< EVT > | invoker_type |
Protected Types inherited from ocra::ObserverBase< EVT_CHANGE_VALUE > | |
typedef SubjectBase< EVT > | subject_type |
typedef InvokerBase< EVT > | invoker_type |
A generic abstract class the solvers that can be used in the wOcra Controller.
It is based on quadratic solvers.
To get a concrete implementation of wOcra solvers, you should call:
- OneLevelSolver if we consider that all the tasks registered have the same level of importance (but not necessarily the same weights) - HierarchySolver if we consider that tasks registered can have different level of importance
Definition at line 58 of file OneLevelSolver.h.
Definition at line 61 of file OneLevelSolver.h.
OneLevelSolver::OneLevelSolver | ( | ) |
Initialize an abstract wOcra Solver.
Definition at line 11 of file OneLevelSolver.cpp.
|
virtual |
Destructor
Definition at line 21 of file OneLevelSolver.cpp.
void OneLevelSolver::addConstraint | ( | ocra::LinearConstraint & | constraint | ) |
Add a quadratic objective to the controller.
obj | The quadratic objective to add |
This objective is saved in an internal vector of objectives. Remove a quadratic objective to the controller.
obj | The quadratic objective to remove |
This objective is removed from the internal vector of objectives. Add a linear constraint to the controller.
constraint | The linear constraint to add |
This constraint is saved in an internal vector of equality or inequality constraints, depending on the type of constraint.
Definition at line 65 of file OneLevelSolver.cpp.
|
inline |
Definition at line 72 of file OneLevelSolver.h.
|
pure virtual |
retuns a pointer to a new instance, very usefull in Hocra
Implemented in ocra::OneLevelSolverWithQLD, ocra::OneLevelSolverWithQPOASES, and ocra::OneLevelSolverWithQuadProg.
|
protectedvirtual |
Do conclude, meaning what to do after solving.
Actually does nothing.
Implements ocra::Solver.
Definition at line 121 of file OneLevelSolver.cpp.
|
protectedvirtual |
Do prepare, meaning prepare matrices before solving.
It calls in this order:
- #prepareMatrices() - #updateObjectiveEquations() - #updateConstraintEquations()
Implements ocra::Solver.
Definition at line 106 of file OneLevelSolver.cpp.
|
protectedpure virtual |
Implements ocra::Solver.
Implemented in ocra::OneLevelSolverWithQLD, ocra::OneLevelSolverWithQPOASES, and ocra::OneLevelSolverWithQuadProg.
|
inline |
Definition at line 92 of file OneLevelSolver.h.
|
inline |
Definition at line 93 of file OneLevelSolver.h.
|
inline |
Definition at line 94 of file OneLevelSolver.h.
|
protectedvirtual |
Prepare the basic matrices, which can be considered as the task because it minimizes the whole problem vector with very low coefficient.
Definition at line 93 of file OneLevelSolver.cpp.
|
virtual |
I don't really know, I suppose to print internal values when solution is found.
Actually does nothing.
Implements ocra::Solver.
Definition at line 30 of file OneLevelSolver.cpp.
|
protected |
Reduce the set of equality constraints if it is not full rank.
A | The matrix associated to the set of equality constraints |
b | The vector associated to the set of equality constraints |
Ar | The matrix instance where will be saved the reduced version of A |
br | The vector instance where will be saved the reduced version of b |
tolerance | The tolerance of reduction |
To reduce the set of equality constraints, we make a SVD decomposition . Then we check the dimension (denoted by ) of the diagonal where value are greater than the tolerance.
The reduced set of task is then (noted in a python way):
Definition at line 168 of file OneLevelSolver.cpp.
void OneLevelSolver::removeConstraint | ( | ocra::LinearConstraint & | constraint | ) |
Removea linear constraint to the controller.
constraint | The linear constraint to remove |
Definition at line 78 of file OneLevelSolver.cpp.
|
inline |
Definition at line 77 of file OneLevelSolver.h.
|
inlinevirtual |
Definition at line 87 of file OneLevelSolver.h.
|
virtual |
I don't really know, I support to write the problem as a string.
Actually does nothing.
Implements ocra::Solver.
Definition at line 205 of file OneLevelSolver.cpp.
|
protectedpure virtual |
Implemented in ocra::OneLevelSolverWithQLD, ocra::OneLevelSolverWithQPOASES, and ocra::OneLevelSolverWithQuadProg.
|
protectedpure virtual |
Implemented in ocra::OneLevelSolverWithQLD, ocra::OneLevelSolverWithQPOASES, and ocra::OneLevelSolverWithQuadProg.
void OneLevelSolver::writePerformanceInStream | ( | std::ostream & | outstream, |
bool | addCommaAtEnd | ||
) |
Write information about solver performances in a string stream.
outstream | the output stream where to write the performances information |
addCommaAtEnd | If true, add a comma at the end of the stream. If false, it means that this is the end of the json file, nothing will be added after that, no comma is added. |
See Orocos_wOcraController::getPerformances() to know more. Here it saves:
Definition at line 137 of file OneLevelSolver.cpp.
|
protected |
Definition at line 115 of file OneLevelSolver.h.
|
protected |
Definition at line 118 of file OneLevelSolver.h.
|
protected |
Definition at line 116 of file OneLevelSolver.h.
|
protected |
Definition at line 119 of file OneLevelSolver.h.
|
protected |
Definition at line 131 of file OneLevelSolver.h.
|
protected |
Definition at line 132 of file OneLevelSolver.h.
|
protected |
Definition at line 114 of file OneLevelSolver.h.
|
protected |
Definition at line 123 of file OneLevelSolver.h.
|
protected |
Definition at line 124 of file OneLevelSolver.h.
|
protected |
Definition at line 122 of file OneLevelSolver.h.
|
protected |
Definition at line 111 of file OneLevelSolver.h.
|
protected |
Definition at line 120 of file OneLevelSolver.h.
|
protected |
Definition at line 125 of file OneLevelSolver.h.
|
protected |
Definition at line 127 of file OneLevelSolver.h.