ocra-recipes
Doxygen documentation for the ocra-recipes repository
|
QuadraticSolver class. More...
#include <QuadraticSolver.h>
Public Member Functions | |
void | printValuesAtSolution () |
void | addObjective (QuadraticObjective &obj) |
void | removeObjective (QuadraticFunction &obj) |
void | removeObjective (QuadraticObjective &obj) |
void | addConstraint (LinearConstraint &constraint) |
void | removeConstraint (LinearConstraint &constraint) |
void | addBounds (BoundConstraint &constraint) |
void | addBounds (IdentityConstraint &constraint) |
void | removeBounds (BoundConstraint &constraint) |
void | removeBounds (IdentityConstraint &constraint) |
void | clearObjectives () |
void | clearConstraints () |
void | clearEqualityConstraints () |
void | clearInequalityConstraints () |
void | clearBounds () |
std::string | toString () |
virtual MatrixXd | getP () const =0 |
virtual VectorXd | getq () const =0 |
virtual MatrixXd | getA () const =0 |
virtual VectorXd | getb () const =0 |
virtual VectorXd | getbp () const =0 |
virtual MatrixXd | getC () const =0 |
virtual VectorXd | getd () const =0 |
virtual VectorXd | getl () const =0 |
virtual VectorXd | getu () const =0 |
virtual VectorXd | getxl () const =0 |
virtual VectorXd | getxu () const =0 |
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 | |
QuadraticSolver (bool boundsAsConstraints=false) | |
void | onConstraintResize (int timestamp) |
void | recomputeMP () |
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 | onObjectiveResize (int timestamp) |
virtual void | doPrepare ()=0 |
virtual void | doSolve ()=0 |
virtual void | doConclude ()=0 |
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< LinearConstraint * > | _equalityConstraints |
std::vector< LinearConstraint * > | _inequalityConstraints |
std::vector< QuadraticObjective * > | _objectives |
std::vector< DiagonalLinearConstraint * > | _bounds |
size_t | _m |
size_t | _p |
size_t | _ps |
const bool | _boundsAsConstraints |
bool | _invalidatedMP |
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 |
QuadraticSolver class.
Base class for a quadratic solver Objective functions and constraints given as input assume the following form: Minimize 1/2 x^t P x + q^t x Subj. to Ax + b = b' l <= Cx + d <= u (xl <= x <= xu)
This class gives functionalities to maintain the right count in the number of equality or inequality constraints. Bounds can be either considered separatly as bounds or as 'normal' constraints, together with the other linear constraints.
Definition at line 46 of file QuadraticSolver.h.
|
inlineprotected |
Constructor to be used by derived class
[in] | boundsAsConstraints. | If true, the bounds will be considered as normal constraints |
Definition at line 59 of file QuadraticSolver.h.
void ocra::QuadraticSolver::addBounds | ( | BoundConstraint & | constraint | ) |
Add/remove a bound. Will throw a runtime_error for similar reasons as add/removeObjective.
Definition at line 64 of file QuadraticSolver.cpp.
void ocra::QuadraticSolver::addBounds | ( | IdentityConstraint & | constraint | ) |
Definition at line 69 of file QuadraticSolver.cpp.
void ocra::QuadraticSolver::addConstraint | ( | LinearConstraint & | constraint | ) |
Add/remove a constraint. Will throw a runtime_error for similar reasons as add/removeObjective.
Definition at line 43 of file QuadraticSolver.cpp.
void ocra::QuadraticSolver::addObjective | ( | QuadraticObjective & | obj | ) |
Add/remove an objective. Will throw a runtime_error in case obj already exist and is added again, or if one tries to remove obj and obj does not appear in the problem.
Definition at line 19 of file QuadraticSolver.cpp.
void ocra::QuadraticSolver::clearBounds | ( | ) |
Definition at line 131 of file QuadraticSolver.cpp.
void ocra::QuadraticSolver::clearConstraints | ( | ) |
Definition at line 115 of file QuadraticSolver.cpp.
void ocra::QuadraticSolver::clearEqualityConstraints | ( | ) |
Definition at line 121 of file QuadraticSolver.cpp.
void ocra::QuadraticSolver::clearInequalityConstraints | ( | ) |
Definition at line 126 of file QuadraticSolver.cpp.
void ocra::QuadraticSolver::clearObjectives | ( | ) |
Clear all the corresponding data of the problem. Equivalent to call remove() one by one for each of them
Definition at line 110 of file QuadraticSolver.cpp.
|
pure virtual |
Implemented in ocra::CmlQuadraticSolver, and ocra::QLDSolver.
|
pure virtual |
Implemented in ocra::CmlQuadraticSolver, and ocra::QLDSolver.
|
pure virtual |
Implemented in ocra::QLDSolver.
|
pure virtual |
Implemented in ocra::CmlQuadraticSolver, and ocra::QLDSolver.
|
pure virtual |
Implemented in ocra::CmlQuadraticSolver, and ocra::QLDSolver.
|
pure virtual |
Implemented in ocra::CmlQuadraticSolver, and ocra::QLDSolver.
|
pure virtual |
Implemented in ocra::CmlQuadraticSolver, and ocra::QLDSolver.
|
pure virtual |
Implemented in ocra::CmlQuadraticSolver, and ocra::QLDSolver.
|
pure virtual |
Implemented in ocra::CmlQuadraticSolver, and ocra::QLDSolver.
|
pure virtual |
Implemented in ocra::QLDSolver.
|
pure virtual |
Implemented in ocra::QLDSolver.
|
protectedvirtual |
Overload of the callback defined in Solver.
Reimplemented from ocra::Solver.
Definition at line 150 of file QuadraticSolver.cpp.
|
virtual |
Print the value of each objective and constraint at the previously found solution
Implements ocra::Solver.
Definition at line 137 of file QuadraticSolver.cpp.
|
protected |
Compute the value of _m, _p and _ps for the actual set of constraints (and bounds if _boundsAsConstraints is true), and put back _invalidatedMP to false.
Definition at line 155 of file QuadraticSolver.cpp.
void ocra::QuadraticSolver::removeBounds | ( | BoundConstraint & | constraint | ) |
Definition at line 87 of file QuadraticSolver.cpp.
void ocra::QuadraticSolver::removeBounds | ( | IdentityConstraint & | constraint | ) |
Definition at line 92 of file QuadraticSolver.cpp.
void ocra::QuadraticSolver::removeConstraint | ( | LinearConstraint & | constraint | ) |
Definition at line 53 of file QuadraticSolver.cpp.
void ocra::QuadraticSolver::removeObjective | ( | QuadraticFunction & | obj | ) |
Definition at line 25 of file QuadraticSolver.cpp.
void ocra::QuadraticSolver::removeObjective | ( | QuadraticObjective & | obj | ) |
Definition at line 37 of file QuadraticSolver.cpp.
|
virtual |
Get debug info. Don't use these functions in critical loops.
Implements ocra::Solver.
Definition at line 175 of file QuadraticSolver.cpp.
|
protected |
Definition at line 153 of file QuadraticSolver.h.
|
protected |
Definition at line 159 of file QuadraticSolver.h.
|
protected |
Definition at line 150 of file QuadraticSolver.h.
|
protected |
Definition at line 151 of file QuadraticSolver.h.
|
protected |
Definition at line 160 of file QuadraticSolver.h.
|
protected |
Definition at line 155 of file QuadraticSolver.h.
|
protected |
Definition at line 152 of file QuadraticSolver.h.
|
protected |
Definition at line 156 of file QuadraticSolver.h.
|
protected |
Definition at line 157 of file QuadraticSolver.h.