Go to the documentation of this file.
64 std::vector<int> viol_idx;
65 for (std::size_t i = 0; i < bounds.size(); ++i) {
66 double lower = bounds.at(i).lower_;
67 double upper = bounds.at(i).upper_;
69 if (val < lower - tol || upper + tol < val)
70 viol_idx.push_back(i);
73 std::string black =
"\033[0m";
74 std::string red =
"\033[31m";
75 std::string color = viol_idx.empty() ? black : red;
77 std::cout.precision(2);
78 std::cout << std::fixed << std::left << std::setw(30) <<
name_ << std::right
79 << std::setw(4) <<
num_rows_ << std::setw(9) << index
80 << std::setfill(
'.') << std::setw(7) << index +
num_rows_ - 1
81 << std::setfill(
' ') << color << std::setw(12) << viol_idx.size()
82 << black << std::endl;
114 if (c->GetName() == name)
127 int n_rows = c->GetRows();
129 g_all.middleRows(row, n_rows) += g;
141 int n_rows = c->GetRows();
142 c->SetVariables(x.middleRows(row, n_rows));
159 std::vector<Eigen::Triplet<double>> triplet_list;
162 const Jacobian& jac = c->GetJacobian();
163 triplet_list.reserve(triplet_list.size() + jac.nonZeros());
165 for (
int k = 0; k < jac.outerSize(); ++k)
166 for (Jacobian::InnerIterator it(jac, k); it; ++it)
167 triplet_list.push_back(
168 Eigen::Triplet<double>(row + it.row(), it.col(), it.value()));
174 jacobian.setFromTriplets(triplet_list.begin(), triplet_list.end());
183 bounds_.insert(bounds_.end(), b.begin(), b.end());
200 std::cout <<
GetName() <<
":\n";
203 c->Print(tol, index);
205 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 Mon Sep 18 2023 02:14:38