ConicBundle
VariableMetric.hxx
Go to the documentation of this file.
1 
2 
3 #ifndef CONICBUNDLE_VARIABLEMETRIC_HXX
4 #define CONICBUNDLE_VARIABLEMETRIC_HXX
5 
6 
15 #include "CBout.hxx"
16 #include "MinorantPointer.hxx"
17 
18 namespace ConicBundle {
19 
20  class AffineFunctionTransformation;
21 
106 
107  class VariableMetric;
108 
110 
111 class VariableMetricModel: public virtual CBout
112 {
113 public:
115  VariableMetricModel(CBout* cb=0,int cbincr=-1);
117  virtual ~VariableMetricModel();
118 
155  virtual int add_variable_metric(VariableMetric& H,
157  const CH_Matrix_Classes::Matrix& y,
158  bool descent_step ,
159  CH_Matrix_Classes::Real weightu ,
160  CH_Matrix_Classes::Real model_maxviol,
161  const CH_Matrix_Classes::Indexmatrix* indices =0);
162 
170 
171 };
172 
173 
184 {
185 private:
189 
190 public:
192  virtual ~VariableMetricBundleData();
193 
195  virtual CH_Matrix_Classes::Real get_function_factor() const=0;
196 
198  virtual int get_latest_minorants(MinorantBundle& latest_minorants,
199  CH_Matrix_Classes::Integer max_number) =0;
200 
202  virtual int get_model_data(MinorantBundle& model_minorants,
203  CH_Matrix_Classes::Matrix& model_coeff) const=0;
204 
206  virtual const MinorantPointer& get_aggregate() const=0;
207 
210  {return vmbd_denseH;}
211 
214  {return vmbd_denseH;}
215 
218  {return vmbd_lowrankH;}
219 
222  {return vmbd_lowrankH;}
223 
225  virtual const CH_Matrix_Classes::Matrix& get_diagH() const
226  {return vmbd_diagH;}
227 
230  {return vmbd_diagH;}
231 };
232 
233 
237 class VariableMetricSelection: public virtual CBout
238 {
239 public:
241  VariableMetricSelection(CBout* cb=0,int cbincr=-1);
243  virtual ~VariableMetricSelection();
244 
284  virtual int add_variable_metric(VariableMetric& H,
286  const CH_Matrix_Classes::Matrix& y,
287  bool descent_step,
288  CH_Matrix_Classes::Real weightu,
289  CH_Matrix_Classes::Real model_maxviol,
290  const CH_Matrix_Classes::Indexmatrix* indices,
291  VariableMetricBundleData& bundle_data)=0;
292 
294  virtual VariableMetricSelection* clone_VariableMetricSelection() =0;
295 
296 };
297 
298 
299 
300 
301 
302 
303 
304 
309 class VariableMetric: public virtual CBout
310 {
311 private:
314 
317 
320 
321 public:
323  virtual ~VariableMetric();
324 
327  bool use_loc_metric=false,
328  bool use_bnds_scaling=false,
329  CBout* cbo=0,int cbinc=-1):
330  CBout(cbo,cbinc),
331  vm_selection(vp),
332  use_local_metric(use_loc_metric),
333  use_bounds_scaling(use_bnds_scaling)
334  {
335  vm_selection=vp;
336  }
337 
340 
343  {delete vm_selection;vm_selection=vp;}
344 
346  virtual bool supports_dense_variable_metric() const
347  {return false;}
348 
350  virtual bool supports_lowrank_variable_metric() const
351  {return false;}
352 
355  {return false;}
356 
359  {return (vm_selection)&&(supports_diagonal_variable_metric()||
360  supports_lowrank_variable_metric()||
361  supports_dense_variable_metric());}
362 
364  virtual int apply_variable_metric(VariableMetricModel* /* groundset */,
365  VariableMetricModel* /* model */,
366  const CH_Matrix_Classes::Matrix& /* aggregate */,
367  CH_Matrix_Classes::Integer /* y_id */,
368  const CH_Matrix_Classes::Matrix& /* y */,
369  bool /* descent_step */,
370  CH_Matrix_Classes::Real& /* current_weight */,
371  CH_Matrix_Classes::Real /* model_maxviol */,
372  const CH_Matrix_Classes::Indexmatrix* /* new_indices */=0)
373  {return 1;}
374 
384  {return 1;}
385 
398  CH_Matrix_Classes::Matrix& /* vecH */)
399  {return 1;}
400 
401 
403  virtual int push_aft(const AffineFunctionTransformation* /* aft */)
404  {return 1;}
405 
407  virtual int pop_aft()
408  {return 1;}
409 
410 
412  bool get_use_bounds_scaling() const {return use_bounds_scaling;}
413 
415  void set_use_bounds_scaling(bool bounds_scaling)
416  {use_bounds_scaling=bounds_scaling;}
417 
420  virtual bool supports_diagonal_bounds_scaling() const {return false;}
421 
425  {return (use_bounds_scaling && supports_diagonal_bounds_scaling());}
426 
432  {return 1;}
433 
435  bool get_use_local_metric() const {return use_local_metric;}
436 
438  void set_use_local_metric(bool local_metric)
439  {use_local_metric=local_metric;}
440 
441 
442 };
443 
444 
445 
447 
448 }
449 
450 #endif
451 
int Integer
all integer numbers in calculations and indexing are of this type
Definition: matop.hxx:40
virtual bool supports_lowrank_variable_metric() const
returns true if add_variable_metric() does not ignore the low rank argument vecH
Definition: VariableMetric.hxx:350
virtual const CH_Matrix_Classes::Matrix & get_diagH() const
allows to retrieve the diagonal variable metric information generated in the previous call and allows...
Definition: VariableMetric.hxx:225
virtual bool supports_diagonal_bounds_scaling() const
if the respective implementation supports a diagonal bounds scaling heuristic, the following routine ...
Definition: VariableMetric.hxx:420
double Real
all real numbers in calculations are of this type
Definition: matop.hxx:50
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: VariableMetric.hxx:431
virtual CH_Matrix_Classes::Matrix & set_lowrankH()
allows to retrieve the low rank variable metric information generated in the previous call and allows...
Definition: VariableMetric.hxx:221
void set_use_bounds_scaling(bool bounds_scaling)
sets use_bounds_scaling
Definition: VariableMetric.hxx:415
void set_variable_metric_selection(VariableMetricSelection *vp=0)
sets use_variable_metric; the object passed is then owned by this
Definition: VariableMetric.hxx:342
Matrix class for integral values of type Integer
Definition: indexmat.hxx:195
VariableMetricSelection * vm_selection
NULL also signals not to call dynamic VariableMetric routines; if a corresponding object has been tra...
Definition: VariableMetric.hxx:313
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
virtual bool supports_dense_variable_metric() const
returns true if add_dense_variable_metric() is supported
Definition: VariableMetric.hxx:346
bool employ_diagonal_bounds_scaling() const
if the respective implementation supports a diagonal bounds scaling heuristic, the following routine ...
Definition: VariableMetric.hxx:424
bool get_use_local_metric() const
returns use_local_metric
Definition: VariableMetric.hxx:435
CH_Matrix_Classes::Matrix vmbd_lowrankH
used by the variable metric low rank heuristic (without function_factor)
Definition: VariableMetric.hxx:186
Matrix class of symmetric matrices with real values of type Real
Definition: symmat.hxx:43
virtual CH_Matrix_Classes::Matrix & set_diagH()
allows to retrieve the diagonal variable metric information generated in the previous call and allows...
Definition: VariableMetric.hxx:229
virtual int add_variable_metric(VariableMetric &H, CH_Matrix_Classes::Integer y_id, const CH_Matrix_Classes::Matrix &y, bool descent_step, CH_Matrix_Classes::Real weightu, CH_Matrix_Classes::Real model_maxviol, const CH_Matrix_Classes::Indexmatrix *indices=0)
add to the variable metric information H some model dependent "second order" information of the funct...
CH_Matrix_Classes::Symmatrix vmbd_denseH
used by the variable metric heuristic
Definition: VariableMetric.hxx:188
conic bundle method solver for sum of convex functions. See the ConicBundle_Manual for a quick introd...
Definition: CBSolver.hxx:22
virtual int add_variable_metric(CH_Matrix_Classes::Matrix &, CH_Matrix_Classes::Matrix &)
adds (a suitable modification of) Diag(diagH)+vecH*transpose(vecH) to the scaling matrix H (either ma...
Definition: VariableMetric.hxx:397
virtual int apply_variable_metric(VariableMetricModel *, VariableMetricModel *, const CH_Matrix_Classes::Matrix &, CH_Matrix_Classes::Integer, const CH_Matrix_Classes::Matrix &, bool, CH_Matrix_Classes::Real &, CH_Matrix_Classes::Real, const CH_Matrix_Classes::Indexmatrix *=0)
the BundleSolver starts an update of this by dynamic scaling by calling this in every step; negative ...
Definition: VariableMetric.hxx:364
base class for uniform use of WARNINGS and ERRORS (at some point in time)
Definition: CBout.hxx:30
declares the interface that a BundelModel needs to provide for contributing to VariableMetric informa...
Definition: VariableMetric.hxx:111
void set_use_local_metric(bool local_metric)
sets use_local_metric
Definition: VariableMetric.hxx:438
Header declaring the output class CBout.
interface class that allows a VariableMetricModel to contribute information to a VariableMetric objec...
Definition: VariableMetric.hxx:309
virtual const CH_Matrix_Classes::Symmatrix & get_denseH() const
allows to retrieve dense variable metric information stored here
Definition: VariableMetric.hxx:209
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
bool use_local_metric
flag for whether the scaling information should be collected from active local models; if false...
Definition: VariableMetric.hxx:316
VariableMetricModel(CBout *cb=0, int cbincr=-1)
constructor for passing on ouptut information
CH_Matrix_Classes::Matrix vmbd_diagH
used by the variable metric low rank heuristic (without function_factor)
Definition: VariableMetric.hxx:187
std::vector< MinorantPointer > MinorantBundle
a bundle is a vector with MinorantPointer entries
Definition: MinorantPointer.hxx:24
virtual int push_aft(const AffineFunctionTransformation *)
this AffineFunctionTransformation has to be used before applying Hinv in
Definition: VariableMetric.hxx:403
VariableMetric(VariableMetricSelection *vp=0, bool use_loc_metric=false, bool use_bnds_scaling=false, CBout *cbo=0, int cbinc=-1)
default constructor; if vp is not zero, ownership of *vp is passed over to *this and *this will delet...
Definition: VariableMetric.hxx:326
virtual ~VariableMetricModel()
virtual destructor
virtual bool supports_diagonal_variable_metric() const
returns true if add_variable_metric() does not ignore the diagonal argument diagH ...
Definition: VariableMetric.hxx:354
virtual CH_Matrix_Classes::Symmatrix & set_denseH()
allows to retrieve the dense variable metric information generated in the previous call and allows to...
Definition: VariableMetric.hxx:213
bool get_use_bounds_scaling() const
returns use_bounds_scaling
Definition: VariableMetric.hxx:412
Header declaring the class ConicBundle::MinorantPointer.
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()
removes the top most aft (without deleting it!)
Definition: VariableMetric.hxx:407
bool employ_variable_metric() const
returns true if some dynamic scaling is supported and switched on
Definition: VariableMetric.hxx:358
virtual VariableMetricModel * variable_metric_transform()
Overload this in order apply transformations in between.
Definition: VariableMetric.hxx:169
points to MinorantUseData that may be shared by many and allows computations with Minorants ...
Definition: MinorantPointer.hxx:34
bool use_bounds_scaling
flag for whether LPGroundset may use its diagonal update heuristic for bounds
Definition: VariableMetric.hxx:319
virtual int add_variable_metric(CH_Matrix_Classes::Symmatrix &)
adds a suitable modification of symH (symH may be modified in this) to the scaling matrix H ...
Definition: VariableMetric.hxx:383
abstract interface providing the bundle data that is typically needed in VariableMetricSelection clas...
Definition: VariableMetric.hxx:183
virtual const CH_Matrix_Classes::Matrix & get_lowrankH() const
allows to retrieve low rank variable metric information stored here
Definition: VariableMetric.hxx:217