46 #ifndef ROL_DYNAMICCONSTRAINT_HPP
47 #define ROL_DYNAMICCONSTRAINT_HPP
78 template<
typename Real>
83 Ptr<Vector<Real>>
jv_;
141 virtual void update(
const V& uo,
const V& un,
const V& z,
const TS& ts ) {
151 virtual void value(
V& c,
const V& uo,
const V& un,
152 const V& z,
const TS& ts )
const = 0;
155 const V& z,
const TS& ts ) {
161 Real cnorm = c.
norm();
162 const Real ctol = std::min(
atol_,
rtol_*cnorm);
169 Real alpha(1), tmp(0);
172 std::cout <<
"\n Default DynamicConstraint::solve\n";
174 std::cout << std::setw(6) << std::left <<
"iter";
175 std::cout << std::setw(15) << std::left <<
"rnorm";
176 std::cout << std::setw(15) << std::left <<
"alpha";
179 for (cnt = 0; cnt <
maxit_; ++cnt) {
189 while ( tmp > (1.0-
decr_*alpha)*cnorm &&
201 std::cout << std::setw(6) << std::left << cnt;
202 std::cout << std::scientific << std::setprecision(6);
203 std::cout << std::setw(15) << std::left << tmp;
204 std::cout << std::scientific << std::setprecision(6);
205 std::cout << std::setw(15) << std::left << alpha;
219 ROL::Ptr<DynamicConstraint<Real>> con_ptr = ROL::makePtrFromRef(*
this);
220 ROL::Ptr<const Vector<Real>> uo_ptr = ROL::makePtrFromRef(uo);
221 ROL::Ptr<const Vector<Real>> z_ptr = ROL::makePtrFromRef(z);
222 ROL::Ptr<const TimeStamp<Real>> ts_ptr = ROL::makePtrFromRef(ts);
223 ROL::Ptr<Objective<Real>> obj_ptr
224 = ROL::makePtr<NonlinearLeastSquaresObjective_Dynamic<Real>>(con_ptr,c,uo_ptr,z_ptr,ts_ptr,
true);
225 ROL::ParameterList parlist;
226 parlist.sublist(
"Status Test").set(
"Gradient Tolerance",ctol);
227 parlist.sublist(
"Status Test").set(
"Step Tolerance",
stol_);
228 parlist.sublist(
"Status Test").set(
"Iteration Limit",
maxit_);
229 parlist.sublist(
"Step").sublist(
"Trust Region").set(
"Subproblem Solver",
"Truncated CG");
230 parlist.sublist(
"General").sublist(
"Krylov").set(
"Iteration Limit",100);
231 ROL::Ptr<Algorithm<Real>> algo = ROL::makePtr<Algorithm<Real>>(
"Trust Region",parlist,
false);
232 algo->run(un,*obj_ptr,
print_);
236 ROL::Ptr<DynamicConstraint<Real>> con_ptr = ROL::makePtrFromRef(*
this);
237 ROL::Ptr<const Vector<Real>> uo_ptr = ROL::makePtrFromRef(uo);
238 ROL::Ptr<const Vector<Real>> z_ptr = ROL::makePtrFromRef(z);
239 ROL::Ptr<const TimeStamp<Real>> ts_ptr = ROL::makePtrFromRef(ts);
240 ROL::Ptr<Constraint<Real>> cn_ptr
241 = ROL::makePtr<Constraint_DynamicState<Real>>(con_ptr,uo_ptr,z_ptr,ts_ptr);
242 ROL::Ptr<Objective<Real>> obj_ptr
243 = ROL::makePtr<Objective_FSsolver<Real>>();
244 ROL::ParameterList parlist;
245 parlist.sublist(
"Status Test").set(
"Constraint Tolerance",ctol);
246 parlist.sublist(
"Status Test").set(
"Step Tolerance",
stol_);
247 parlist.sublist(
"Status Test").set(
"Iteration Limit",
maxit_);
248 ROL::Ptr<Algorithm<Real>> algo = ROL::makePtr<Algorithm<Real>>(
"Composite Step",parlist,
false);
249 ROL::Ptr<Vector<Real>> l = c.
dual().
clone();
250 algo->run(un,*l,*obj_ptr,*cn_ptr,
print_);
254 ROL_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
255 ">>> ERROR (ROL:DynamicConstraint:solve): Invalid solver type!");
280 ROL::ParameterList & list = parlist.sublist(
"Dynamic Constraint").sublist(
"Solve");
295 const V& un,
const V& z,
296 const TS& ts )
const {}
299 const V& un,
const V& z,
300 const TS& ts )
const {}
303 const V& un,
const V& z,
304 const TS& ts )
const {}
309 const V& un,
const V& z,
310 const TS& ts )
const {}
313 const V& un,
const V& z,
314 const TS& ts )
const {}
317 const V& un,
const V& z,
318 const TS& ts )
const {}
323 const V& un,
const V& z,
324 const TS& ts )
const {}
327 const V& un,
const V& z,
328 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 {
357 const V& uo,
const V& un,
358 const V& z,
const TS& ts )
const {
363 const V& uo,
const V& un,
364 const V& z,
const TS& ts )
const {
369 const V& uo,
const V& un,
370 const V& z,
const TS& ts )
const {
375 const V& uo,
const V& un,
376 const V& z,
const TS& ts )
const {
381 const V& uo,
const V& un,
382 const V& z,
const TS& ts )
const {
392 #endif // ROL_DYNAMICCONSTRAINT_HPP
Ptr< Vector< Real > > jv_
virtual void update_un(const V &un, const TS &ts)
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
Contains local time step information.
virtual void zero()
Set to zero vector.
Defines the linear algebra or vector space interface.
virtual void setSolveParameters(ROL::ParameterList &parlist)
Set solve parameters.
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 applyInverseJacobian_un(V &ijv, const V &vn, const V &uo, const V &un, const V &z, const TS &ts) const
virtual void value(V &c, const V &uo, const V &un, const V &z, const TS &ts) const =0
virtual void applyAdjointJacobian_uo(V &ajv, const V &dualv, const V &uo, const V &un, const V &z, const TS &ts) const
virtual void update_z(const V &z, const TS &ts)
virtual void update_uo(const V &uo, const TS &ts)
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.