57 std::vector< Eigen::Triplet<double> > triplet_list;
59 for (
const auto& vars :
variables_->GetComponents()) {
60 int n = vars->GetRows();
65 triplet_list.reserve(triplet_list.size()+jac.nonZeros());
68 for (
int k=0; k<jac.outerSize(); ++k)
69 for (Jacobian::InnerIterator it(jac,k); it; ++it)
70 triplet_list.push_back(Eigen::Triplet<double>(it.row(), col+it.col(), it.value()));
75 jacobian.setFromTriplets(triplet_list.begin(), triplet_list.end());
110 std::cout.precision(2);
111 std::cout << std::fixed
116 << std::setw(9) << index
117 << std::setfill (
'.')
118 << std::setw(7) << index+
GetRows()-1
119 << std::setfill (
' ')
120 << std::setw(12) << cost
virtual double GetCost() const =0
Returns the scalar cost term calculated from the variables.
A container holding a set of related constraints.
Composite::Ptr VariablesPtr
VecBound GetBounds() const final
Returns infinite bounds (e.g. no bounds).
ConstraintSet(int n_constraints, const std::string &name)
Creates constraints on the variables x.
void LinkWithVariables(const VariablesPtr &x)
Connects the constraint with the optimization variables.
int GetRows() const
Returns the number of rows of this component.
void Print(double tol, int &index) const final
static const Bounds NoBound
virtual void FillJacobianBlock(std::string var_set, Jacobian &jac_block) const =0
Set individual Jacobians corresponding to each decision variable set.
VariableSet(int n_var, const std::string &name)
Creates a set of variables representing a single concept.
std::string GetName() const
Returns the name (id) of this component.
Eigen::SparseMatrix< double, Eigen::RowMajor > Jacobian
common namespace for all elements in this library.
CostTerm(const std::string &name)
Interface representing either Variable, Cost or Constraint.
VectorXd GetValues() const final
Wrapper function that converts double to Eigen::VectorXd.
virtual void InitVariableDependedQuantities(const VariablesPtr &x_init)
Initialize quantities that depend on the optimization variables.
Jacobian GetJacobian() const final
The matrix of derivatives for these constraints and variables.
std::vector< Bounds > VecBound