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_;
120 virtual void update(
const V& uo,
const V& un,
const V& z,
const TS& ts ) {
130 virtual void value(
V& c,
const V& uo,
const V& un,
131 const V& z,
const TS& ts )
const = 0;
134 const V& z,
const TS& ts ) {
139 Real cnorm = c.
norm();
140 const Real ctol = std::min(
atol_,
rtol_*cnorm);
147 Real alpha(1), tmp(0);
150 *stream <<
" Default DynamicConstraint::solve" << std::endl;
152 *stream << std::setw(6) << std::left <<
"iter";
153 *stream << std::setw(15) << std::left <<
"rnorm";
154 *stream << std::setw(15) << std::left <<
"alpha";
155 *stream << std::endl;
157 for (cnt = 0; cnt <
maxit_; ++cnt) {
167 while ( tmp > (1.0-
decr_*alpha)*cnorm &&
179 *stream << std::setw(6) << std::left << cnt;
180 *stream << std::scientific << std::setprecision(6);
181 *stream << std::setw(15) << std::left << tmp;
182 *stream << std::scientific << std::setprecision(6);
183 *stream << std::setw(15) << std::left << alpha;
184 *stream << std::endl;
197 Ptr<DynamicConstraint<Real>> con = makePtrFromRef(*
this);
198 Ptr<Objective<Real>> obj
199 = makePtr<NonlinearLeastSquaresObjective_Dynamic<Real>>(con,c,makePtrFromRef(uo),makePtrFromRef(z),makePtrFromRef(ts),
true);
200 ParameterList parlist;
201 parlist.sublist(
"General").set(
"Output Level",1);
202 parlist.sublist(
"General").sublist(
"Krylov").set(
"Iteration Limit",100);
203 parlist.sublist(
"Step").sublist(
"Trust Region").set(
"Subproblem Solver",
"Truncated CG");
204 parlist.sublist(
"Status Test").set(
"Gradient Tolerance",ctol);
205 parlist.sublist(
"Status Test").set(
"Step Tolerance",
stol_);
206 parlist.sublist(
"Status Test").set(
"Iteration Limit",
maxit_);
207 Ptr<TypeU::Algorithm<Real>> algo = makePtr<TypeU::TrustRegionAlgorithm<Real>>(parlist);
208 algo->run(un,*obj,*stream);
212 Ptr<Constraint<Real>> con
213 = makePtr<Constraint_DynamicState<Real>>(makePtrFromRef(*
this),makePtrFromRef(uo),makePtrFromRef(z),makePtrFromRef(ts));
214 Ptr<Objective<Real>> obj = makePtr<Objective_FSsolver<Real>>();
216 ParameterList parlist;
217 parlist.sublist(
"General").set(
"Output Level",1);
218 parlist.sublist(
"Status Test").set(
"Constraint Tolerance",ctol);
219 parlist.sublist(
"Status Test").set(
"Step Tolerance",
stol_);
220 parlist.sublist(
"Status Test").set(
"Iteration Limit",
maxit_);
221 Ptr<TypeE::Algorithm<Real>> algo = makePtr<TypeE::AugmentedLagrangianAlgorithm<Real>>(parlist);
222 algo->run(un,*obj,*con,*l,*stream);
226 ROL_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
227 ">>> ERROR (ROL:DynamicConstraint:solve): Invalid solver type!");
252 ParameterList & list = parlist.sublist(
"Dynamic Constraint").sublist(
"Solve");
267 const V& un,
const V& z,
268 const TS& ts )
const {}
271 const V& un,
const V& z,
272 const TS& ts )
const {}
275 const V& un,
const V& z,
276 const TS& ts )
const {}
281 const V& un,
const V& z,
282 const TS& ts )
const {}
285 const V& un,
const V& z,
286 const TS& ts )
const {}
289 const V& un,
const V& z,
290 const TS& ts )
const {}
295 const V& un,
const V& z,
296 const TS& ts )
const {}
299 const V& un,
const V& z,
300 const TS& ts )
const {}
305 const V& uo,
const V& un,
306 const V& z,
const TS& ts )
const {
311 const V& uo,
const V& un,
312 const V& z,
const TS& ts )
const {
317 const V& uo,
const V& un,
318 const V& z,
const TS& ts )
const {
323 const V& uo,
const V& un,
324 const V& z,
const TS& ts )
const {
329 const V& uo,
const V& un,
330 const V& z,
const TS& ts )
const {
335 const V& uo,
const V& un,
336 const V& z,
const TS& ts )
const {
341 const V& uo,
const V& un,
342 const V& z,
const TS& ts )
const {
347 const V& uo,
const V& un,
348 const V& z,
const TS& ts )
const {
353 const V& uo,
const V& un,
354 const V& z,
const TS& ts )
const {
364 #endif // ROL_DYNAMICCONSTRAINT_HPP
DynamicFunction(std::initializer_list< std::string > zero_deriv_terms={})
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
Ptr< std::ostream > makeStreamPtr(std::ostream &os, bool noSuppressOutput=true)
virtual void zero()
Set to zero vector.
Defines the linear algebra or vector space interface.
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)
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
Real ROL_EPSILON(void)
Platform-dependent machine epsilon.
virtual void update_un(const V &x, const TS &ts)