44 #ifndef ROL_EQUALITY_CONSTRAINT_SIMOPT_H
45 #define ROL_EQUALITY_CONSTRAINT_SIMOPT_H
134 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
135 "The method solve is used but not implemented!\n");
162 h = std::max(1.0,u.
norm()/v.
norm())*tol;
165 Teuchos::RCP<Vector<Real> > unew = u.
clone();
170 value(jv,*unew,z,ctol);
172 Teuchos::RCP<Vector<Real> > cold = jv.
clone();
174 value(*cold,u,z,ctol);
205 h = std::max(1.0,u.
norm()/v.
norm())*tol;
208 Teuchos::RCP<Vector<Real> > znew = z.
clone();
213 value(jv,u,*znew,ctol);
215 Teuchos::RCP<Vector<Real> > cold = jv.
clone();
217 value(*cold,u,z,ctol);
243 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
244 "The method applyInverseJacobian_1 is used but not implemented!\n");
297 h = std::max(1.0,u.
norm()/v.
norm())*tol;
299 Teuchos::RCP<Vector<Real> > cold = dualv.
clone();
300 Teuchos::RCP<Vector<Real> > cnew = dualv.
clone();
302 value(*cold,u,z,ctol);
303 Teuchos::RCP<Vector<Real> > unew = u.
clone();
305 for (
int i = 0; i < u.
dimension(); i++) {
307 unew->axpy(h,*(u.
basis(i)));
309 value(*cnew,*unew,z,ctol);
310 cnew->axpy(-1.0,*cold);
312 ajv.
axpy(cnew->dot(v),*((u.
dual()).basis(i)));
368 h = std::max(1.0,u.
norm()/v.
norm())*tol;
370 Teuchos::RCP<Vector<Real> > cold = dualv.
clone();
371 Teuchos::RCP<Vector<Real> > cnew = dualv.
clone();
373 value(*cold,u,z,ctol);
374 Teuchos::RCP<Vector<Real> > znew = z.
clone();
376 for (
int i = 0; i < z.
dimension(); i++) {
378 znew->axpy(h,*(z.
basis(i)));
380 value(*cnew,u,*znew,ctol);
381 cnew->axpy(-1.0,*cold);
383 ajv.
axpy(cnew->dot(v),*((z.
dual()).basis(i)));
408 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
409 "The method applyInverseAdjointJacobian_1 is used but not implemented!\n");
438 h = std::max(1.0,u.
norm()/v.
norm())*tol;
441 Teuchos::RCP<Vector<Real> > unew = u.
clone();
447 Teuchos::RCP<Vector<Real> > jv = ahwv.
clone();
482 h = std::max(1.0,u.
norm()/v.
norm())*tol;
485 Teuchos::RCP<Vector<Real> > unew = u.
clone();
491 Teuchos::RCP<Vector<Real> > jv = ahwv.
clone();
526 h = std::max(1.0,u.
norm()/v.
norm())*tol;
529 Teuchos::RCP<Vector<Real> > znew = z.
clone();
535 Teuchos::RCP<Vector<Real> > jv = ahwv.
clone();
569 h = std::max(1.0,u.
norm()/v.
norm())*tol;
572 Teuchos::RCP<Vector<Real> > znew = z.
clone();
578 Teuchos::RCP<Vector<Real> > jv = ahwv.
clone();
658 Teuchos::RCP<ROL::Vector<Real> > ijv = (xs.
get_1())->clone();
663 catch (
const std::logic_error &e) {
669 Teuchos::RCP<ROL::Vector<Real> > ijv_dual = (gs.
get_1())->clone();
670 ijv_dual->
set(ijv->dual());
675 catch (
const std::logic_error &e) {
715 const Vector_SimOpt<Real> &vs = Teuchos::dyn_cast<
const Vector_SimOpt<Real> >(
718 Teuchos::RCP<Vector<Real> > jv2 = jv.
clone();
730 const Vector_SimOpt<Real> &xs = Teuchos::dyn_cast<
const Vector_SimOpt<Real> >(
732 Teuchos::RCP<Vector<Real> > ajv1 = (ajvs.
get_1())->clone();
735 Teuchos::RCP<Vector<Real> > ajv2 = (ajvs.
get_2())->clone();
748 const Vector_SimOpt<Real> &xs = Teuchos::dyn_cast<
const Vector_SimOpt<Real> >(
750 const Vector_SimOpt<Real> &vs = Teuchos::dyn_cast<
const Vector_SimOpt<Real> >(
753 Teuchos::RCP<Vector<Real> > C11 = (ahwvs.
get_1())->clone();
754 Teuchos::RCP<Vector<Real> > C21 = (ahwvs.
get_1())->clone();
760 Teuchos::RCP<Vector<Real> > C12 = (ahwvs.
get_2())->clone();
761 Teuchos::RCP<Vector<Real> > C22 = (ahwvs.
get_2())->clone();
773 const bool printToStream =
true,
774 std::ostream & outStream = std::cout) {
777 Teuchos::RCP<ROL::Vector<Real> > s = u.
clone();
780 Teuchos::RCP<ROL::Vector<Real> > cs = c.
clone();
783 Real cnorm = cs->norm();
784 if ( printToStream ) {
785 std::stringstream hist;
786 hist << std::scientific << std::setprecision(8);
787 hist <<
"\nTest SimOpt solve at feasible (u,z): \n ||c(u,z)|| = " << cnorm <<
"\n";
788 outStream << hist.str();
810 const bool printToStream =
true,
811 std::ostream & outStream = std::cout) {
837 const bool printToStream =
true,
838 std::ostream & outStream = std::cout) {
840 Teuchos::RCP<Vector<Real> > Jv = dualw.
clone();
842 Real wJv = w.
dot(Jv->dual());
843 Teuchos::RCP<Vector<Real> > Jw = dualv.
clone();
845 Real vJw = v.
dot(Jw->dual());
846 Real diff = std::abs(wJv-vJw);
847 if ( printToStream ) {
848 std::stringstream hist;
849 hist << std::scientific << std::setprecision(8);
850 hist <<
"\nTest SimOpt consistency of Jacobian_1 and its adjoint: \n |<w,Jv> - <adj(J)w,v>| = "
852 hist <<
" |<w,Jv>| = " << std::abs(wJv) <<
"\n";
853 hist <<
" Relative Error = " << diff / (std::abs(wJv)+
ROL_UNDERFLOW) <<
"\n";
854 outStream << hist.str();
876 const bool printToStream =
true,
877 std::ostream & outStream = std::cout) {
902 const bool printToStream =
true,
903 std::ostream & outStream = std::cout) {
905 Teuchos::RCP<Vector<Real> > Jv = dualw.
clone();
907 Real wJv = w.
dot(Jv->dual());
908 Teuchos::RCP<Vector<Real> > Jw = dualv.
clone();
910 Real vJw = v.
dot(Jw->dual());
911 Real diff = std::abs(wJv-vJw);
912 if ( printToStream ) {
913 std::stringstream hist;
914 hist << std::scientific << std::setprecision(8);
915 hist <<
"\nTest SimOpt consistency of Jacobian_2 and its adjoint: \n |<w,Jv> - <adj(J)w,v>| = "
917 hist <<
" |<w,Jv>| = " << std::abs(wJv) <<
"\n";
918 hist <<
" Relative Error = " << diff / (std::abs(wJv)+
ROL_UNDERFLOW) <<
"\n";
919 outStream << hist.str();
928 const bool printToStream =
true,
929 std::ostream & outStream = std::cout) {
931 Teuchos::RCP<Vector<Real> > Jv = jv.
clone();
933 Teuchos::RCP<Vector<Real> > iJJv = u.
clone();
935 Teuchos::RCP<Vector<Real> > diff = v.
clone();
937 diff->axpy(-1.0,*iJJv);
938 Real dnorm = diff->norm();
939 Real vnorm = v.
norm();
940 if ( printToStream ) {
941 std::stringstream hist;
942 hist << std::scientific << std::setprecision(8);
943 hist <<
"\nTest SimOpt consistency of inverse Jacobian_1: \n ||v-inv(J)Jv|| = "
945 hist <<
" ||v|| = " << vnorm <<
"\n";
946 hist <<
" Relative Error = " << dnorm / (vnorm+
ROL_UNDERFLOW) <<
"\n";
947 outStream << hist.str();
956 const bool printToStream =
true,
957 std::ostream & outStream = std::cout) {
959 Teuchos::RCP<Vector<Real> > Jv = jv.
clone();
961 Teuchos::RCP<Vector<Real> > iJJv = v.
clone();
963 Teuchos::RCP<Vector<Real> > diff = v.
clone();
965 diff->axpy(-1.0,*iJJv);
966 Real dnorm = diff->norm();
967 Real vnorm = v.
norm();
968 if ( printToStream ) {
969 std::stringstream hist;
970 hist << std::scientific << std::setprecision(8);
971 hist <<
"\nTest SimOpt consistency of inverse adjoint Jacobian_1: \n ||v-inv(adj(J))adj(J)v|| = "
973 hist <<
" ||v|| = " << vnorm <<
"\n";
974 hist <<
" Relative Error = " << dnorm / (vnorm+
ROL_UNDERFLOW) <<
"\n";
975 outStream << hist.str();
virtual Real checkInverseJacobian_1(const Vector< Real > &jv, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, const bool printToStream=true, std::ostream &outStream=std::cout)
virtual void applyAdjointJacobian_2(Vector< Real > &ajv, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, const Vector< Real > &dualv, Real &tol)
Apply the adjoint of the partial constraint Jacobian at , , to vector . This is the secondary interfa...
virtual const Vector & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
virtual void applyAdjointJacobian_1(Vector< Real > &ajv, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, Real &tol)
Apply the adjoint of the partial constraint Jacobian at , , to the vector . This is the primary inter...
virtual void applyAdjointJacobian_2(Vector< Real > &ajv, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, Real &tol)
Apply the adjoint of the partial constraint Jacobian at , , to vector . This is the primary interface...
virtual void scale(const Real alpha)=0
Compute where .
Teuchos::RCP< const Vector< Real > > get_1() const
virtual int dimension() const
Return dimension of the vector space.
virtual void applyJacobian_2(Vector< Real > &jv, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, Real &tol)
Apply the partial constraint Jacobian at , , to the vector .
virtual void plus(const Vector &x)=0
Compute , where .
virtual void axpy(const Real alpha, const Vector &x)
Compute where .
Defines the linear algebra or vector space interface for simulation-based optimization.
virtual void value(Vector< Real > &c, const Vector< Real > &u, const Vector< Real > &z, Real &tol)=0
Evaluate the constraint operator at .
virtual void applyInverseAdjointJacobian_1(Vector< Real > &iajv, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, Real &tol)
Apply the inverse of the adjoint of the partial constraint Jacobian at , , to the vector ...
virtual void applyAdjointHessian_11(Vector< Real > &ahwv, const Vector< Real > &w, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, Real &tol)
Apply the adjoint of the partial constraint Hessian at , , to vector in direction ...
virtual void applyAdjointHessian_22(Vector< Real > &ahwv, const Vector< Real > &w, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, Real &tol)
Apply the adjoint of the partial constraint Hessian at , , to vector in direction ...
Contains definitions of custom data types in ROL.
void set_1(const Vector< Real > &vec)
virtual void applyAdjointHessian_21(Vector< Real > &ahwv, const Vector< Real > &w, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, Real &tol)
Apply the adjoint of the partial constraint Hessian at , , to vector in direction ...
virtual Teuchos::RCP< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
EqualityConstraint_SimOpt(void)
virtual void applyAdjointHessian(Vector< Real > &ahwv, const Vector< Real > &w, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Apply the derivative of the adjoint of the constraint Jacobian at to vector in direction ...
virtual void zero()
Set to zero vector.
Defines the linear algebra or vector space interface.
Defines the equality constraint operator interface for simulation-based optimization.
virtual Real dot(const Vector &x) const =0
Compute where .
virtual void value(Vector< Real > &c, const Vector< Real > &x, Real &tol)
Evaluate the constraint operator at .
virtual void applyPreconditioner(Vector< Real > &pv, const Vector< Real > &v, const Vector< Real > &x, const Vector< Real > &g, Real &tol)
Apply a constraint preconditioner at , , to vector . In general, this preconditioner satisfies the fo...
virtual void update(const Vector< Real > &u, const Vector< Real > &z, bool flag=true, int iter=-1)
Update constraint functions. x is the optimization variable, flag = true if optimization variable is ...
virtual std::vector< Real > solveAugmentedSystem(Vector< Real > &v1, Vector< Real > &v2, const Vector< Real > &b1, const Vector< Real > &b2, const Vector< Real > &x, Real &tol)
Approximately solves the augmented system where , , , , is an identity operator, and is a zero operator.
Defines the equality constraint operator interface.
virtual Real checkSolve(const ROL::Vector< Real > &u, const ROL::Vector< Real > &z, const ROL::Vector< Real > &c, const bool printToStream=true, std::ostream &outStream=std::cout)
virtual void applyInverseJacobian_1(Vector< Real > &ijv, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, Real &tol)
Apply the inverse partial constraint Jacobian at , , to the vector .
virtual void applyAdjointHessian_12(Vector< Real > &ahwv, const Vector< Real > &w, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, Real &tol)
Apply the adjoint of the partial constraint Hessian at , , to vector in direction ...
virtual bool isFeasible(const Vector< Real > &v)
Check if the vector, v, is feasible.
virtual void applyJacobian_1(Vector< Real > &jv, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, Real &tol)
Apply the partial constraint Jacobian at , , to the vector .
virtual void applyAdjointJacobian(Vector< Real > &ajv, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Apply the adjoint of the the constraint Jacobian at , , to vector .
virtual Real checkAdjointConsistencyJacobian_2(const Vector< Real > &w, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, const Vector< Real > &dualw, const Vector< Real > &dualv, const bool printToStream=true, std::ostream &outStream=std::cout)
Check the consistency of the Jacobian and its adjoint. This is the secondary interface, for use with dual spaces where the user does not define the dual() operation.
virtual void solve(Vector< Real > &u, const Vector< Real > &z, Real &tol)
Given , solve for .
virtual void applyPreconditioner(Vector< Real > &pv, const Vector< Real > &v, const Vector< Real > &x, const Vector< Real > &g, Real &tol)
Apply a constraint preconditioner at , , to vector . Ideally, this preconditioner satisfies the follo...
virtual void applyJacobian(Vector< Real > &jv, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Apply the constraint Jacobian at , , to vector .
virtual Real checkAdjointConsistencyJacobian_1(const Vector< Real > &w, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, const Vector< Real > &dualw, const Vector< Real > &dualv, const bool printToStream=true, std::ostream &outStream=std::cout)
Check the consistency of the Jacobian and its adjoint. This is the secondary interface, for use with dual spaces where the user does not define the dual() operation.
virtual void update(const Vector< Real > &x, bool flag=true, int iter=-1)
Update constraint functions. x is the optimization variable, flag = true if optimization variable is ...
virtual Real checkAdjointConsistencyJacobian_1(const Vector< Real > &w, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, const bool printToStream=true, std::ostream &outStream=std::cout)
Check the consistency of the Jacobian and its adjoint. This is the primary interface.
virtual void set(const Vector &x)
Set where .
virtual void applyAdjointJacobian_1(Vector< Real > &ajv, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, const Vector< Real > &dualv, Real &tol)
Apply the adjoint of the partial constraint Jacobian at , , to the vector . This is the secondary int...
virtual Real checkInverseAdjointJacobian_1(const Vector< Real > &jv, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, const bool printToStream=true, std::ostream &outStream=std::cout)
virtual Teuchos::RCP< Vector > basis(const int i) const
Return i-th basis vector.
virtual Real norm() const =0
Returns where .
virtual std::vector< Real > solveAugmentedSystem(Vector< Real > &v1, Vector< Real > &v2, const Vector< Real > &b1, const Vector< Real > &b2, const Vector< Real > &x, Real &tol)
Approximately solves the augmented system where , , , , is an identity operator, and is a zero operator.
Teuchos::RCP< const Vector< Real > > get_2() const
void set_2(const Vector< Real > &vec)
virtual Real checkAdjointConsistencyJacobian_2(const Vector< Real > &w, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, const bool printToStream=true, std::ostream &outStream=std::cout)
Check the consistency of the Jacobian and its adjoint. This is the primary interface.
static const double ROL_UNDERFLOW
Platform-dependent minimum double.
static const double ROL_EPSILON
Platform-dependent machine epsilon.