10#ifndef ROL_BUNDLE_U_TT_DEF_H
11#define ROL_BUNDLE_U_TT_DEF_H
22#define FIRST_VIOLATED 0
26template<
typename Real>
30 const unsigned remSize)
31 :
Bundle_U<Real>(maxSize,coeff,omega,remSize),
33 maxind_ = std::numeric_limits<int>::max();
36 Id_(i,i) =
static_cast<Real
>(1);
40template<
typename Real>
42 const Real
zero(0), one(1);
43 return ((x <
zero) ? -one :
47template<
typename Real>
62template<
typename Real>
64 const Real
zero(0), one(1);
71 for (
unsigned n=ind1+1; n<=ind2; ++n){
73 Id_n(dd,dd) =
zero; Id_n(dd,n) = one;
74 Id_n(n,dd) = one; Id_n(n,n) =
zero;
77 prod.multiply(LA::ETransp::NO_TRANS,LA::ETransp::NO_TRANS,one,Id_n,
L_,
zero);
80 prod.multiply(LA::ETransp::NO_TRANS,LA::ETransp::NO_TRANS,one,
L_,Id_n,
zero);
87template<
typename Real>
90 kappa_ =
static_cast<Real
>(1);
96 if(
L_(j,j) > tmpdiagMax ){
100 if(
L_(j,j) < tmpdiagMin ){
101 tmpdiagMin =
L_(j,j);
105 kappa_ = tmpdiagMax/tmpdiagMin;
109template<
typename Real>
126 unsigned zsize = ind+1;
127 z1_.resize(zsize);
z2_.resize(zsize);
128 z1_[ind] = (
static_cast<Real
>(1) -
lhz1_ ) / delta;
143template<
typename Real>
145 const Real
zero(0), one(1);
199 else if ( std::abs(ai) > std::abs(aj) ){
202 Real u = sgnb * std::sqrt(one + t*t );
210 Real u = sgna * std::sqrt(one + t*t );
224 Real tmp1 =
L_(h,ind);
226 L_(h,ind) = Gc*tmp1 + Gs*tmp2;
227 L_(h,j) = Gc*tmp2 - Gs*tmp1;
230 Real tmp1 =
z1_[ind];
232 Real tmp3 =
z2_[ind];
234 z1_[ind] = Gc*tmp1 + Gs*tmp2;
235 z1_[j] = Gc*tmp2 - Gs*tmp1;
236 z2_[ind] = Gc*tmp3 + Gs*tmp4;
237 z2_[j] = Gc*tmp4 - Gs*tmp3;
254 for(
unsigned m=ind; m<zsize; m++ ){
277 deltaLh_ = std::abs(ghNorm - lhnrm);
280 Real sgn2 =
sgn(dletaLj);
281 Real signum = sgn1 * sgn2;
285 if( std::sqrt(
deltaLh_) > tol*
kappa_*std::max(
static_cast<Real
>(1),ghNorm) ){
292 for (
unsigned ii=0; ii<newind; ++ii){
293 lh_[ii] =
L_(newind,ii);
328 for (
unsigned ii=0; ii<
currSize_; ++ii) {
331 deltaLj_ = std::abs(gjNorm - ljnrm);
336 if( std::sqrt(
deltaLj_) > tol*
kappa_*std::max(
static_cast<Real
>(1),gjNorm) ){
343 for (
unsigned ii=0;ii<newind-1;ii++){
344 lj_[ii] =
L_(newind,ii);
370template<
typename Real>
373 if( L.numRows()!=
size )
374 std::cout <<
"Error: Wrong size matrix!" << std::endl;
375 else if( v.numRows()!=
size )
376 std::cout <<
"Error: Wrong size vector!" << std::endl;
381 lapack_.TRTRS(
'L', tran,
'N',
size, 1, L.values(), L.stride(), v.values(), v.stride(), &info );
385template<
typename Real>
388 for(
int i=0;i<v.numRows();i++){
396template<
typename Real>
398 const Real
zero(0), half(0.5), one(1);
399 Real z1z2(0), z1z1(0);
411 L_(0,0) = std::sqrt(
GiGj(0,0));
419 z1_.resize(1);
z2_.resize(1);
420 z1_[0] = one/
L_(0,0);
430 for (iter=0;iter<maxit;iter++){
441 rho_ = ( one + z1z2/t )/z1z1;
479 Real tmp = ( one + z1z2 / t -
rho_ * z1z1 )/( one -
lhz1_ );
591 for (
unsigned baseitem=0; baseitem<
currSize_; ++baseitem){
615 Real newobjval(0), Lin(0), Quad(0);
621 newobjval = -half*Quad;
625 newobjval = half*(
rho_ + Lin/t);
652#if ( ! FIRST_VIOLATED )
656 for (
unsigned bundleitem=0; bundleitem<Bundle_U<Real>::size(); ++bundleitem){
681#if ( FIRST_VIOLATED )
686 if ( diff > olddiff ){
706 for (
unsigned i=0; i<zsize; ++i){
709 LA::Matrix<Real> LBprime( LA::Copy,
L_,zsize,zsize);
711 for (
unsigned i=0; i<zsize; ++i){
729 for (
unsigned i=0; i<zsize-1; ++i){
734 if ( delta > deltaeps ){
737 delta = std::sqrt(delta);
740 else if(delta < -deltaeps){
764template<
typename Real>
767 unsigned outermaxit = 20;
768 bool increase =
false, decrease =
false;
770 for (
unsigned it=0; it < outermaxit; ++it ){
776 mytol /=
static_cast<Real
>(10);
780 mytol *=
static_cast<Real
>(10);
783 if ( (mytol >
static_cast<Real
>(1e-4))
784 || (mytol <
static_cast<Real
>(1e-16)) ){
787 if ( increase && decrease ) {
Objective_SerialSimOpt(const Ptr< Obj > &obj, const V &ui) z0 zero)()
Contains definitions of custom data types in ROL.
LA::Vector< Real > tempv_
LAPACK< int, Real > lapack_
Bundle_U_TT(const unsigned maxSize=10, const Real coeff=0.0, const Real omega=2.0, const unsigned remSize=2)
Real sgn(const Real x) const
LA::Vector< Real > tempw1_
void addSubgradToBase(unsigned ind, Real delta)
void deleteSubgradFromBase(unsigned ind, Real tol)
unsigned solveDual_arbitrary(const Real t, const unsigned maxit=1000, const Real tol=1.e-8)
bool isFeasible(LA::Vector< Real > &v, const Real &tol)
void solveSystem(int size, char tran, LA::Matrix< Real > &L, LA::Vector< Real > &v)
LA::Vector< Real > tempw2_
void swapRowsL(unsigned ind1, unsigned ind2, bool trans=false)
std::vector< int > taboo_
unsigned solveDual(const Real t, const unsigned maxit=1000, const Real tol=1.e-8)
unsigned solveDual_TT(const Real t, const unsigned maxit=1000, const Real tol=1.e-8)
const Real alpha(const unsigned i) const
const Real getDualVariable(const unsigned i) const
void resetDualVariables(void)
unsigned size(void) 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 GiGj(const unsigned i, const unsigned j) 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)
Real ROL_EPSILON(void)
Platform-dependent machine epsilon.