10#ifndef ROL_BUNDLE_U_AS_DEF_H
11#define ROL_BUNDLE_U_AS_DEF_H
15template<
typename Real>
19 const unsigned remSize)
22template<
typename Real>
35template<
typename Real>
50template<
typename Real>
53 Real sum(0), err(0), tmp(0), y(0);
54 for (
unsigned i = 0; i < Bundle_U<Real>::size(); ++i) {
59 err = (tmp - sum) - y;
62 for (
unsigned i = 0; i < Bundle_U<Real>::size(); ++i) {
68 for (
unsigned i = 0; i < Bundle_U<Real>::size(); ++i) {
78template<
typename Real>
84 typename std::set<unsigned>::iterator it =
workingSet_.begin();
85 for (
unsigned i = 0; i < n; ++i) {
86 lam[i] = g[*it] - mu; it++;
94template<
typename Real>
101 typename std::set<unsigned>::iterator it =
workingSet_.begin();
102 for (
unsigned i = 0; i < n; ++i) {
114template<
typename Real>
117 Real
alpha(1), tmp(0);
119 typename std::set<unsigned>::iterator it;
122 tmp = -x[*it]/p[*it];
123 if (
alpha >= tmp ) {
132template<
typename Real>
134 const std::vector<Real> &g,
const Real tol)
const {
141 std::vector<Real> gk(n,
zero);
142 typename std::set<unsigned>::iterator it =
nworkingSet_.begin();
143 for (
unsigned i = 0; i < n; ++i) {
144 gk[i] = g[*it]; it++;
146 std::vector<Real> sk(n,
zero);
149 for (
unsigned i = 0; i < n; ++i) {
150 s[*it] = sk[i]; it++;
156template<
typename Real>
160 std::vector<Real> tmp(Px.size(),
zero);
169template<
typename Real>
179template<
typename Real>
182 Real sum(0), err(0), tmp(0), y(0);
183 for (
unsigned i = 0; i <
dim; ++i) {
188 err = (tmp - sum) - y;
192 for (
unsigned i = 0; i <
dim; ++i) {
197template<
typename Real>
199 Gx.assign(x.begin(),x.end());
202template<
typename Real>
204 const Real
zero(0), one(1);
207 Real errX(0), tmpX(0), yX(0), errE(0), tmpE(0), yE(0);
208 std::vector<Real> gg(
dim,
zero);
209 typename std::set<unsigned>::iterator it =
nworkingSet_.begin();
210 for (
unsigned i = 0; i <
dim; ++i) {
214 yX = x[i]*gg[i] - errX;
216 errX = (tmpX - sum) - yX;
222 errE = (tmpE - eHe) - yE;
226 for (
unsigned i = 0; i <
dim; ++i) {
227 Px[i] = (x[i]-sum)*gg[i];
231template<
typename Real>
234 typename std::set<unsigned>::iterator it =
nworkingSet_.begin();
235 for (
unsigned i = 0; i <
dim; ++i) {
240template<
typename Real>
245 Real eHx(0), eHe(0), one(1);
247 std::vector<Real> x1(
dim,0), e1(
dim,0),gg(
dim,0);
248 typename std::set<unsigned>::iterator it, jt;
250 for (
int i = 0; i <
dim; ++i) {
252 for (
int j = 0; j < i; ++j) {
263 for (
int i = 0; i <
dim; ++i) {
269 for (
int i =
dim-1; i >= 0; --i) {
272 for (
int j =
dim-1; j >= i+1; --j) {
284 for (
int i = 0; i <
dim; ++i) {
285 Px[i] = Hx[i] - (eHx/eHe)*He[i];
289template<
typename Real>
292 typename std::set<unsigned>::iterator it =
nworkingSet_.begin();
293 for (
unsigned i = 0; i <
dim; ++i) {
298template<
typename Real>
300 unsigned n = g.size();
301 std::vector<Real> Gg(n,0);
302 Real y(0), ytmp(0), yprt(0), yerr(0);
306 for (
unsigned i = 0; i < n; ++i) {
308 yprt = (r[i] - Gg[i]) - yerr;
310 yerr = (ytmp - y) - yprt;
314 for (
unsigned i = 0; i < n; ++i) {
320template<
typename Real>
324 for (
unsigned i = 0; i < Bundle_U<Real>::size(); ++i) {
332 for (
unsigned i = 0; i < Bundle_U<Real>::size(); ++i) {
338template<
typename Real>
343 typename std::set<unsigned>::iterator it =
nworkingSet_.begin();
344 for (
unsigned i = 0; i < n; ++i) {
354 for (
unsigned i = 0; i < n; ++i) {
360template<
typename Real>
362 const Real one(1),
zero(0);
364 std::vector<Real> r(n,0), r0(n,0), g(n,0), d(n,0), Ad(n,0);
368 r0.assign(r.begin(),r.end());
371 Real rg =
dot(r,g), rg0(0);
374 Real
alpha(0), kappa(0), beta(0), TOL(1.e-2);
375 Real CGtol = std::min(tol,TOL*rg);
377 while (rg > CGtol && cnt < 2*n+1) {
394 Real err(0), tmp(0), y(0);
395 for (
unsigned i = 0; i < n; ++i) {
399 err = (tmp - mu) - y;
402 mu /=
static_cast<Real
>(n);
407template<
typename Real>
410 Real val(0), err(0), tmp(0), y0(0);
411 unsigned n = std::min(x.size(),y.size());
412 for (
unsigned i = 0; i < n; ++i) {
414 y0 = x[i]*y[i] - err;
416 err = (tmp - val) - y0;
422template<
typename Real>
424 return std::sqrt(
dot(x,x));
427template<
typename Real>
429 unsigned n = std::min(y.size(),x.size());
430 for (
unsigned i = 0; i < n; ++i) {
435template<
typename Real>
437 for (
unsigned i = 0; i < x.size(); ++i) {
442template<
typename Real>
444 unsigned n = std::min(x.size(),y.size());
445 for (
unsigned i = 0; i < n; ++i) {
450template<
typename Real>
452 const Real
zero(0), one(1);
455 unsigned ind = 0, i = 0, CGiter = 0;
456 Real snorm(0),
alpha(0), mu(0);
460 for (
unsigned j = 0; j < Bundle_U<Real>::size(); ++j) {
465 for (i = 0; i < maxit; ++i) {
499 for (
unsigned j = 0; j < Bundle_U<Real>::size(); ++j) {
505template<
typename Real>
507 const Real
zero(0), one(1);
509 vsort.assign(v.begin(),v.end());
510 std::sort(vsort.begin(),vsort.end());
511 Real sum(-1), lam(0);
522 for (
unsigned i = 0; i < Bundle_U<Real>::size(); ++i) {
523 x[i] = std::max(
zero,v[i] - lam);
527template<
typename Real>
529 const Real
zero(0), one(1);
Objective_SerialSimOpt(const Ptr< Obj > &obj, const V &ui) z0 zero)()
void applyG_Identity(std::vector< Real > &Gx, const std::vector< Real > &x) const
std::set< unsigned > workingSet_
unsigned projectedCG(std::vector< Real > &x, Real &mu, const std::vector< Real > &b, const Real tol) const
void applyMatrix(std::vector< Real > &Hx, const std::vector< Real > &x) const
Real norm(const std::vector< Real > &x) const
void applyPreconditioner(std::vector< Real > &Px, const std::vector< Real > &x) const
void applyPreconditioner_SymGS(std::vector< Real > &Px, const std::vector< Real > &x) const
void applyPreconditioner_Jacobi(std::vector< Real > &Px, const std::vector< Real > &x) const
void applyG_Jacobi(std::vector< Real > &Gx, const std::vector< Real > &x) const
Ptr< Vector< Real > > gx_
unsigned solveEQPsubproblem(std::vector< Real > &s, Real &mu, const std::vector< Real > &g, const Real tol) const
void computeResidualUpdate(std::vector< Real > &r, std::vector< Real > &g) const
void applyFullMatrix(std::vector< Real > &Hx, const std::vector< Real > &x) const
Bundle_U_AS(const unsigned maxSize=10, const Real coeff=0.0, const Real omega=2.0, const unsigned remSize=2)
void computeLagMult(std::vector< Real > &lam, const Real mu, const std::vector< Real > &g) const
Real dot(const std::vector< Real > &x, const std::vector< Real > &y) const
unsigned solveDual(const Real t, const unsigned maxit=1000, const Real tol=1.e-8)
std::set< unsigned > nworkingSet_
void applyG_SymGS(std::vector< Real > &Gx, const std::vector< Real > &x) const
unsigned solveDual_arbitrary(const Real t, const unsigned maxit=1000, const Real tol=1.e-8)
void initializeDualSolver(void)
Ptr< Vector< Real > > ge_
void applyG(std::vector< Real > &Gx, const std::vector< Real > &x) const
Ptr< Vector< Real > > yG_
bool isNonnegative(unsigned &ind, const std::vector< Real > &x) const
void initialize(const Vector< Real > &g)
void applyPreconditioner_Identity(std::vector< Real > &Px, const std::vector< Real > &x) const
Real computeCriticality(const std::vector< Real > &g, const std::vector< Real > &sol) const
Real computeStepSize(unsigned &ind, const std::vector< Real > &x, const std::vector< Real > &p) const
Ptr< Vector< Real > > eG_
void scale(std::vector< Real > &x, const Real a) const
void axpy(const Real a, const std::vector< Real > &x, std::vector< Real > &y) const
Ptr< Vector< Real > > tG_
void project(std::vector< Real > &x, const std::vector< Real > &v) const
const Real alpha(const unsigned i) const
Real evaluateObjective(std::vector< Real > &g, const std::vector< Real > &x, const Real t) const
const Real getDualVariable(const unsigned i) const
unsigned size(void) 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)
Bundle_U(const unsigned maxSize=10, const Real coeff=0.0, const Real omega=2.0, const unsigned remSize=2)
const Real dotGi(const unsigned i, const Vector< Real > &x) const
const Real GiGj(const unsigned i, const unsigned j) const
virtual void initialize(const Vector< Real > &g)
void addGi(const unsigned i, const Real a, Vector< Real > &x) const
unsigned solveDual_dim2(const Real t, const unsigned maxit=1000, const Real tol=1.e-8)
void setDualVariable(const unsigned i, const Real val)
Defines the linear algebra or vector space interface.
virtual ROL::Ptr< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
Real ROL_EPSILON(void)
Platform-dependent machine epsilon.
Real ROL_OVERFLOW(void)
Platform-dependent maximum double.