ROL
ROL_FletcherObjectiveBase.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ************************************************************************
3 //
4 // Rapid Optimization Library (ROL) Package
5 // Copyright (2014) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact lead developers:
38 // Drew Kouri (dpkouri@sandia.gov) and
39 // Denis Ridzal (dridzal@sandia.gov)
40 //
41 // ************************************************************************
42 // @HEADER
43 
44 
45 #ifndef ROL_FLETCHEROBJECTVEBASE_H
46 #define ROL_FLETCHEROBJECTVEBASE_H
47 
48 #include "ROL_Objective.hpp"
49 #include "ROL_Constraint.hpp"
50 #include "ROL_Types.hpp"
51 #include "ROL_Ptr.hpp"
52 #include "ROL_KrylovFactory.hpp"
54 #include "ROL_ScalarController.hpp"
55 #include <iostream>
56 
57 namespace ROL {
58 
59 template<typename Real>
60 class FletcherObjectiveBase : public Objective<Real> {
61 protected:
62  const Ptr<Objective<Real>> obj_;
63  const Ptr<Constraint<Real>> con_;
64 
65  Real sigma_; // penalty parameter
66  Real delta_; // regularization parameter
67  Real quadPenaltyParameter_; // augmented Lagrangian penalty parameter
70 
71  // Evaluation counters
73 
74  Ptr<ScalarController<Real,int>> fPhi_; // value of penalty function
75  Ptr<VectorController<Real,int>> gPhi_; // gradient of penalty function
76  Ptr<VectorController<Real,int>> y_; // multiplier estimate
77  Ptr<ScalarController<Real,int>> fval_; // value of objective function
78  Ptr<VectorController<Real,int>> g_; // gradient of objective value
79  Ptr<VectorController<Real,int>> c_; // constraint value
80 
81  Ptr<Vector<Real>> scaledc_; // penaltyParameter_ * c_
82  Ptr<Vector<Real>> gL_; // gradient of Lagrangian (g - A*y)
83  Ptr<Vector<Real>> gLdual_; // dual gradient of Lagrangian (g - A*y)
84  Ptr<Vector<Real>> xprim_, xdual_, cprim_, cdual_;
85 
86  Real cnorm_; // norm of constraint violation
87 
88  Real multSolverError_; // Error from augmented system solve in value()
89  Real gradSolveError_; // Error from augmented system solve in gradient()
90 
91  // For Augmented system solves
92  Ptr<Krylov<Real>> krylov_;
94  Ptr<Vector<Real>> v1_, v2_, b1_, b2_, w1_, w2_;
95  Ptr<PartitionedVector<Real>> vv_, bb_, ww_;
96 
97 public:
98  FletcherObjectiveBase(const Ptr<Objective<Real>> &obj,
99  const Ptr<Constraint<Real>> &con,
100  const Vector<Real> &xprim,
101  const Vector<Real> &xdual,
102  const Vector<Real> &cprim,
103  const Vector<Real> &cdual,
104  ParameterList &parlist);
105 
106  virtual void update( const Vector<Real> &x, UpdateType type, int iter = -1 ) override;
107 
108  // Accessors
109  Ptr<const Vector<Real>> getLagrangianGradient(const Vector<Real>& x);
110  Ptr<const Vector<Real>> getConstraintVec(const Vector<Real>& x);
111  Ptr<const Vector<Real>> getMultiplierVec(const Vector<Real>& x);
112  Ptr<const Vector<Real>> getGradient(const Vector<Real>& x);
113  Real getObjectiveValue(const Vector<Real>& x);
114  int getNumberFunctionEvaluations() const;
115  int getNumberGradientEvaluations() const;
116  int getNumberConstraintEvaluations() const;
117  void reset(Real sigma, Real delta);
118 
119 protected:
120  Real objValue(const Vector<Real>& x, Real &tol);
121  void objGrad(Vector<Real> &g, const Vector<Real>& x, Real &tol);
122  void conValue(Vector<Real> &c, const Vector<Real>&x, Real &tol);
123  void computeMultipliers(Vector<Real> &y, Vector<Real> &gL, const Vector<Real> &x, Vector<Real> &g, Vector<Real> &c, Real tol);
124  virtual void solveAugmentedSystem(Vector<Real> &v1, Vector<Real> &v2, const Vector<Real> &b1, const Vector<Real> &b2, const Vector<Real> &x, Real &multSolverError_, bool refine) = 0;
125 
126 }; // class FletcherObjectiveBase
127 
128 } // namespace ROL
129 
131 
132 #endif
Provides the interface to evaluate objective functions.
Ptr< const Vector< Real > > getGradient(const Vector< Real > &x)
void computeMultipliers(Vector< Real > &y, Vector< Real > &gL, const Vector< Real > &x, Vector< Real > &g, Vector< Real > &c, Real tol)
Ptr< VectorController< Real, int > > g_
Real objValue(const Vector< Real > &x, Real &tol)
const Ptr< Constraint< Real > > con_
Contains definitions of custom data types in ROL.
Ptr< ScalarController< Real, int > > fPhi_
Ptr< ScalarController< Real, int > > fval_
Ptr< const Vector< Real > > getMultiplierVec(const Vector< Real > &x)
Ptr< VectorController< Real, int > > y_
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:80
void objGrad(Vector< Real > &g, const Vector< Real > &x, Real &tol)
Ptr< PartitionedVector< Real > > vv_
Ptr< VectorController< Real, int > > gPhi_
Ptr< PartitionedVector< Real > > ww_
Real getObjectiveValue(const Vector< Real > &x)
const Ptr< Objective< Real > > obj_
virtual void solveAugmentedSystem(Vector< Real > &v1, Vector< Real > &v2, const Vector< Real > &b1, const Vector< Real > &b2, const Vector< Real > &x, Real &multSolverError_, bool refine)=0
Ptr< PartitionedVector< Real > > bb_
Ptr< VectorController< Real, int > > c_
Ptr< const Vector< Real > > getConstraintVec(const Vector< Real > &x)
FletcherObjectiveBase(const Ptr< Objective< Real >> &obj, const Ptr< Constraint< Real >> &con, const Vector< Real > &xprim, const Vector< Real > &xdual, const Vector< Real > &cprim, const Vector< Real > &cdual, ParameterList &parlist)
virtual void update(const Vector< Real > &x, UpdateType type, int iter=-1) override
Update objective function.
Ptr< const Vector< Real > > getLagrangianGradient(const Vector< Real > &x)
Defines the general constraint operator interface.
void conValue(Vector< Real > &c, const Vector< Real > &x, Real &tol)