30 #include <gtest/gtest.h>    49 using namespace ifopt;
    64   EXPECT_STREQ(
"ex_component", c.
GetName().c_str());
    70   auto c1 = std::make_shared<ExComponent>(0, 
"component1");
    71   auto c2 = std::make_shared<ExComponent>(1, 
"component2");
    72   auto c3 = std::make_shared<ExComponent>(2, 
"component3");
    75   cost.AddComponent(c1);
    76   cost.AddComponent(c2);
    77   cost.AddComponent(c3);
    78   EXPECT_EQ(1, cost.GetRows());
    84   auto c1 = std::make_shared<ExComponent>(0, 
"component1");
    85   auto c2 = std::make_shared<ExComponent>(1, 
"component2");
    86   auto c3 = std::make_shared<ExComponent>(2, 
"component3");
    88   Composite constraint(
"constraint", 
false);
    89   constraint.AddComponent(c1);
    90   constraint.AddComponent(c2);
    91   constraint.AddComponent(c3);
    92   EXPECT_EQ(0+1+2, constraint.GetRows());
    98   auto c1 = std::make_shared<ExComponent>(0, 
"component1");
    99   auto c2 = std::make_shared<ExComponent>(1, 
"component2");
   100   auto c3 = std::make_shared<ExComponent>(2, 
"component3");
   103   comp.AddComponent(c1);
   104   comp.AddComponent(c2);
   105   comp.AddComponent(c3);
   107   auto c1_new = comp.GetComponent(
"component1");
   108   EXPECT_EQ(c1->GetRows(), c1_new->GetRows());
   110   auto c2_new = comp.GetComponent<
ExComponent>(
"component2");
   111   EXPECT_EQ(c2->GetRows(), c2_new->GetRows());
   113   auto c3_new = comp.GetComponent<
ExComponent>(
"component3");
   114   EXPECT_NE(c1->GetRows(), c3_new->GetRows());
   120   auto c1 = std::make_shared<ExComponent>(0, 
"component1");
   121   auto c2 = std::make_shared<ExComponent>(1, 
"component2");
   122   auto c3 = std::make_shared<ExComponent>(2, 
"component3");
   125   comp.AddComponent(c1);
   126   comp.AddComponent(c2);
   127   comp.AddComponent(c3);
   129   EXPECT_EQ(0+1+2, comp.GetRows());
   131   comp.ClearComponents();
   132   EXPECT_EQ(0, comp.GetRows());
 virtual VectorXd GetValues() const
Returns the "values" of whatever this component represents. 
ExComponent(int n_var, const std::string &name)
virtual Jacobian GetJacobian() const
Returns derivatives of each row w.r.t. the variables. 
int GetRows() const
Returns the number of rows of this component. 
std::string GetName() const
Returns the name (id) of this component. 
Declares the classes Composite and Component used as variables, costs and constraints. 
void SetRows(int num_rows)
Sets the number of rows of this component. 
virtual VecBound GetBounds() const
Returns the "bounds" of this component. 
Eigen::SparseMatrix< double, Eigen::RowMajor > Jacobian
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 void SetVariables(const VectorXd &x)
Sets the optimization variables from an Eigen vector.