ocra-recipes
Doxygen documentation for the ocra-recipes repository
Classes | Namespaces | Enumerations | Functions | Variables
SolverUtilities.h File Reference
#include <ocra/util/MathTypes.h>
#include "ocra/optim/Variable.h"
#include "ocra/optim/Constraint.h"
#include "ocra/optim/uncompress.h"
#include <Eigen/Eigen>
#include <iostream>
#include <iomanip>
#include "SolverUtilities.hxx"
Include dependency graph for SolverUtilities.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ocra::OptimizationResult
 

Namespaces

 ocra
 Optimization-based Robot Controller namespace. a library of classes to write and solve optimization problems dedicated to the control of multi-body systems.
 
 ocra::utils
 
 ocra::utils::details
 

Macros

#define DECLARE_UNCOMPRESSED_FUNCTION(functionName)
 

Enumerations

enum  ocra::eReturnInfo {
  ocra::RETURN_SUCCESS = 0, ocra::RETURN_INCONSISTENT_PROBLEM, ocra::RETURN_INFEASIBLE_PROBLEM, ocra::RETURN_MAX_ITER_REACHED,
  ocra::RETURN_MAX_TIME_REACHED, ocra::RETURN_MEMORY_ERROR, ocra::RETURN_NUMERICAL_ERROR, ocra::RETURN_ERROR
}
 
enum  ocra::eConstraintOutput {
  ocra::CSTR_PLUS_EQUAL =0, ocra::CSTR_MINUS_EQUAL, ocra::CSTR_PLUS_LOWER, ocra::CSTR_MINUS_LOWER,
  ocra::CSTR_PLUS_GREATER, ocra::CSTR_MINUS_GREATER, ocra::CSTR_DOUBLE_BOUNDS
}
 
enum  ocra::utils::details::eConvertCase {
  ocra::utils::details::PLUS_A_PLUS_B =0, ocra::utils::details::PLUS_A_MINUS_B, ocra::utils::details::PLUS_A_PLUS_BV, ocra::utils::details::PLUS_A_MINUS_BV,
  ocra::utils::details::MINUS_A_PLUS_B, ocra::utils::details::MINUS_A_MINUS_B, ocra::utils::details::MINUS_A_PLUS_BV, ocra::utils::details::MINUS_A_MINUS_BV,
  ocra::utils::details::SPECIAL_CASE, ocra::utils::details::IMPOSSIBLE_CASE
}
 

Functions

template<class Derived , class VectorBase >
void ocra::utils::printLinearEquation (const MatrixBase< Derived > &A, const VectorBase &b, int space=9, int precision=3)
 
void ocra::utils::printSolution (const VectorXd &result, const Variable &var, int space=9, int precision=3)
 
template<class Derived , class VectorBase1 , class VectorBase2 >
void ocra::utils::convert (const LinearConstraint &cstr, const std::vector< int > &mapping, eConstraintOutput type, MatrixBase< Derived > &A, VectorBase1 &b, VectorBase2 &l, double infinity=0.)
 
template<class VectorBase1 , class VectorBase2 >
void ocra::utils::intersectBounds (const DiagonalLinearConstraint &bounds, const std::vector< int > &mapping, VectorBase1 &bl, VectorBase2 &bu)
 
void ocra::testUtilities ()
 

Variables

const details::eConvertCase ocra::utils::conversion_cases [7][7]
 

Macro Definition Documentation

#define DECLARE_UNCOMPRESSED_FUNCTION (   functionName)
Value:
template<class Derived1, class Derived2> \
void functionName(const MatrixBase<Derived1>& in, MatrixBase<Derived2> const& _out, \
const std::vector<int>& mapping, double scale=1., bool reverseMapping=false); \
template<class Derived1, class Derived2> \
void functionName(const Variable& base, const Variable& rel, \
const MatrixBase<Derived1>& in, MatrixBase<Derived2> const& _out, \
std::vector<int>& mapping, double scale=1.); \
template<typename Scalar, class Derived1, class Derived2> \
/* specialization for when in is of the form a*M */ \
inline void functionName(const CwiseUnaryOp<internal::scalar_multiple_op<Scalar>, Derived1>& in, MatrixBase<Derived2> const& _out, \
const std::vector<int>& mapping, double scale=1., bool reverseMapping=false) \
{ functionName(in.nestedExpression(), _out, mapping, scale*in.functor().m_other, reverseMapping); } \
template<typename Scalar, class Derived1, class Derived2> \
void functionName(const Variable& base, const Variable& rel, \
const CwiseUnaryOp<internal::scalar_multiple_op<Scalar>, Derived1>& in, MatrixBase<Derived2> const& _out, \
std::vector<int>& mapping, double scale=1.) \
{ \
MatrixBase<Derived2>& out = const_cast<MatrixBase<Derived2> & >(_out);\
functionName(base, rel, in.nestedExpression(), out, mapping, scale*in.functor().m_other); \
}

The following functions are aliases on usages of the methods of uncompress<Functor> (Uncompress.h), defined for userfriendliness:

  • uncompressByCol
  • uncompressByRow
  • uncompress2d
  • addCompressedByCol
  • addCompressedByRow
  • addCompressed2d
  • minCompressedByCol
  • minCompressedByRow
  • minCompressed2d
  • maxCompressedByCol
  • maxCompressedByRow
  • maxCompressed2d each of them having two overloads void functionName(const MatrixBase<Derived1>& in, MatrixBase<Derived2>& out, const std::vector<int>& mapping, double scale=1., bool reverseMapping);

void functionName(const Variable& base, const Variable& rel, const MatrixBase<Derived1>& in, MatrixBase<Derived2>& out, std::vector<int>& mapping, double scale=1.)

Given two matrices in and out, and a vector of indices mapping, these functions will perform an operation between:

  • in.col(i) and out.col(mapping[i]) for functions postfixed by ByRow,
  • in.row(j) and out.row(mapping[j]) for functions postfixed by ByCol,
  • in(i,j) and out(mapping[i], mapping[j]) for functions postfixed by 2d, for i in [0,in.cols()[ or/and j in [0,in.rows()[. If reverseMapping is set to true, the indices k and mapping[k] are swaped: for example, for functions postfixed by ByRow, the operation will happen between in.col(mapping[i]) and out.col(i) The operation between these two elements e1 and e2 is e2 = e1 for uncompress functions, e2 += e1 for addCompressed functions, e2 = min(e1,e2) for minCompressed functions, e2 = max(e1,e2) for maxCompressed functions.

Each function has two overloads:

  • const (MatrixBase&, MatrixBase&, const vector<int>&, double, bool reverseMapping) for which the mapping is given by the user.
  • const (const Variable&, constVariable& MatrixBase&, MatrixBase&, vector<int>&, double) for which the mapping is computed from the variables (base.getRelativeMappingOf(rel, mapping)) and returned to the user.

Definition at line 138 of file SolverUtilities.h.