11 #ifndef ROL_DYNAMICCONSTRAINT_HPP
12 #define ROL_DYNAMICCONSTRAINT_HPP
23 template<
typename Real>
26 template<
typename Real>
52 template<
typename Real>
57 Ptr<Vector<Real>>
jv_;
118 virtual void update(
const V& uo,
const V& un,
const V& z,
const TS& ts ) {
128 virtual void value(
V& c,
const V& uo,
const V& un,
129 const V& z,
const TS& ts )
const = 0;
132 const V& z,
const TS& ts ) {
137 Real cnorm = c.
norm();
138 const Real ctol = std::min(
atol_,
rtol_*cnorm);
145 Real alpha(1), tmp(0);
148 *stream <<
" Default DynamicConstraint::solve" << std::endl;
150 *stream << std::setw(6) << std::left <<
"iter";
151 *stream << std::setw(15) << std::left <<
"rnorm";
152 *stream << std::setw(15) << std::left <<
"alpha";
153 *stream << std::endl;
155 for (cnt = 0; cnt <
maxit_; ++cnt) {
165 while ( tmp > (1.0-
decr_*alpha)*cnorm &&
177 *stream << std::setw(6) << std::left << cnt;
178 *stream << std::scientific << std::setprecision(6);
179 *stream << std::setw(15) << std::left << tmp;
180 *stream << std::scientific << std::setprecision(6);
181 *stream << std::setw(15) << std::left << alpha;
182 *stream << std::endl;
195 Ptr<DynamicConstraint<Real>> con = makePtrFromRef(*
this);
196 Ptr<Objective<Real>> obj
197 = makePtr<NonlinearLeastSquaresObjective_Dynamic<Real>>(con,c,makePtrFromRef(uo),makePtrFromRef(z),makePtrFromRef(ts),
true);
198 ParameterList parlist;
199 parlist.sublist(
"General").set(
"Output Level",1);
200 parlist.sublist(
"General").sublist(
"Krylov").set(
"Iteration Limit",100);
201 parlist.sublist(
"Step").sublist(
"Trust Region").set(
"Subproblem Solver",
"Truncated CG");
202 parlist.sublist(
"Status Test").set(
"Gradient Tolerance",ctol);
203 parlist.sublist(
"Status Test").set(
"Step Tolerance",
stol_);
204 parlist.sublist(
"Status Test").set(
"Iteration Limit",
maxit_);
205 Ptr<TypeU::Algorithm<Real>> algo = makePtr<TypeU::TrustRegionAlgorithm<Real>>(parlist);
206 algo->run(un,*obj,*stream);
210 Ptr<Constraint<Real>> con
211 = makePtr<Constraint_DynamicState<Real>>(makePtrFromRef(*
this),makePtrFromRef(uo),makePtrFromRef(z),makePtrFromRef(ts));
212 Ptr<Objective<Real>> obj = makePtr<Objective_FSsolver<Real>>();
214 ParameterList parlist;
215 parlist.sublist(
"General").set(
"Output Level",1);
216 parlist.sublist(
"Status Test").set(
"Constraint Tolerance",ctol);
217 parlist.sublist(
"Status Test").set(
"Step Tolerance",
stol_);
218 parlist.sublist(
"Status Test").set(
"Iteration Limit",
maxit_);
219 Ptr<TypeE::Algorithm<Real>> algo = makePtr<TypeE::AugmentedLagrangianAlgorithm<Real>>(parlist);
220 algo->run(un,*obj,*con,*l,*stream);
224 ROL_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
225 ">>> ERROR (ROL:DynamicConstraint:solve): Invalid solver type!");
250 ParameterList & list = parlist.sublist(
"Dynamic Constraint").sublist(
"Solve");
265 const V& un,
const V& z,
266 const TS& ts )
const {}
269 const V& un,
const V& z,
270 const TS& ts )
const {}
273 const V& un,
const V& z,
274 const TS& ts )
const {}
279 const V& un,
const V& z,
280 const TS& ts )
const {}
283 const V& un,
const V& z,
284 const TS& ts )
const {}
287 const V& un,
const V& z,
288 const TS& ts )
const {}
293 const V& un,
const V& z,
294 const TS& ts )
const {}
297 const V& un,
const V& z,
298 const TS& ts )
const {}
303 const V& uo,
const V& un,
304 const V& z,
const TS& ts )
const {
309 const V& uo,
const V& un,
310 const V& z,
const TS& ts )
const {
315 const V& uo,
const V& un,
316 const V& z,
const TS& ts )
const {
321 const V& uo,
const V& un,
322 const V& z,
const TS& ts )
const {
327 const V& uo,
const V& un,
328 const V& z,
const TS& ts )
const {
333 const V& uo,
const V& un,
334 const V& z,
const TS& ts )
const {
339 const V& uo,
const V& un,
340 const V& z,
const TS& ts )
const {
345 const V& uo,
const V& un,
346 const V& z,
const TS& ts )
const {
351 const V& uo,
const V& un,
352 const V& z,
const TS& ts )
const {
362 #endif // ROL_DYNAMICCONSTRAINT_HPP
Ptr< Vector< Real > > jv_
virtual const Vector & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
virtual void applyAdjointHessian_un_z(V &ahwv, const V &w, const V &vn, const V &uo, const V &un, const V &z, const TS &ts) const
virtual ROL::Ptr< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
virtual void solve(V &c, const V &uo, V &un, const V &z, const TS &ts)
Defines the time-dependent constraint operator interface for simulation-based optimization.
virtual void applyAdjointHessian_uo_un(V &ahwv, const V &w, const V &vo, const V &uo, const V &un, const V &z, const TS &ts) const
Defines the linear algebra of vector space on a generic partitioned vector.
virtual void applyAdjointHessian_z_z(V &ahwv, const V &w, const V &vz, const V &uo, const V &un, const V &z, const TS &ts) const
Provides update interface, casting and vector management to DynamicConstraint and DynamicObjective...
Ptr< Vector< Real > > unew_
Contains definitions of custom data types in ROL.
virtual void applyAdjointHessian_z_un(V &ahwv, const V &w, const V &vz, const V &uo, const V &un, const V &z, const TS &ts) const
virtual void applyAdjointJacobian_un(V &ajv, const V &dualv, const V &uo, const V &un, const V &z, const TS &ts) const
virtual void applyJacobian_uo(V &jv, const V &vo, const V &uo, const V &un, const V &z, const TS &ts) const
virtual void update(const V &uo, const V &un, const V &z, const TS &ts)
virtual void applyInverseAdjointJacobian_un(V &iajv, const V &vn, const V &uo, const V &un, const V &z, const TS &ts) const
virtual void zero()
Set to zero vector.
Defines the linear algebra or vector space interface.
Ptr< ostream > makeStreamPtr(ostream &os, bool noSuppressOutput=true)
const int DEFAULT_solverType_
virtual void applyAdjointJacobian_z(V &ajv, const V &dualv, const V &uo, const V &un, const V &z, const TS &ts) const
virtual void setSolveParameters(ParameterList &parlist)
Set solve parameters.
virtual void applyInverseJacobian_un(V &ijv, const V &vn, const V &uo, const V &un, const V &z, const TS &ts) const
virtual void update_z(const V &x, const TS &ts)
virtual void value(V &c, const V &uo, const V &un, const V &z, const TS &ts) const =0
virtual void update_uo(const V &x, const TS &ts)
DynamicConstraint(std::initializer_list< std::string > zero_deriv_terms={})
virtual void applyAdjointJacobian_uo(V &ajv, const V &dualv, const V &uo, const V &un, const V &z, const TS &ts) const
virtual void applyJacobian_un(V &jv, const V &vn, const V &uo, const V &un, const V &z, const TS &ts) const
virtual void applyJacobian_z(V &jv, const V &vz, const V &uo, const V &un, const V &z, const TS &ts) const
virtual void applyAdjointHessian_un_uo(V &ahwv, const V &w, const V &vn, const V &uo, const V &un, const V &z, const TS &ts) const
const bool DEFAULT_print_
const Real DEFAULT_factor_
virtual void applyAdjointHessian_z_uo(V &ahwv, const V &w, const V &vz, const V &uo, const V &un, const V &z, const TS &ts) const
virtual void applyAdjointHessian_uo_uo(V &ahwv, const V &w, const V &v, const V &uo, const V &un, const V &z, const TS &ts) const
virtual void set(const Vector &x)
Set where .
virtual ~DynamicConstraint()
virtual Real norm() const =0
Returns where .
virtual void applyAdjointHessian_un_un(V &ahwv, const V &wn, const V &vn, const V &uo, const V &un, const V &z, const TS &ts) const
virtual void applyAdjointHessian_uo_z(V &ahwv, const V &w, const V &vo, const V &uo, const V &un, const V &z, const TS &ts) const
virtual void update_un(const V &x, const TS &ts)