7 SumOfLinearFunctions::SumOfLinearFunctions(
int dimension)
12 , _variable(
"SumOfLinearFunctionsVariable")
13 , _offset(VectorXd::Zero(dimension))
21 while(!_functions.empty())
32 throw std::runtime_error(
"[ocra::SumOfLinearFunctions::addFunction] f must have the dimension set at construction");
34 for (
size_t i=0; i<_functions.size(); ++i)
36 if (_functions[i].first == &f)
38 _functions[i].second += scale;
43 _functions.push_back(std::make_pair(&f,scale));
48 f.
connect<
EVT_RESIZE>(*
this, &SumOfLinearFunctions::checkThatFunctionsDimensionDoNotChange);
58 for (
size_t i=0; i<_functions.size(); ++i)
60 if (_functions[i].first == &f)
62 _functions[i].second -= scale;
63 if (std::abs(_functions[i].second) < 1.e-8)
70 _functions.erase(_functions.begin() + i);
77 ocra_assert(
false &&
"the function to remove was not found");
84 for (
size_t i=0;i<_functions.size(); ++i)
86 if (_functions[i].first == &f)
93 _functions.erase(_functions.begin() + i);
99 ocra_assert(
false &&
"the function to remove was not found");
110 for (
size_t i=0; i<_functions.size(); ++i)
117 for (
size_t i=0; i<_functions.size(); ++i)
118 _b += _functions[i].second * _functions[i].first->getb();
128 throw std::runtime_error(
"[ocra::SumOfLinearFunctions::changeA] invalid operation on SumOfLinearFunctions");
138 void SumOfLinearFunctions::checkThatFunctionsDimensionDoNotChange(
int timestamp)
140 for (
size_t i=0; i<_functions.size(); ++i)
141 if(_functions[i].first->getDimension() !=
_dim)
142 throw std::runtime_error(
"[ocra::SumOfLinearFunctions::checkThatFunctionsDimensionDoNotChange] Dimension of function " + _functions[i].first->getName() +
" changed!");
SumOfLinearFunctions & removeFunction(LinearFunction &f, double scale)
const Variable & getVariable() const
void addCompressedByCol(const MatrixBase< Derived1 > &in, MatrixBase< Derived2 > const &_out, const std::vector< int > &mapping, double scale, bool reverseMapping)
void insert(Variable *var)
bool isVariableUpToDate() const
void disconnectVariable()
Optimization-based Robot Controller namespace. a library of classes to write and solve optimization p...
AbilitySet & add(eFunctionAbility prop)
void invalidateb(int timestamp)
void remove(Variable *var)
void recomputeVariable() const
void doChangeA(const MatrixXd &A)
void updateJacobian() const
VariableMapping * find(Variable *var) const
void doChangeb(const VectorXd &b)
SumOfLinearFunctions & addFunction(LinearFunction &f, double scale=1.)
void doUpdateInputSizeBegin()
A concatenation of base variables and other composite variables.
CompositeVariable & getVariable()
#define ocra_assert(ocra_expression)
void disconnect(Derived &object, void(Base::*callbackToErase)(int)) const
Disconnect non-static method.
void connect(Derived &object, void(Base::*newCallback)(int)) const
Call this method to register a non-static method as a callback.
Declaration file of the VariableMapping class.