46 #ifndef ROL_DYNAMICCONSTRAINT_HPP
47 #define ROL_DYNAMICCONSTRAINT_HPP
80 template<
typename Real>
85 Ptr<Vector<Real>>
jv_;
146 virtual void update(
const V& uo,
const V& un,
const V& z,
const TS& ts ) {
156 virtual void value(
V& c,
const V& uo,
const V& un,
157 const V& z,
const TS& ts )
const = 0;
160 const V& z,
const TS& ts ) {
166 Real cnorm = c.
norm();
167 const Real ctol = std::min(
atol_,
rtol_*cnorm);
174 Real alpha(1), tmp(0);
177 std::cout <<
"\n Default DynamicConstraint::solve\n";
179 std::cout << std::setw(6) << std::left <<
"iter";
180 std::cout << std::setw(15) << std::left <<
"rnorm";
181 std::cout << std::setw(15) << std::left <<
"alpha";
184 for (cnt = 0; cnt <
maxit_; ++cnt) {
194 while ( tmp > (1.0-
decr_*alpha)*cnorm &&
206 std::cout << std::setw(6) << std::left << cnt;
207 std::cout << std::scientific << std::setprecision(6);
208 std::cout << std::setw(15) << std::left << tmp;
209 std::cout << std::scientific << std::setprecision(6);
210 std::cout << std::setw(15) << std::left << alpha;
224 Ptr<DynamicConstraint<Real>> con_ptr = makePtrFromRef(*
this);
225 Ptr<const Vector<Real>> uo_ptr = makePtrFromRef(uo);
226 Ptr<const Vector<Real>> z_ptr = makePtrFromRef(z);
227 Ptr<const TimeStamp<Real>> ts_ptr = makePtrFromRef(ts);
228 Ptr<Objective<Real>> obj_ptr
229 = makePtr<NonlinearLeastSquaresObjective_Dynamic<Real>>(con_ptr,c,uo_ptr,z_ptr,ts_ptr,
true);
230 ParameterList parlist;
231 parlist.sublist(
"Status Test").set(
"Gradient Tolerance",ctol);
232 parlist.sublist(
"Status Test").set(
"Step Tolerance",
stol_);
233 parlist.sublist(
"Status Test").set(
"Iteration Limit",
maxit_);
234 parlist.sublist(
"Step").sublist(
"Trust Region").set(
"Subproblem Solver",
"Truncated CG");
235 parlist.sublist(
"General").sublist(
"Krylov").set(
"Iteration Limit",100);
236 Ptr<Step<Real>> step = makePtr<TrustRegionStep<Real>>(parlist);
237 Ptr<StatusTest<Real>> status = makePtr<StatusTest<Real>>(parlist);
238 Ptr<Algorithm<Real>> algo = makePtr<Algorithm<Real>>(step,status,
false);
239 algo->run(un,*obj_ptr,
print_);
243 Ptr<DynamicConstraint<Real>> con_ptr = makePtrFromRef(*
this);
244 Ptr<const Vector<Real>> uo_ptr = makePtrFromRef(uo);
245 Ptr<const Vector<Real>> z_ptr = makePtrFromRef(z);
246 Ptr<const TimeStamp<Real>> ts_ptr = makePtrFromRef(ts);
247 Ptr<Constraint<Real>> cn_ptr
248 = makePtr<Constraint_DynamicState<Real>>(con_ptr,uo_ptr,z_ptr,ts_ptr);
249 Ptr<Objective<Real>> obj_ptr
250 = makePtr<Objective_FSsolver<Real>>();
251 ParameterList parlist;
252 parlist.sublist(
"Status Test").set(
"Constraint Tolerance",ctol);
253 parlist.sublist(
"Status Test").set(
"Step Tolerance",
stol_);
254 parlist.sublist(
"Status Test").set(
"Iteration Limit",
maxit_);
255 Ptr<Step<Real>> step = makePtr<CompositeStep<Real>>(parlist);
256 Ptr<StatusTest<Real>> status = makePtr<ConstraintStatusTest<Real>>(parlist);
257 Ptr<Algorithm<Real>> algo = makePtr<Algorithm<Real>>(step,status,
false);
259 algo->run(un,*l,*obj_ptr,*cn_ptr,
print_);
263 ROL_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
264 ">>> ERROR (ROL:DynamicConstraint:solve): Invalid solver type!");
289 ParameterList & list = parlist.sublist(
"Dynamic Constraint").sublist(
"Solve");
304 const V& un,
const V& z,
305 const TS& ts )
const {}
308 const V& un,
const V& z,
309 const TS& ts )
const {}
312 const V& un,
const V& z,
313 const TS& ts )
const {}
318 const V& un,
const V& z,
319 const TS& ts )
const {}
322 const V& un,
const V& z,
323 const TS& ts )
const {}
326 const V& un,
const V& z,
327 const TS& ts )
const {}
332 const V& un,
const V& z,
333 const TS& ts )
const {}
336 const V& un,
const V& z,
337 const TS& ts )
const {}
342 const V& uo,
const V& un,
343 const V& z,
const TS& ts )
const {
348 const V& uo,
const V& un,
349 const V& z,
const TS& ts )
const {
354 const V& uo,
const V& un,
355 const V& z,
const TS& ts )
const {
360 const V& uo,
const V& un,
361 const V& z,
const TS& ts )
const {
366 const V& uo,
const V& un,
367 const V& z,
const TS& ts )
const {
372 const V& uo,
const V& un,
373 const V& z,
const TS& ts )
const {
378 const V& uo,
const V& un,
379 const V& z,
const TS& ts )
const {
384 const V& uo,
const V& un,
385 const V& z,
const TS& ts )
const {
390 const V& uo,
const V& un,
391 const V& z,
const TS& ts )
const {
401 #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.
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)