ROL
ROL_BoundConstraint.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Rapid Optimization Library (ROL) Package
4 //
5 // Copyright 2014 NTESS and the ROL contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef ROL_BOUND_CONSTRAINT_H
11 #define ROL_BOUND_CONSTRAINT_H
12 
13 #include "ROL_Vector.hpp"
14 #include "ROL_Ptr.hpp"
15 #include "ROL_Types.hpp"
16 #include <iostream>
17 
36 namespace ROL {
37 
38 template<typename Real>
40 private:
41  bool Lactivated_;
42  bool Uactivated_;
43 
44 protected:
45  Ptr<Vector<Real>> lower_;
46  Ptr<Vector<Real>> upper_;
47 
48  Real computeInf(const Vector<Real> &x) const;
49 
50 public:
51 
52  virtual ~BoundConstraint() {}
53  BoundConstraint(void);
54  BoundConstraint(const Vector<Real> &x);
55 
56  // REQUIRED FUNCTIONS (VIRTUAL)
57 
66  virtual void project( Vector<Real> &x );
67 
78  virtual void projectInterior( Vector<Real> &x );
79 
91  virtual void pruneUpperActive( Vector<Real> &v, const Vector<Real> &x, Real eps = Real(0) );
92 
107  virtual void pruneUpperActive( Vector<Real> &v, const Vector<Real> &g, const Vector<Real> &x, Real xeps = Real(0), Real geps = Real(0) );
108 
120  virtual void pruneLowerActive( Vector<Real> &v, const Vector<Real> &x, Real eps = Real(0) );
121 
136  virtual void pruneLowerActive( Vector<Real> &v, const Vector<Real> &g, const Vector<Real> &x, Real xeps = Real(0), Real geps = Real(0) );
137 
138 
139  // QUERY FUNCTIONS (VIRTUAL AND NONVIRTUAL)
140 
142  virtual const Ptr<const Vector<Real>> getLowerBound( void ) const;
143 
145  virtual const Ptr<const Vector<Real>> getUpperBound( void ) const;
146 
152  virtual bool isFeasible( const Vector<Real> &v );
153 
167  virtual void applyInverseScalingFunction(Vector<Real> &dv, const Vector<Real> &v, const Vector<Real> &x, const Vector<Real> &g) const;
168 
182  virtual void applyScalingFunctionJacobian(Vector<Real> &dv, const Vector<Real> &v, const Vector<Real> &x, const Vector<Real> &g) const;
183 
188  void activateLower(void);
189 
194  void activateUpper(void);
195 
200  void activate(void);
201 
206  void deactivateLower(void);
207 
212  void deactivateUpper(void);
213 
218  void deactivate(void);
219 
224  bool isLowerActivated(void) const;
225 
230  bool isUpperActivated(void) const;
231 
236  bool isActivated(void) const;
237 
238 
239  // HELPER FUNCTIONS (NONVIRTUAL)
240 
252  void pruneActive( Vector<Real> &v, const Vector<Real> &x, Real eps = Real(0) );
253 
267  void pruneActive( Vector<Real> &v, const Vector<Real> &g, const Vector<Real> &x, Real xeps = Real(0), Real geps = Real(0) );
268 
276  void pruneLowerInactive( Vector<Real> &v, const Vector<Real> &x, Real eps = Real(0) );
277 
285  void pruneUpperInactive( Vector<Real> &v, const Vector<Real> &x, Real eps = Real(0) );
286 
296  void pruneLowerInactive( Vector<Real> &v, const Vector<Real> &g, const Vector<Real> &x, Real xeps = Real(0), Real geps = Real(0) );
297 
307  void pruneUpperInactive( Vector<Real> &v, const Vector<Real> &g, const Vector<Real> &x, Real xeps = Real(0), Real geps = Real(0) );
308 
316  void pruneInactive( Vector<Real> &v, const Vector<Real> &x, Real eps = Real(0) );
317 
327  void pruneInactive( Vector<Real> &v, const Vector<Real> &g, const Vector<Real> &x, Real xeps = Real(0), Real geps = Real(0) );
328 
336 
343  void computeProjectedStep( Vector<Real> &v, const Vector<Real> &x );
344 
345 }; // class BoundConstraint
346 
347 } // namespace ROL
348 
350 
351 #endif
virtual bool isFeasible(const Vector< Real > &v)
Check if the vector, v, is feasible.
bool Uactivated_
Flag that determines whether or not the upper bounds are being used.
Ptr< Vector< Real > > upper_
virtual void projectInterior(Vector< Real > &x)
Project optimization variables into the interior of the feasible set.
void activateLower(void)
Turn on lower bound.
void activate(void)
Turn on bounds.
bool isActivated(void) const
Check if bounds are on.
virtual void pruneUpperActive(Vector< Real > &v, const Vector< Real > &x, Real eps=Real(0))
Set variables to zero if they correspond to the upper -active set.
Contains definitions of custom data types in ROL.
void pruneUpperInactive(Vector< Real > &v, const Vector< Real > &x, Real eps=Real(0))
Set variables to zero if they correspond to the -inactive set.
bool Lactivated_
Flag that determines whether or not the lower bounds are being used.
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:46
virtual const Ptr< const Vector< Real > > getLowerBound(void) const
Return the ref count pointer to the lower bound vector.
virtual void applyInverseScalingFunction(Vector< Real > &dv, const Vector< Real > &v, const Vector< Real > &x, const Vector< Real > &g) const
Apply inverse scaling function.
void activateUpper(void)
Turn on upper bound.
Ptr< Vector< Real > > lower_
void pruneLowerInactive(Vector< Real > &v, const Vector< Real > &x, Real eps=Real(0))
Set variables to zero if they correspond to the -inactive set.
void deactivateUpper(void)
Turn off upper bound.
virtual void pruneLowerActive(Vector< Real > &v, const Vector< Real > &x, Real eps=Real(0))
Set variables to zero if they correspond to the lower -active set.
void computeProjectedStep(Vector< Real > &v, const Vector< Real > &x)
Compute projected step.
void deactivateLower(void)
Turn off lower bound.
virtual void project(Vector< Real > &x)
Project optimization variables onto the bounds.
virtual const Ptr< const Vector< Real > > getUpperBound(void) const
Return the ref count pointer to the upper bound vector.
void pruneInactive(Vector< Real > &v, const Vector< Real > &x, Real eps=Real(0))
Set variables to zero if they correspond to the -inactive set.
void pruneActive(Vector< Real > &v, const Vector< Real > &x, Real eps=Real(0))
Set variables to zero if they correspond to the -active set.
Provides the interface to apply upper and lower bound constraints.
Real computeInf(const Vector< Real > &x) const
void computeProjectedGradient(Vector< Real > &g, const Vector< Real > &x)
Compute projected gradient.
virtual void applyScalingFunctionJacobian(Vector< Real > &dv, const Vector< Real > &v, const Vector< Real > &x, const Vector< Real > &g) const
Apply scaling function Jacobian.
void deactivate(void)
Turn off bounds.
bool isLowerActivated(void) const
Check if lower bound are on.
bool isUpperActivated(void) const
Check if upper bound are on.