ConicBundle
BundleDenseTrustRegionProx.hxx
Go to the documentation of this file.
1 
2 #ifndef CONICBUNDLE_BUNDLEDENSETRUSTREGIONPROX_HXX
3 #define CONICBUNDLE_BUNDLEDENSETRUSTREGIONPROX_HXX
4 
5 
14 #include "BundleProxObject.hxx"
15 
16 namespace ConicBundle {
17 
22 
29 {
30 private:
33 
36 
38  mutable bool is_factored;
39 
42 
43 
46 
49 
72 
73 
76 
78  std::vector<const AffineFunctionTransformation*> aft_stack;
79 
81  void compute_corr()
82  //{ corr_val=trace(H); if (corr_val>H.rowdim()) corr_val=H.rowdim()/corr_val; else corr_val=1.;}
83  {corr_val=CH_Matrix_Classes::min(1.,H.rowdim()/(H.rowdim()*weightu+trace(H)));}
84 
85 public:
86 
90  bool local_metric=false,
91  bool bounds_scaling=false,
92  CBout* cb=0,
93  int cbinc=-1):
94  BundleProxObject(vp,local_metric,bounds_scaling,cb,cbinc),
95  H(Hin),is_factored(false)
96  {weightu=1.;}
97 
101  bool local_metric=false,
102  bool bounds_scaling=false,
103  CBout* cb=0,
104  int cbinc=-1):
105  BundleProxObject(vp,local_metric,bounds_scaling,cb,cbinc),
106  H(dim,0.),is_factored(false)
107  {assert(dim>=0);weightu=1.;}
108 
110  virtual ~BundleDenseTrustRegionProx(){}
111 
113  void set_weightu(CH_Matrix_Classes::Real in_weightu);
114 
117  {return weightu;}
118 
121  {return corr_val;}
122 
125  {is_factored=false; return H=in_H;}
126 
128  bool get_factored() const {return is_factored;}
129 
131  const CH_Matrix_Classes::Symmatrix& get_H() const {return H;}
132 
135 
137  CH_Matrix_Classes::Integer dim() const {return H.rowdim();}
138 
141  {return H(i,j);}
142 
145 
147  virtual CH_Matrix_Classes::Real dnorm_sqr(const MinorantPointer& B) const;
148 
150  virtual bool is_DLR() const
151  {return false;}
152 
154  virtual int add_H(CH_Matrix_Classes::Symmatrix& big_sym,CH_Matrix_Classes::Integer start_index=0) const;
155 
158  CH_Matrix_Classes::Matrix& outplusHx,
159  CH_Matrix_Classes::Real alpha=1.) const
160  { outplusHx.xpeya(x,weightu*alpha); return genmult(H,x,outplusHx,alpha,1.);}
161 
164 
167  { inD=diag(H); inD+=weightu; Vp=0; }
168 
169 
173  CH_Matrix_Classes::Real& offset,
174  const MinorantPointer& constant_minorant,
175  const MinorantBundle& bundle,
176  const CH_Matrix_Classes::Matrix& y,
177  const MinorantPointer& groundset_minorant,
179 
180 
182  virtual int update_QP_costs(CH_Matrix_Classes::Symmatrix& delta_Q,
183  CH_Matrix_Classes::Matrix& delta_d,
184  CH_Matrix_Classes::Real& delta_offset,
185  const MinorantPointer& constant_minorant,
186  const MinorantBundle& bundle,
187  const CH_Matrix_Classes::Matrix& center_y,
188  const MinorantPointer& groundset_minorant,
189  const MinorantPointer& delta_groundset_minorant,
190  const CH_Matrix_Classes::Indexmatrix& delta_index,
192 
193 
195  virtual int apply_modification(const GroundsetModification& gsmdf);
196 
200  {
202  H.principal_submatrix(indices,S);
203  for(CH_Matrix_Classes::Integer i=0;i<S.rowdim();i++)
204  S(i,i)-=weightu;
206  pp->set_weightu(weightu);
207  pp->apply_factor(factor);
209  pp->set_variable_metric_selection(get_variable_metric_selection()->clone_VariableMetricSelection());
210  return pp;
211  }
212 
213 
217  virtual bool supports_diagonal_bounds_scaling() const {return false;}
218 
226  {
227  return 1;
228  }
229 
231  virtual bool supports_dense_variable_metric() const
232  {return true;}
233 
235  virtual bool supports_lowrank_variable_metric() const
236  {return true;}
237 
240  {return true;}
241 
243  virtual int apply_variable_metric(VariableMetricModel* groundset,
244  VariableMetricModel* model,
245  const CH_Matrix_Classes::Matrix& aggr,
247  const CH_Matrix_Classes::Matrix& y,
248  bool descent_step,
249  CH_Matrix_Classes::Real& current_weight,
250  CH_Matrix_Classes::Real model_maxviol,
251  const CH_Matrix_Classes::Indexmatrix* new_indices =0);
252 
255 
259 
261  virtual int push_aft(const AffineFunctionTransformation* aft)
262  { aft_stack.push_back(aft); return 0;}
263 
265  virtual int pop_aft()
266  {
267  aft_stack.pop_back();
268  return 0;
269  }
270 
272  virtual int mfile_data(std::ostream& out) const;
273 
274 
275 };
276 
277 
279 }
280 
281 #endif
282 
int Integer
all integer numbers in calculations and indexing are of this type
Definition: matop.hxx:40
virtual CH_Matrix_Classes::Real dnorm_sqr(const MinorantPointer &B) const
returns $|B|^2_{H^{-1}}$ (with weightu included in H)
Matrix & xpeya(const Matrix &A, Real d=1.)
sets *this+=d*A and returns *this
abstract interface that allows to use different -norms with a positive definite matrix in the proxi...
Definition: BundleProxObject.hxx:88
virtual bool supports_diagonal_bounds_scaling() const
this implementation does not support a diagonal scaling heuristic, therefore the following routine ha...
Definition: BundleDenseTrustRegionProx.hxx:217
virtual int mfile_data(std::ostream &out) const
output the description of the scaling in mfile-suitable format
CH_Matrix_Classes::Real get_term_corr() const
returns a correction factor for termination precision if the quadratic term is strong ...
Definition: BundleDenseTrustRegionProx.hxx:120
double Real
all real numbers in calculations are of this type
Definition: matop.hxx:50
CH_Matrix_Classes::Matrix & genmult(const MinorantBundle &A, const CH_Matrix_Classes::Matrix &B, CH_Matrix_Classes::Matrix &C, CH_Matrix_Classes::Real alpha=1., CH_Matrix_Classes::Real beta=0., int Atrans=0, int Btrans=0, CH_Matrix_Classes::Matrix *Coffset=0)
computes and returns C=alpha*A*B+beta*C where A and B may be transposed and A is considered to have t...
CH_Matrix_Classes::Real factor
used to accumulate a compensation factor for function_factor; this factor is not included in H but ca...
Definition: BundleProxObject.hxx:95
void set_variable_metric_selection(VariableMetricSelection *vp=0)
sets use_variable_metric; the object passed is then owned by this
Definition: VariableMetric.hxx:342
virtual int pop_aft()
see BundleProxObject::pop_aft();
Definition: BundleDenseTrustRegionProx.hxx:265
virtual bool supports_lowrank_variable_metric() const
returns true if dynamic scaling with low rank structure is supported
Definition: BundleDenseTrustRegionProx.hxx:235
Matrix class for integral values of type Integer
Definition: indexmat.hxx:195
virtual int compute_QP_costs(CH_Matrix_Classes::Symmatrix &Q, CH_Matrix_Classes::Matrix &d, CH_Matrix_Classes::Real &offset, const MinorantPointer &constant_minorant, const MinorantBundle &bundle, const CH_Matrix_Classes::Matrix &y, const MinorantPointer &groundset_minorant, CH_Matrix_Classes::Indexmatrix *yfixed)
computes the dual QP costs Q, d, and the constant offset to the bundle subproblem, see BundleProxObject::compute_QP_costs
virtual CH_Matrix_Classes::Matrix & add_Hx(const CH_Matrix_Classes::Matrix &x, CH_Matrix_Classes::Matrix &outplusHx, CH_Matrix_Classes::Real alpha=1.) const
adds to outplusHx and returns this
Definition: BundleDenseTrustRegionProx.hxx:157
Header declaring the class ConicBundle::BundleProxObject.
VariableMetricSelection * get_variable_metric_selection() const
returns 0 or an available VariableMetricSelection object, that may be employed for computing a variab...
Definition: VariableMetric.hxx:339
std::vector< const AffineFunctionTransformation * > aft_stack
in add_variable_metric() the stack serves to transform the given data
Definition: BundleDenseTrustRegionProx.hxx:78
virtual bool supports_dense_variable_metric() const
returns true if dynamic scaling with dense symmetric matrices is supported
Definition: BundleDenseTrustRegionProx.hxx:231
CH_Matrix_Classes::Matrix oldd
the old linear cost term;
Definition: BundleDenseTrustRegionProx.hxx:69
bool get_use_local_metric() const
returns use_local_metric
Definition: VariableMetric.hxx:435
Matrix class of symmetric matrices with real values of type Real
Definition: symmat.hxx:43
Integer rowdim() const
returns the row dimension
Definition: symmat.hxx:159
CH_Matrix_Classes::Symmatrix H
the metric matrix without weightu added to it
Definition: BundleDenseTrustRegionProx.hxx:32
Symmatrix & principal_submatrix(const Indexmatrix &ind, Symmatrix &S) const
returns S and in S the principal submatrix indexed by ind (multiple indices are allowed) ...
CH_Matrix_Classes::Real oldoffset
the old costant cost term;
Definition: BundleDenseTrustRegionProx.hxx:71
virtual int apply_variable_metric(VariableMetricModel *groundset, VariableMetricModel *model, const CH_Matrix_Classes::Matrix &aggr, CH_Matrix_Classes::Integer y_id, const CH_Matrix_Classes::Matrix &y, bool descent_step, CH_Matrix_Classes::Real &current_weight, CH_Matrix_Classes::Real model_maxviol, const CH_Matrix_Classes::Indexmatrix *new_indices=0)
see DynamicScaling
CH_Matrix_Classes::Real get_weightu() const
returns the current weight of the proximal term
Definition: BundleDenseTrustRegionProx.hxx:116
conic bundle method solver for sum of convex functions. See the ConicBundle_Manual for a quick introd...
Definition: CBSolver.hxx:22
CH_Matrix_Classes::Symmatrix oldQ
the old quadratic cost matrix
Definition: BundleDenseTrustRegionProx.hxx:67
virtual CH_Matrix_Classes::Real norm_sqr(const CH_Matrix_Classes::Matrix &B) const
returns $|B|^2_H$ (with weightu included in H)
base class for uniform use of WARNINGS and ERRORS (at some point in time)
Definition: CBout.hxx:30
virtual int add_variable_metric(CH_Matrix_Classes::Symmatrix &addH)
see BundleProxObject::add_variable_metric()
virtual int diagonal_bounds_scaling_update(const CH_Matrix_Classes::Matrix &)
if supported, D_update has to contain nonnegative numbers that are permanently added to the diagonal ...
Definition: BundleDenseTrustRegionProx.hxx:225
int apply_factor(CH_Matrix_Classes::Real f)
allows AFTModel and SumModel to accumulate a compensation factor for tracing the effects of recursive...
Definition: BundleProxObject.hxx:122
declares the interface that a BundelModel needs to provide for contributing to VariableMetric informa...
Definition: VariableMetric.hxx:111
CH_Matrix_Classes::Matrix _y
for compute_QP_costs() this holds the non_fixed part of center_y
Definition: BundleDenseTrustRegionProx.hxx:61
virtual CH_Matrix_Classes::Matrix & apply_Hinv(CH_Matrix_Classes::Matrix &x) const
returns
CH_Matrix_Classes::Real _delta
for compute_QP_costs() this holds the constant offset
Definition: BundleDenseTrustRegionProx.hxx:59
void set_weightu(CH_Matrix_Classes::Real in_weightu)
set the weight of the proximal term
Integer trace(const Indexmatrix &A)
returns the sum of the diagonal elements A(i,i) over all i
bool is_factored
true iff Hchol is computed for the current H and weightu
Definition: BundleDenseTrustRegionProx.hxx:38
void compute_corr()
computes the correction value, here min(1,dim/trace(H))
Definition: BundleDenseTrustRegionProx.hxx:81
Indexmatrix diag(const Indexmatrix &A)
returns a column vector v consisting of the elements v(i)=A(i,i), 0<=i<min(row dimension,column dimension)
const CH_Matrix_Classes::Indexmatrix * new_indices
if values should be computed for a new subset indices, this is stored here
Definition: BundleDenseTrustRegionProx.hxx:75
const CH_Matrix_Classes::Symmatrix & get_Hchol() const
returns the stored factorization of H with weightu (up to date if get_factored()==true) ...
Definition: BundleDenseTrustRegionProx.hxx:134
BundleDenseTrustRegionProx(const CH_Matrix_Classes::Symmatrix &Hin, VariableMetricSelection *vp=0, bool local_metric=false, bool bounds_scaling=false, CBout *cb=0, int cbinc=-1)
initialize to this Matrix and set the variable_metric option (false by default)
Definition: BundleDenseTrustRegionProx.hxx:88
CH_Matrix_Classes::Integer dim() const
returns the order of the matrix
Definition: BundleDenseTrustRegionProx.hxx:137
virtual int update_QP_costs(CH_Matrix_Classes::Symmatrix &delta_Q, CH_Matrix_Classes::Matrix &delta_d, CH_Matrix_Classes::Real &delta_offset, const MinorantPointer &constant_minorant, const MinorantBundle &bundle, const CH_Matrix_Classes::Matrix &center_y, const MinorantPointer &groundset_minorant, const MinorantPointer &delta_groundset_minorant, const CH_Matrix_Classes::Indexmatrix &delta_index, CH_Matrix_Classes::Indexmatrix *yfixed)
updates the dual QP costs Q, d, and the constant offset to the bundle subproblem, see BundleProxObjec...
implements the abstract interface ConicBundle::BundleProxObject for for general symmetric H+weight*I...
Definition: BundleDenseTrustRegionProx.hxx:28
Matrix class for real values of type Real
Definition: matrix.hxx:74
abstract interface, that allows to specify a routine for providing or computing a suitable variable m...
Definition: VariableMetric.hxx:237
const CH_Matrix_Classes::Symmatrix & init(CH_Matrix_Classes::Symmatrix &in_H)
set H with the information, whether it is factored
Definition: BundleDenseTrustRegionProx.hxx:124
virtual bool is_DLR() const
return true if H is of the form diagonal matrix plus Gram matrix of a low rank matrix ...
Definition: BundleDenseTrustRegionProx.hxx:150
CH_Matrix_Classes::Real corr_val
the correction value for correcting termination precision
Definition: BundleDenseTrustRegionProx.hxx:48
std::ostream * out
not output at all if out==0, otherwise use this output stream
Definition: CBout.hxx:33
CH_Matrix_Classes::Matrix _c
for compute_QP_costs() this holds the offset values of the subgradients
Definition: BundleDenseTrustRegionProx.hxx:57
std::vector< MinorantPointer > MinorantBundle
a bundle is a vector with MinorantPointer entries
Definition: MinorantPointer.hxx:24
CH_Matrix_Classes::Real weightu
the current weightu added to H
Definition: BundleDenseTrustRegionProx.hxx:45
CH_Matrix_Classes::Matrix _b
for compute_QP_costs() this holds the constant subgradient
Definition: BundleDenseTrustRegionProx.hxx:55
CH_Matrix_Classes::Symmatrix Hchol
if is_facotred==ture this holds the Cholesky factor of (H+weightu*I)
Definition: BundleDenseTrustRegionProx.hxx:35
bool get_factored() const
returns true iff get_Hchol() returns the factord matrix of H with weightu
Definition: BundleDenseTrustRegionProx.hxx:128
const CH_Matrix_Classes::Symmatrix & get_H() const
returns the metric matrix without weightu
Definition: BundleDenseTrustRegionProx.hxx:131
virtual BundleProxObject * projected_clone(const CH_Matrix_Classes::Indexmatrix &indices)
in order to allow for fixed variables, this generates a clone restricted to the given indices ...
Definition: BundleDenseTrustRegionProx.hxx:199
virtual int apply_modification(const GroundsetModification &gsmdf)
when BundleSolver is called to modify the groundset it also calls this
CH_Matrix_Classes::Symmatrix Hind_chol
holds the Cholesky factor of (H+weightu*I) with old_fixed_ind deleted if the dimension fits ...
Definition: BundleDenseTrustRegionProx.hxx:41
CH_Matrix_Classes::Indexmatrix old_fixed_ind
the fixed indices for which the QP_costs were computed
Definition: BundleDenseTrustRegionProx.hxx:51
double min(double a, double b)
minimum value of two double variables
Definition: mymath.hxx:49
Collects modifications for the unconstrained Groundset for appending, deleting or reassigning variabl...
Definition: GroundsetModification.hxx:32
bool get_use_bounds_scaling() const
returns use_bounds_scaling
Definition: VariableMetric.hxx:412
virtual void get_precond(CH_Matrix_Classes::Matrix &inD, const CH_Matrix_Classes::Matrix *&Vp) const
returns a suitable approximation for preconditioning, see BundleProxObject::get_precond ...
Definition: BundleDenseTrustRegionProx.hxx:166
transform a function f(z) to fun_coeff*f(arg_offset+arg_trafo*y)+linear_cost*y+fun_offset (scales the...
Definition: AffineFunctionTransformation.hxx:68
BundleDenseTrustRegionProx(CH_Matrix_Classes::Integer dim=0, VariableMetricSelection *vp=0, bool local_metric=false, bool bounds_scaling=false, CBout *cb=0, int cbinc=-1)
initialize H to the zero Matrix of this dimension (on the diagonal the weight will be added) and set ...
Definition: BundleDenseTrustRegionProx.hxx:99
const CH_Matrix_Classes::Real & operator()(CH_Matrix_Classes::Integer i, CH_Matrix_Classes::Integer j)
returns H(i,j) (without including weightu)
Definition: BundleDenseTrustRegionProx.hxx:140
CH_Matrix_Classes::Matrix LinvA
for compute_QP_costs() this holds L^{-1}*_A
Definition: BundleDenseTrustRegionProx.hxx:63
CH_Matrix_Classes::Matrix Lty
for compute_QP_costs() this holds L^T*_y
Definition: BundleDenseTrustRegionProx.hxx:65
points to MinorantUseData that may be shared by many and allows computations with Minorants ...
Definition: MinorantPointer.hxx:34
virtual int add_H(CH_Matrix_Classes::Symmatrix &big_sym, CH_Matrix_Classes::Integer start_index=0) const
add H to the dense symmetric matrix as a principal submatrix starting at position start_index ...
virtual int push_aft(const AffineFunctionTransformation *aft)
see BundleProxObject::push_aft();
Definition: BundleDenseTrustRegionProx.hxx:261
CH_Matrix_Classes::Matrix _A
for compute_QP_costs() this holds the non_fixed part of the subgradients
Definition: BundleDenseTrustRegionProx.hxx:53
virtual bool supports_diagonal_variable_metric() const
returns true if dynamic scaling with diagonal matrices is supported
Definition: BundleDenseTrustRegionProx.hxx:239