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
36namespace ROL {
37
38template<typename Real>
40private:
43
44protected:
45 Ptr<Vector<Real>> lower_;
46 Ptr<Vector<Real>> upper_;
47
48 Real computeInf(const Vector<Real> &x) const;
49
50public:
51
52 virtual ~BoundConstraint() {}
53 BoundConstraint(void);
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
344
345}; // class BoundConstraint
346
347} // namespace ROL
348
350
351#endif
Contains definitions of custom data types in ROL.
Provides the interface to apply upper and lower bound constraints.
virtual const Ptr< const Vector< Real > > getLowerBound(void) const
Return the ref count pointer to the lower bound vector.
virtual bool isFeasible(const Vector< Real > &v)
Check if the vector, v, is feasible.
void computeProjectedStep(Vector< Real > &v, const Vector< Real > &x)
Compute projected step.
void pruneLowerInactive(Vector< Real > &v, const Vector< Real > &x, Real eps=Real(0))
Set variables to zero if they correspond to the -inactive set.
bool Uactivated_
Flag that determines whether or not the upper bounds are being used.
void pruneInactive(Vector< Real > &v, const Vector< Real > &x, Real eps=Real(0))
Set variables to zero if they correspond to the -inactive set.
bool isLowerActivated(void) const
Check if lower bound are on.
void pruneUpperInactive(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.
Ptr< Vector< Real > > upper_
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.
bool isActivated(void) const
Check if bounds are on.
virtual void applyInverseScalingFunction(Vector< Real > &dv, const Vector< Real > &v, const Vector< Real > &x, const Vector< Real > &g) const
Apply inverse scaling function.
Real computeInf(const Vector< Real > &x) const
virtual void projectInterior(Vector< Real > &x)
Project optimization variables into the interior of the feasible set.
void deactivateLower(void)
Turn off lower bound.
void activateLower(void)
Turn on lower bound.
void deactivateUpper(void)
Turn off upper bound.
void deactivate(void)
Turn off bounds.
bool Lactivated_
Flag that determines whether or not the lower bounds are being used.
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 computeProjectedGradient(Vector< Real > &g, const Vector< Real > &x)
Compute projected gradient.
Ptr< Vector< Real > > lower_
void activate(void)
Turn on bounds.
void activateUpper(void)
Turn on upper bound.
virtual void project(Vector< Real > &x)
Project optimization variables onto the bounds.
virtual void applyScalingFunctionJacobian(Vector< Real > &dv, const Vector< Real > &v, const Vector< Real > &x, const Vector< Real > &g) const
Apply scaling function Jacobian.
bool isUpperActivated(void) const
Check if upper bound are on.
virtual const Ptr< const Vector< Real > > getUpperBound(void) const
Return the ref count pointer to the upper bound vector.
Defines the linear algebra or vector space interface.