36 #ifndef IFOPT_INCLUDE_OPT_COMPOSITE_H_ 37 #define IFOPT_INCLUDE_OPT_COMPOSITE_H_ 43 #include <Eigen/Dense> 44 #include <Eigen/Sparse> 65 using Ptr = std::shared_ptr<Component>;
67 using Jacobian = Eigen::SparseMatrix<double, Eigen::RowMajor>;
81 Component(
int num_rows,
const std::string& name);
134 virtual void Print(
double tolerance,
int& index_start)
const;
164 using Ptr = std::shared_ptr<Composite>;
175 Composite(
const std::string& name,
bool is_cost);
183 void PrintAll()
const;
198 template<
typename T> std::shared_ptr<T>
199 GetComponent(
const std::string& name)
const;
209 void ClearComponents();
221 mutable size_t n_var = -1;
230 return std::dynamic_pointer_cast<T>(c);
virtual VectorXd GetValues() const =0
Returns the "values" of whatever this component represents.
virtual void Print(double tolerance, int &index_start) const
Prints the relevant information (name, rows, values) of this component.
const Component::Ptr GetComponent(std::string name) const
Access generic component with the specified name.
static const int kSpecifyLater
Component(int num_rows, const std::string &name)
Creates a component.
std::vector< Component::Ptr > ComponentVec
int GetRows() const
Returns the number of rows of this component.
std::shared_ptr< Component > Ptr
std::string GetName() const
Returns the name (id) of this component.
virtual void SetVariables(const VectorXd &x)=0
Sets the optimization variables from an Eigen vector.
void SetRows(int num_rows)
Sets the number of rows of this component.
Eigen::SparseMatrix< double, Eigen::RowMajor > Jacobian
virtual Jacobian GetJacobian() const =0
Returns derivatives of each row w.r.t. the variables.
common namespace for all elements in this library.
Interface representing either Variable, Cost or Constraint.
A collection of components which is treated as another Component.
std::vector< Bounds > VecBound
virtual ~Component()=default
virtual VecBound GetBounds() const =0
Returns the "bounds" of this component.