ConicBundle
BundleDiagonalTrustRegionProx.hxx
Go to the documentation of this file.
1 
2 
3 #ifndef CONICBUNDLE_BUNDLEDIAGONALTRUSTREGIONPROX_HXX
4 #define CONICBUNDLE_BUNDLEDIAGONALTRUSTREGIONPROX_HXX
5 
6 
15 #include "BundleProxObject.hxx"
16 
17 namespace ConicBundle {
18 
23 
29 {
30 private:
33 
36 
39 
42 
44  typedef std::map<MinorantPointer,CH_Matrix_Classes::Integer> MinorantPointerMap;
46  MinorantPointerMap oldmap;
47 
50 
53 
56 
59 
62 
65 
67  std::vector<const AffineFunctionTransformation*> aft_stack;
68 
69  // CH_Matrix_Classes::Symmatrix last_Q; ///< for testing updates
70  // CH_Matrix_Classes::Matrix last_d; ///< for testing updates
71  // CH_Matrix_Classes::Real last_offset; ///< for testing updates
72 
73 
75  void compute_corr()
76  //{ corr_val=sum(D)-weightu*D.dim(); if (corr_val>D.dim()) corr_val=D.dim()/corr_val; else corr_val=1.;}
77  {corr_val=CH_Matrix_Classes::min(1.,D.rowdim()/sum(D));}
78 
79 public:
83  bool local_scaling=false,
84  bool bounds_scaling=false,
85  CBout* cb=0,
86  int cbinc=-1):
87  BundleProxObject(vp,local_scaling,bounds_scaling,cb,cbinc),
88  weightu(1.),D(Din)
89  {D+=weightu;compute_corr();}
90 
95  bool local_scaling=false,
96  bool bounds_scaling=false,
97  CBout* cb=0,
98  int cbinc=-1):
99  BundleProxObject(vp,local_scaling,bounds_scaling,cb,cbinc),
100  weightu(1.),D(dim,1,weightu+d)
101  {assert(dim>=0);assert(d>=0.);compute_corr();}
102 
106  bool local_scaling=false,
107  bool bounds_scaling=false,
108  CBout* cb=0,
109  int cbinc=-1):
110  BundleProxObject(vp,local_scaling,bounds_scaling,cb,cbinc),
111  weightu(1.),D(dim,1,weightu)
112  {assert(dim>=0);compute_corr();}
113 
116 
118  void set_weightu(CH_Matrix_Classes::Real in_weightu);
119 
122  {return weightu*factor;}
123 
126  {return corr_val*factor;}
127 
129  const CH_Matrix_Classes::Matrix& get_D() const {return D;}
130 
133  {D=in_D+weightu;compute_corr();oldmap.clear();oldQ.init(0,0.);}
134 
136  CH_Matrix_Classes::Integer dim() const {return D.dim();}
137 
140 
143 
146 
149  {return B.dual_norm_squared(&D)/factor;}
150 
152  virtual bool is_DLR() const
153  {return true;}
154 
156  virtual int add_H(CH_Matrix_Classes::Symmatrix& big_sym,CH_Matrix_Classes::Integer start_index=0) const;
157 
160  CH_Matrix_Classes::Matrix& outplusHx,
161  CH_Matrix_Classes::Real alpha=1.) const
162  { return outplusHx.xpeya(D%x,alpha); }
163 
166 
169  { inD=D; Vp=0; }
170 
171 
175  CH_Matrix_Classes::Real& offset,
176  const MinorantPointer& constant_minorant,
177  const MinorantBundle& bundle,
178  const CH_Matrix_Classes::Matrix& y,
179  const MinorantPointer& groundset_minorant,
181 
182 
184  virtual int update_QP_costs(CH_Matrix_Classes::Symmatrix& delta_Q,
185  CH_Matrix_Classes::Matrix& delta_d,
186  CH_Matrix_Classes::Real& delta_offset,
187  const MinorantPointer& constant_minorant,
188  const MinorantBundle& bundle,
189  const CH_Matrix_Classes::Matrix& center_y,
190  const MinorantPointer& groundset_minorant,
191  const MinorantPointer& delta_groundset_minorant,
192  const CH_Matrix_Classes::Indexmatrix& delta_index,
194 
195 
197  virtual int apply_modification(const GroundsetModification& gsmdf);
198 
202  {
203  CH_Matrix_Classes::Matrix tmpD=D(indices);
204  tmpD-=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 
216  virtual bool supports_diagonal_bounds_scaling() const {return true;}
217 
225  {
226  assert(min(D_update)>=0.);
227  update_Dvalue=D_update;D+=D_update;compute_corr();
228  oldmap.clear();oldQ.init(0,0.);
229  return 0;
230  }
231 
233  virtual bool supports_lowrank_variable_metric() const {return false;}
234 
236  virtual bool supports_diagonal_variable_metric() const {return true;}
237 
239  virtual int apply_variable_metric(VariableMetricModel* groundset,
240  VariableMetricModel* model,
241  const CH_Matrix_Classes::Matrix& aggr,
243  const CH_Matrix_Classes::Matrix& y,
244  bool descent_step,
245  CH_Matrix_Classes::Real& current_weight,
246  CH_Matrix_Classes::Real model_maxviol,
247  const CH_Matrix_Classes::Indexmatrix* new_indices =0);
248 
252 
254  virtual int push_aft(const AffineFunctionTransformation* aft)
255  { aft_stack.push_back(aft); return 0;}
256 
258  virtual int pop_aft()
259  {
260  aft_stack.pop_back();
261  return 0;
262  }
263 
265  virtual int mfile_data(std::ostream& out) const;
266 };
267 
268 
270 }
271 
272 #endif
273 
CH_Matrix_Classes::Matrix old_D
for inserting some conservatism in dynamic updating of the diagonal
Definition: BundleDiagonalTrustRegionProx.hxx:61
int Integer
all integer numbers in calculations and indexing are of this type
Definition: matop.hxx:40
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
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
Integer rowdim() const
returns the row dimension
Definition: matrix.hxx:215
CH_Matrix_Classes::Symmatrix oldQ
the old quadratic cost matrix; this is where oldmap points into
Definition: BundleDiagonalTrustRegionProx.hxx:49
double Real
all real numbers in calculations are of this type
Definition: matop.hxx:50
std::map< MinorantPointer, CH_Matrix_Classes::Integer > MinorantPointerMap
The MinorantPointerMap serves to locate an identical MinorantPointer in a previous bundle in order to...
Definition: BundleDiagonalTrustRegionProx.hxx:44
const CH_Matrix_Classes::Matrix * aggr
for judging whether a dynamic diagonal contribution does to aggr what it should ...
Definition: BundleDiagonalTrustRegionProx.hxx:58
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
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 ...
CH_Matrix_Classes::Real operator()(CH_Matrix_Classes::Integer i) const
return the i-th element of the diagonal matrix D
Definition: BundleDiagonalTrustRegionProx.hxx:139
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 CH_Matrix_Classes::Real dnorm_sqr(const MinorantPointer &B) const
returns
Definition: BundleDiagonalTrustRegionProx.hxx:148
virtual int add_variable_metric(CH_Matrix_Classes::Matrix &diagH, CH_Matrix_Classes::Matrix &vecH)
see BundleProxObject::add_dynamic_scaling()
virtual bool is_DLR() const
return true if H is of the form diagonal matrix plus Gram matrix of a low rank matrix ...
Definition: BundleDiagonalTrustRegionProx.hxx:152
BundleDiagonalTrustRegionProx(const CH_Matrix_Classes::Matrix &Din, VariableMetricSelection *vp=0, bool local_scaling=false, bool bounds_scaling=false, CBout *cb=0, int cbinc=-1)
initialize to this diagonal matrix
Definition: BundleDiagonalTrustRegionProx.hxx:81
Symmatrix & init(const Symmatrix &A, double d=1.)
initialize to *this=A*d
Definition: symmat.hxx:753
Matrix class for integral values of type Integer
Definition: indexmat.hxx:195
void dim(Integer &_nr, Integer &_nc) const
returns the number of rows in _nr and the number of columns in _nc
Definition: matrix.hxx:209
CH_Matrix_Classes::Real get_weightu() const
returns the current weight of the proximal term
Definition: BundleDiagonalTrustRegionProx.hxx:121
CH_Matrix_Classes::Matrix D
the diaongal of the diagonal matrix with the weightu added into it
Definition: BundleDiagonalTrustRegionProx.hxx:35
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...
BundleDiagonalTrustRegionProx(CH_Matrix_Classes::Integer dim=0, VariableMetricSelection *vp=0, bool local_scaling=false, bool bounds_scaling=false, CBout *cb=0, int cbinc=-1)
initialize to a zero diaognal matrix of dimesion dim
Definition: BundleDiagonalTrustRegionProx.hxx:104
virtual int push_aft(const AffineFunctionTransformation *aft)
see BundleProxObject::push_aft();
Definition: BundleDiagonalTrustRegionProx.hxx:254
BundleDiagonalTrustRegionProx(CH_Matrix_Classes::Integer dim, CH_Matrix_Classes::Real d, VariableMetricSelection *vp=0, bool local_scaling=false, bool bounds_scaling=false, CBout *cb=0, int cbinc=-1)
initialize to a diaognal matrix d*identity of dimesion dim
Definition: BundleDiagonalTrustRegionProx.hxx:92
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
void set_D(CH_Matrix_Classes::Matrix &in_D)
set the diagonal (it needs to be >=0 but this is not checked)
Definition: BundleDiagonalTrustRegionProx.hxx:132
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
const CH_Matrix_Classes::Matrix & get_D() const
returns the diagonal D of the diagonal scaling matrix
Definition: BundleDiagonalTrustRegionProx.hxx:129
conic bundle method solver for sum of convex functions. See the ConicBundle_Manual for a quick introd...
Definition: CBSolver.hxx:22
base class for uniform use of WARNINGS and ERRORS (at some point in time)
Definition: CBout.hxx:30
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
const CH_Matrix_Classes::Indexmatrix * new_indices
if values should be computed for a new subset indices, this is stored here
Definition: BundleDiagonalTrustRegionProx.hxx:55
CH_Matrix_Classes::Real corr_val
the correction value for correcting termination precision
Definition: BundleDiagonalTrustRegionProx.hxx:38
CH_Matrix_Classes::Integer dim() const
returns the dimension of the diagonal
Definition: BundleDiagonalTrustRegionProx.hxx:136
virtual int apply_modification(const GroundsetModification &gsmdf)
when BundleSolver is called to modify the groundset it also calls this
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 VariableMetric
MinorantPointerMap oldmap
identifies which MinorantPointer was used last time in which position
Definition: BundleDiagonalTrustRegionProx.hxx:46
virtual int diagonal_bounds_scaling_update(const CH_Matrix_Classes::Matrix &D_update)
if supported, D_update has to contain nonnegative numbers that are permanently added to the diagonal ...
Definition: BundleDiagonalTrustRegionProx.hxx:224
implements the abstract interface ConicBundle::BundleProxObject for with H=D+weight*I, where D is a diagonal matrix, giving rise to an augmented model with diagonal scaling
Definition: BundleDiagonalTrustRegionProx.hxx:28
CH_Matrix_Classes::Real get_term_corr() const
returns a correction factor for termination precision if the quadratic term is strong ...
Definition: BundleDiagonalTrustRegionProx.hxx:125
virtual bool supports_lowrank_variable_metric() const
returns true if dynamic scaling with low rank matrices is supported
Definition: BundleDiagonalTrustRegionProx.hxx:233
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: BundleDiagonalTrustRegionProx.hxx:159
CH_Matrix_Classes::Real old_damping
corrects excessive step reductions by dynamic scaling, recomputed in descent steps ...
Definition: BundleDiagonalTrustRegionProx.hxx:64
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
CH_Matrix_Classes::Indexmatrix old_fixed_ind
the old fixed indices for which oldmap and oldQ were computed
Definition: BundleDiagonalTrustRegionProx.hxx:52
std::ostream * out
not output at all if out==0, otherwise use this output stream
Definition: CBout.hxx:33
virtual CH_Matrix_Classes::Real norm_sqr(const CH_Matrix_Classes::Matrix &B) const
returns
virtual bool supports_diagonal_variable_metric() const
returns true if dynamic scaling with diagonal matrices is supported
Definition: BundleDiagonalTrustRegionProx.hxx:236
std::vector< MinorantPointer > MinorantBundle
a bundle is a vector with MinorantPointer entries
Definition: MinorantPointer.hxx:24
void compute_corr()
computes the correction value, here min(1,dim/trace(D)))
Definition: BundleDiagonalTrustRegionProx.hxx:75
CH_Matrix_Classes::Real dual_norm_squared(const CH_Matrix_Classes::Matrix *D=0) const
Compute the dual norm squared of this for the given diagonal matrix D (identity if not given)...
CH_Matrix_Classes::Real weightu
the current weightu added into the diagonal D
Definition: BundleDiagonalTrustRegionProx.hxx:32
virtual bool supports_diagonal_bounds_scaling() const
this implementation supports a diagonal scaling heuristic for bounds in the groundset, therefore the following routine has to return true.
Definition: BundleDiagonalTrustRegionProx.hxx:216
virtual ~BundleDiagonalTrustRegionProx()
destructor
Definition: BundleDiagonalTrustRegionProx.hxx:115
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
virtual CH_Matrix_Classes::Matrix & apply_Hinv(CH_Matrix_Classes::Matrix &x) const
returns
void set_weightu(CH_Matrix_Classes::Real in_weightu)
set the weight of the proximal term
std::vector< const AffineFunctionTransformation * > aft_stack
in add_dynamic_scaling() the stack serves to transform the given data
Definition: BundleDiagonalTrustRegionProx.hxx:67
bool get_use_bounds_scaling() const
returns use_bounds_scaling
Definition: VariableMetric.hxx:412
CH_Matrix_Classes::Matrix update_Dvalue
used for the diagonal scaling heuristic
Definition: BundleDiagonalTrustRegionProx.hxx:41
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: BundleDiagonalTrustRegionProx.hxx:168
Integer sum(const Indexmatrix &A)
returns the sum over all elements of A, i.e., (1 1 ... 1)*A*(1 1 ... 1)^T
virtual int mfile_data(std::ostream &out) const
output the description of the scaling in mfile-suitable format
CH_Matrix_Classes::Real operator[](CH_Matrix_Classes::Integer i) const
return the i-th element of the diagonal matrix D
Definition: BundleDiagonalTrustRegionProx.hxx:142
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
virtual int pop_aft()
see BundleProxObject::pop_aft();
Definition: BundleDiagonalTrustRegionProx.hxx:258
points to MinorantUseData that may be shared by many and allows computations with Minorants ...
Definition: MinorantPointer.hxx:34
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: BundleDiagonalTrustRegionProx.hxx:201