13 const int id = int(
blocks_.size());
24 terms_.push_back({block.
id(), -1, std::move(form)});
31 assert(a.
id() != b.id());
33 terms_.push_back({a.
id(), b.id(), std::move(form)});
40 term.form->init(
gather(
x, term));
51 assert(x0.size() ==
size_);
52 assert(x1.size() ==
size_);
56 if (!term.form->enabled())
58 if (!term.form->is_step_valid(
gather(x0, term),
gather(x1, term)))
67 assert(x0.size() ==
size_);
68 assert(x1.size() ==
size_);
72 if (!term.form->enabled())
74 if (!term.form->is_step_collision_free(
gather(x0, term),
gather(x1, term)))
83 assert(x0.size() ==
size_);
84 assert(x1.size() ==
size_);
89 if (!term.form->enabled())
91 step = std::min(step, term.form->max_step_size(
gather(x0, term),
gather(x1, term)));
99 assert(x0.size() ==
size_);
100 assert(x1.size() ==
size_);
103 term.form->line_search_begin(
gather(x0, term),
gather(x1, term));
109 term.form->line_search_end();
114 assert(data.x.size() ==
size_);
115 assert(data.grad.size() ==
size_);
119 const Eigen::VectorXd
x =
gather(data.x, term);
120 const Eigen::VectorXd grad =
gather(data.grad, term);
121 const polysolve::nonlinear::PostStepData local_data(data.iter_num, data.solver_info,
x, grad);
122 term.form->post_step(local_data);
128 assert(new_x.size() ==
size_);
130 term.form->solution_changed(
gather(new_x, term));
137 term.form->set_project_to_psd(
val);
142 assert(
x.size() ==
size_);
144 term.form->update_quantities(t,
gather(
x, term));
149 assert(
x.size() ==
size_);
151 term.form->init_lagging(
gather(
x, term));
156 assert(
x.size() ==
size_);
158 term.form->update_lagging(
gather(
x, term), iter_num);
173 if (term.form->uses_lagging())
181 assert(
x.size() ==
size_);
186 if (!term.form->enabled())
195 assert(
x.size() ==
size_);
197 gradv = Eigen::VectorXd::Zero(
size_);
200 if (!term.form->enabled())
203 Eigen::VectorXd local_grad;
204 term.form->first_derivative(
gather(
x, term), local_grad);
205 assert(local_grad.size() ==
term_size(term));
207 for (
int i = 0; i < local_grad.size(); ++i)
214 assert(
x.size() ==
size_);
216 using StorageIndex =
typename StiffnessMatrix::StorageIndex;
217 std::vector<Eigen::Triplet<double, StorageIndex>>
entries;
221 if (!term.form->enabled())
225 term.form->second_derivative(
gather(
x, term), local_hessian);
227 assert(local_hessian.rows() == local_size);
228 assert(local_hessian.cols() == local_size);
230 for (
int k = 0; k < local_hessian.outerSize(); ++k)
232 for (StiffnessMatrix::InnerIterator it(local_hessian, k); it; ++it)
248 assert(block.
id() >= 0);
249 assert(block.
id() <
int(
blocks_.size()));
261 return a.
size() + b.size();
266 assert(
x.size() ==
size_);
273 Eigen::VectorXd local(a.
size() + b.size());
274 local <<
x.segment(a.
offset(), a.
size()),
x.segment(b.offset(), b.size());
280 assert(local_index >= 0);
285 return a.
offset() + local_index;
288 return b.offset() + local_index - a.
size();
std::vector< Eigen::Triplet< double > > entries
Eigen::SparseMatrix< double, Eigen::ColMajor > StiffnessMatrix