Go to the documentation of this file.
67 std::vector<int> viol_idx;
68 for (std::size_t i=0; i<bounds.size(); ++i) {
69 double lower = bounds.at(i).lower_;
70 double upper = bounds.at(i).upper_;
72 if (val < lower-tol || upper+tol < val)
73 viol_idx.push_back(i);
76 std::string black =
"\033[0m";
77 std::string red =
"\033[31m";
78 std::string color = viol_idx.empty()? black : red;
80 std::cout.precision(2);
81 std::cout << std::fixed
86 << std::setw(9) << index
91 << std::setw(12) << viol_idx.size()
128 if (c->GetName() == name)
142 int n_rows = c->GetRows();
144 g_all.middleRows(row, n_rows) += g;
157 int n_rows = c->GetRows();
158 c->SetVariables(x.middleRows(row,n_rows));
172 if (
n_var == 0)
return jacobian;
175 std::vector< Eigen::Triplet<double> > triplet_list;
178 const Jacobian& jac = c->GetJacobian();
179 triplet_list.reserve(triplet_list.size()+jac.nonZeros());
181 for (
int k=0; k<jac.outerSize(); ++k)
182 for (Jacobian::InnerIterator it(jac,k); it; ++it)
183 triplet_list.push_back(Eigen::Triplet<double>(row+it.row(), it.col(), it.value()));
189 jacobian.setFromTriplets(triplet_list.begin(), triplet_list.end());
199 bounds_.insert(bounds_.end(), b.begin(), b.end());
217 std::cout <<
GetName() <<
":\n";
220 c->Print(tol, index);
222 std::cout << std::endl;
Composite(const std::string &name, bool is_cost)
Creates a Composite holding either variables, costs or constraints.
Interface representing either Variable, Cost or Constraint.
void SetRows(int num_rows)
Sets the number of rows of this component.
static const int kSpecifyLater
void AddComponent(const Component::Ptr &)
Adds a component to this composite.
std::vector< Bounds > VecBound
const ComponentVec GetComponents() const
Returns read access to the components.
VecBound GetBounds() const override
Returns the "bounds" of this component.
virtual void Print(double tolerance, int &index_start) const
Prints the relevant information (name, rows, values) of this component.
Jacobian GetJacobian() const override
Returns derivatives of each row w.r.t. the variables.
std::shared_ptr< Component > Ptr
std::string GetName() const
Returns the name (id) of this component.
void SetVariables(const VectorXd &x) override
Sets the optimization variables from an Eigen vector.
common namespace for all elements in this library.
Declares the classes Composite and Component used as variables, costs and constraints.
virtual VecBound GetBounds() const =0
Returns the "bounds" of this component.
Component(int num_rows, const std::string &name)
Creates a component.
std::vector< Component::Ptr > ComponentVec
const Component::Ptr GetComponent(std::string name) const
Access generic component with the specified name.
int GetRows() const
Returns the number of rows of this component.
Eigen::SparseMatrix< double, Eigen::RowMajor > Jacobian
VectorXd GetValues() const override
Returns the "values" of whatever this component represents.
void ClearComponents()
Removes all component from this composite.
virtual VectorXd GetValues() const =0
Returns the "values" of whatever this component represents.
ifopt
Author(s): Alexander W. Winkler
autogenerated on Thu Sep 15 2022 02:14:55