ROL
ROL_Bundle_U.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#ifndef ROL_BUNDLE_U_H
45#define ROL_BUNDLE_U_H
46
47#include "ROL_Vector.hpp"
48#include "ROL_Ptr.hpp"
49#include <vector>
50#include <set>
51
56namespace ROL {
57
58template<typename Real>
59class Bundle_U {
60/***********************************************************************************************/
61/***************** BUNDLE STORAGE **************************************************************/
62/***********************************************************************************************/
63private:
64 std::vector<Ptr<Vector<Real>>> subgradients_;
65 std::vector<Real> linearizationErrors_;
66 std::vector<Real> distanceMeasures_;
67
68 std::vector<Real> dualVariables_;
69
70 Ptr<Vector<Real>> tG_;
71 Ptr<Vector<Real>> eG_;
72 Ptr<Vector<Real>> yG_;
73 Ptr<Vector<Real>> gx_;
74 Ptr<Vector<Real>> ge_;
75
76 unsigned size_;
77
78 unsigned maxSize_;
79 unsigned remSize_;
80 Real coeff_;
81 Real omega_;
82
84
85 void remove(const std::vector<unsigned> &ind);
86
87 void add(const Vector<Real> &g, const Real le, const Real dm);
88
89/***********************************************************************************************/
90/***************** BUNDLE MODIFICATION AND ACCESS ROUTINES *************************************/
91/***********************************************************************************************/
92public:
93 virtual ~Bundle_U(void) {}
94
95 Bundle_U(const unsigned maxSize = 10,
96 const Real coeff = 0.0,
97 const Real omega = 2.0,
98 const unsigned remSize = 2);
99
100 virtual void initialize(const Vector<Real> &g);
101
102 virtual unsigned solveDual(const Real t, const unsigned maxit = 1000, const Real tol = 1.e-8) = 0;
103
104 const Real linearizationError(const unsigned i) const;
105
106 const Real distanceMeasure(const unsigned i) const;
107
108 const Vector<Real> & subgradient(const unsigned i) const;
109
110 const Real getDualVariable(const unsigned i) const;
111
112 void setDualVariable(const unsigned i, const Real val);
113
114 void resetDualVariables(void);
115
116 const Real computeAlpha(const Real dm, const Real le) const;
117
118 const Real alpha(const unsigned i) const;
119
120 unsigned size(void) const;
121
122 void aggregate(Vector<Real> &aggSubGrad, Real &aggLinErr, Real &aggDistMeas) const;
123
124 void reset(const Vector<Real> &g, const Real le, const Real dm);
125
126 void update(const bool flag, const Real linErr, const Real distMeas,
127 const Vector<Real> &g, const Vector<Real> &s);
128
129protected:
130 const Real GiGj(const unsigned i, const unsigned j) const;
131
132 const Real dotGi(const unsigned i, const Vector<Real> &x) const;
133
134 void addGi(const unsigned i, const Real a, Vector<Real> &x) const;
135
136 Real evaluateObjective(std::vector<Real> &g, const std::vector<Real> &x, const Real t) const;
137
138 unsigned solveDual_dim1(const Real t, const unsigned maxit = 1000, const Real tol = 1.e-8);
139
140 unsigned solveDual_dim2(const Real t, const unsigned maxit = 1000, const Real tol = 1.e-8);
141
142}; // class Bundle_U
143
144} // namespace ROL
145
146#include "ROL_Bundle_U_Def.hpp"
147
148#endif
Provides the interface for and implements a bundle.
void update(const bool flag, const Real linErr, const Real distMeas, const Vector< Real > &g, const Vector< Real > &s)
const Real alpha(const unsigned i) const
Real evaluateObjective(std::vector< Real > &g, const std::vector< Real > &x, const Real t) const
Ptr< Vector< Real > > gx_
const Real getDualVariable(const unsigned i) const
unsigned maxSize_
void resetDualVariables(void)
unsigned size(void) const
const Real computeAlpha(const Real dm, const Real le) const
const Vector< Real > & subgradient(const unsigned i) const
unsigned solveDual_dim1(const Real t, const unsigned maxit=1000, const Real tol=1.e-8)
unsigned remSize_
std::vector< Real > dualVariables_
const Real dotGi(const unsigned i, const Vector< Real > &x) const
const Real GiGj(const unsigned i, const unsigned j) const
std::vector< Real > linearizationErrors_
Ptr< Vector< Real > > yG_
Ptr< Vector< Real > > eG_
virtual unsigned solveDual(const Real t, const unsigned maxit=1000, const Real tol=1.e-8)=0
std::vector< Real > distanceMeasures_
Ptr< Vector< Real > > ge_
virtual void initialize(const Vector< Real > &g)
void addGi(const unsigned i, const Real a, Vector< Real > &x) const
virtual ~Bundle_U(void)
void aggregate(Vector< Real > &aggSubGrad, Real &aggLinErr, Real &aggDistMeas) const
void add(const Vector< Real > &g, const Real le, const Real dm)
const Real distanceMeasure(const unsigned i) const
unsigned solveDual_dim2(const Real t, const unsigned maxit=1000, const Real tol=1.e-8)
std::vector< Ptr< Vector< Real > > > subgradients_
const Real linearizationError(const unsigned i) const
void reset(const Vector< Real > &g, const Real le, const Real dm)
void remove(const std::vector< unsigned > &ind)
Ptr< Vector< Real > > tG_
unsigned size_
void setDualVariable(const unsigned i, const Real val)
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:84