ConicBundle
SumBlockModel.hxx
Go to the documentation of this file.
1 
2 
3 #ifndef CONICBUNDLE_SUMBLOCKMODEL_HXX
4 #define CONICBUNDLE_SUMBLOCKMODEL_HXX
5 
6 
14 #include "clock.hxx"
15 #include "MatrixCBSolver.hxx"
16 #include "BundleModel.hxx"
18 #include "BundleData.hxx"
19 #include "SumBundleHandler.hxx"
20 
21 namespace ConicBundle {
22 
23 
28 
29  class AFTModel;
30 
103 {
104  protected:
112 
113  //--- every SumBlockModel can be equipped with its own affine function transformation
115 
116  //--- every SumBlockModel can be equipped with its own VariableMetricSelection
118 
119  //--- the bundle handler for contributing to a parent sumbundle
124 
125  //--- for testing purposes
128 
129 
130  public:
132  virtual ~SumBlockModel();
133 
135  virtual void clear();
136 
139 
142  { delete vm_selection; vm_selection=vms; return 0;}
143 
146  { return vm_selection;}
147 
161  bool call_aftmodel_first(const FunObjModMap& funmdfmap);
162 
164  SumBlockModel(CBout* cb=0,int cbinc=-1);
165 
168 
170  virtual const SumBlockModel* model(const FunctionObject* /* fo */) const
171  {return 0;}
172 
175  {return 0;}
176 
178  virtual int add_model(SumBlockModel* /* model */)
179  {return 1;}
180 
182  virtual SumBlockModel* remove_model(const FunctionObject* /* fo */)
183  {return 0;}
184 
187  {
188  if (model!=0)
189  return remove_model(dynamic_cast<FunctionObject*>(model->get_oracle_object()));
190  return 0;
191  }
192 
193 
194 
195  //----------------------------------------------------------------------
198 
199  //virtual int eval_function(...)=0; is still abstract
200 
201  //virtual int eval_model(...) =0; is still abstract
202 
204  virtual int start_augmodel(QPModelDataPointer& blockp,
206  const CH_Matrix_Classes::Matrix& cand_y,
207  const CH_Matrix_Classes::Indexmatrix* indices=0);
208 
209 
210  // virtual int start_augmodel(......) =0; is still abstract
211 
212  // virtual int make_model_aggregate(..)=0; is still abstract
213 
215  virtual int get_model_aggregate(CH_Matrix_Classes::Integer& model_aggregate_id,
216  MinorantPointer& model_aggregate);
217 
218  //see BundleModel::update_model() it is still abstract
219  virtual int update_model(ModelUpdate model_update,
220  CH_Matrix_Classes::Integer center_id,
221  const CH_Matrix_Classes::Matrix& center_y,
223  const CH_Matrix_Classes::Matrix& cand_y,
224  CH_Matrix_Classes::Real model_maxviol,
225  BundleProxObject& H) =0;
226 
228  virtual int synchronize_ids(CH_Matrix_Classes::Integer& new_center_ub_fid,
229  CH_Matrix_Classes::Integer new_center_id,
230  CH_Matrix_Classes::Integer old_center_id,
231  CH_Matrix_Classes::Integer& new_cand_ub_fid,
232  CH_Matrix_Classes::Integer new_cand_id,
233  CH_Matrix_Classes::Integer old_cand_id,
234  CH_Matrix_Classes::Integer& new_aggregate_id);
235 
237  virtual bool center_modified(CH_Matrix_Classes::Integer& center_fid,
238  CH_Matrix_Classes::Integer center_id);
239 
240  //virtual bool recompute_center(...) =0; is still abstract
241 
243  virtual bool model_aggregate_modified(CH_Matrix_Classes::Integer old_model_aggregate_id);
244 
245  //virtual int provide_model_aggregate(...) =0; is still abstract
246 
257  virtual int apply_modification(bool& no_changes,
258  const GroundsetModification& gsmdf,
259  const FunObjModMap& funmdfmap,
260  CH_Matrix_Classes::Integer new_center_id,
261  const CH_Matrix_Classes::Matrix& new_center,
262  CH_Matrix_Classes::Integer old_center_id,
263  const CH_Matrix_Classes::Matrix& old_center);
264 
268  const CH_Matrix_Classes::Matrix& y,
269  bool descent_step,
270  CH_Matrix_Classes::Real weightu,
271  CH_Matrix_Classes::Real model_maxviol,
272  const CH_Matrix_Classes::Indexmatrix* indices=0);
273 
274  // virtual int check_center_validity_by_candidate(...)=0; is still abstract
275 
277  int get_function_minorant(CH_Matrix_Classes::Integer& function_modification_id,MinorantPointer& minorant);
278 
280  int get_center_minorant(CH_Matrix_Classes::Integer& function_modification_id,MinorantPointer& minorant);
281 
284 
286 
287  //----------------------------------------------------------------------
290 
293 
294 
295 
329  virtual int get_model_aggregate(CH_Matrix_Classes::Integer& model_aggregate_id,
330  MinorantPointer& model_aggregate,
331  bool all_parts,
332  const AffineFunctionTransformation* aft=0);
333 
337  const CH_Matrix_Classes::Matrix& y);
338 
341  virtual int get_function_minorant(MinorantPointer& function_minorant,
342  const AffineFunctionTransformation* aft=0)=0;
343 
346  virtual int get_center_minorant(MinorantPointer& center_minorant,
347  const AffineFunctionTransformation* aft=0)=0;
348 
349 
350  //-------- messages needed, if online problem modifications are desired
351  // these messages are passed on recursively by SumModel and AFTModel
352 
353 
372  virtual int adjust_multiplier(bool& values_may_have_changed)=0;
373 
374 
444  virtual int sumbundle_mode(SumBundle::Mode& mode,
445  SumBundleHandler* bh=0,
447 
449  virtual int start_sumaugmodel(QPModelDataPointer& blockp,
451  const CH_Matrix_Classes::Matrix& cand_y,
452  const CH_Matrix_Classes::Indexmatrix* indices=0,
453  SumBundleHandler* bh=0,
456 
457 
548  virtual int update_model(ModelUpdate model_update,
549  CH_Matrix_Classes::Integer center_id,
550  const CH_Matrix_Classes::Matrix& center_y,
552  const CH_Matrix_Classes::Matrix& cand_y,
553  CH_Matrix_Classes::Real model_maxviol,
554  BundleProxObject& H,
555  CH_Matrix_Classes::Real& model_deviation,
556  CH_Matrix_Classes::Real& model_curvature)=0;
557 
558 
560 
561  //----------------------------------------------------------------------
564 
567 
569  const AFTModel* get_aftmodel() const {return aftmodel;}
570 
572  virtual BundleData* get_data() =0;
573 
575  virtual const BundleData* get_data() const =0;
576 
578  virtual int set_data(BundleData*) {return 1;}
579 
584  virtual const PrimalData* get_approximate_primal() const
585  {return get_data()->get_approximate_primal();}
586 
592  virtual const PrimalData* get_center_primal() const
593  {return get_data()->get_center_primal();}
594 
600  virtual const PrimalData* get_candidate_primal() const
601  {return get_data()->get_candidate_primal();}
602 
612  {return get_data()->call_primal_extender(pext);}
613 
619  {return 1;}
620 
625  {return 0;}
626 
632  virtual int set_sumbundle_parameters(const BundleParameters& );
633 
638  {return sumbundle_parameters;}
639 
642  virtual void clear_model(bool discard_minorants_only=false)
643  {get_data()->clear_model(discard_minorants_only);}
644 
646  virtual void clear_aggregates()
647  {get_data()->clear_aggregates();}
648 
653  virtual int get_ret_code() const
654  {return 0;}
655 
656 
658 
659  //----------------------------------------------------------------------
662 
675 
677  std::ostream& print_statistics(std::ostream& out) const;
678 
680  void set_out(std::ostream* o=0,int pril=1)
681  {
682  CBout::set_out(o,pril);
683  get_data()->set_cbout(this);
684  if (vm_selection)
685  vm_selection->set_cbout(this,0);
686  }
687 
689  void set_cbout(const CBout* cb,int incr)
690  {
691  set_out(cb->get_out_ptr(),cb->get_print_level()+incr);
692  }
693 
695 };
696 
698 
699 }
700 
701 #endif
702 
int Integer
all integer numbers in calculations and indexing are of this type
Definition: matop.hxx:40
virtual const PrimalData * get_candidate_primal() const
return the PrimalData delivered by the last call of FunctionOracle::evaluate()
Definition: BundleData.hxx:264
virtual CH_Tools::Microseconds get_preeval_time() const
return time spent in total for the oracle in eval_function()
Definition: SumBlockModel.hxx:668
MinorantPointer old_model_aggregate
for testing purposes
Definition: SumBlockModel.hxx:127
virtual int set_bundle_parameters(const BundleParameters &)
set max_bundle_size and max_model_size (this may differ if the parameter is a recognized derived clas...
Definition: SumBlockModel.hxx:618
abstract interface that allows to use different -norms with a positive definite matrix in the proxi...
Definition: BundleProxObject.hxx:88
bool call_aftmodel_first(const FunObjModMap &funmdfmap)
in apply_modification this routine is needed to check whether the aftmodel is modified already ...
std::ostream & print_statistics(std::ostream &out) const
output the timing statistics
abstract interface extending BundleModel so that any such model can be used alone or within SumModel ...
Definition: SumBlockModel.hxx:102
virtual int apply_modification(bool &no_changes, const GroundsetModification &gsmdf, const FunObjModMap &funmdfmap, CH_Matrix_Classes::Integer new_center_id, const CH_Matrix_Classes::Matrix &new_center, CH_Matrix_Classes::Integer old_center_id, const CH_Matrix_Classes::Matrix &old_center)
passes on modification information about function and ground set changes
CH_Tools::Microseconds eval_time
total time spent in the oracle in eval_function() or calls to eval_function of children ...
Definition: SumBlockModel.hxx:108
double Real
all real numbers in calculations are of this type
Definition: matop.hxx:50
virtual CH_Matrix_Classes::Real lb_function(CH_Matrix_Classes::Integer y_id, const CH_Matrix_Classes::Matrix &y)
returns a quick lower bound for the function value at y (eg by a previous subgradient) ...
const AFTModel * get_aftmodel() const
returns aftmodel (as a const variant)
Definition: SumBlockModel.hxx:569
virtual const PrimalData * get_approximate_primal() const
return the PrimalData corresponding to the aggregate
Definition: BundleData.hxx:258
abstract interface for automatically generating and retrieving the qp blocks with the model data that...
Definition: QPModelDataObject.hxx:298
virtual ModifiableOracleObject * get_oracle_object()=0
return the function oracle this provides a model for, or some dummy oracle
SumBlockModel(CBout *cb=0, int cbinc=-1)
calls clear
the SumBundle/part is maybe maintained but currently not in use anywhere
Definition: SumBundle.hxx:197
Header declaring the class ConicBundle::SumBundleHandler (see ConicBundle::SumBlockModel) ...
virtual void clear_aggregates()
remove all current aggregate cutting planes, but not the other parts of the model; returns 0 on succe...
Definition: SumBlockModel.hxx:646
virtual const SumBlockModel * model(const FunctionObject *) const
returns the submodel for FunctionObject fo if it in this model, otherwise 0
Definition: SumBlockModel.hxx:170
virtual int update_model(ModelUpdate model_update, CH_Matrix_Classes::Integer center_id, const CH_Matrix_Classes::Matrix &center_y, CH_Matrix_Classes::Integer cand_id, const CH_Matrix_Classes::Matrix &cand_y, CH_Matrix_Classes::Real model_maxviol, BundleProxObject &H)=0
generate the next cutting model and store the center information in the case of a descent step ...
virtual void clear()
resets all data to the initial status of this class, also aftmodel and vm_selection are deleted ...
Matrix class for integral values of type Integer
Definition: indexmat.hxx:195
int get_function_minorant(CH_Matrix_Classes::Integer &function_modification_id, MinorantPointer &minorant)
see BundleModel::get_function_minorant()
virtual CH_Matrix_Classes::Integer nsubmodels() const
returns the number of submodels in this model (direct ones, not all descendants; most have none...
Definition: SumBlockModel.hxx:174
the latest function evaluation and its subgradient give rise to a descent step, preserving the aggreg...
Definition: BundleModel.hxx:151
virtual int set_variable_metric_selection(VariableMetricSelection *vms=0)
delete old selector and set a new one (0 is allowed resulting in no local selector) ...
Definition: SumBlockModel.hxx:141
CH_Tools::Microseconds metric_time
total time spent in add_variable_metric()
Definition: SumBlockModel.hxx:111
abstract interface for SumBundleHandler for the model selection and variable metric seletcion routine...
Definition: SumBundleParametersObject.hxx:50
allows measuring time difference to its initialization time in Microseconds
Definition: clock.hxx:282
Mode
specifies for different parts of the sumbundle whether it is active and who is responsible for handli...
Definition: SumBundle.hxx:194
virtual void clear_aggregates()
delete all kinds of aggregates but keep explicit parts of the cutting model
virtual SumBlockModel * remove_model(const FunctionObject *)
remove the submodel identified by fo from this model, this does NOT destruct the model. It returns the pointer to the model if there is one, otherwise 0
Definition: SumBlockModel.hxx:182
conic bundle method solver for sum of convex functions. See the ConicBundle_Manual for a quick introd...
Definition: CBSolver.hxx:22
virtual ~SumBlockModel()
destructor
CH_Tools::Microseconds get_updatemodel_time() const
return time spent in total for updating the model in update_model()
Definition: SumBlockModel.hxx:666
base class for uniform use of WARNINGS and ERRORS (at some point in time)
Definition: CBout.hxx:30
extra long integer number for expressing and computing time measurements in microseconds.
Definition: clock.hxx:46
ModelUpdate
for informing update_model() at what stage it is called to update the bundle so that the amount of in...
Definition: BundleModel.hxx:149
virtual int set_data(BundleData *)
reinstalls the bundle date from get_data() for continuing from this previous point, see BundleData
Definition: SumBlockModel.hxx:578
virtual const PrimalData * get_center_primal() const
if primal data is provided by the oracle then the primal corresponding to the best eps-subgradient of...
Definition: SumBlockModel.hxx:592
virtual int synchronize_ids(CH_Matrix_Classes::Integer &new_center_ub_fid, CH_Matrix_Classes::Integer new_center_id, CH_Matrix_Classes::Integer old_center_id, CH_Matrix_Classes::Integer &new_cand_ub_fid, CH_Matrix_Classes::Integer new_cand_id, CH_Matrix_Classes::Integer old_cand_id, CH_Matrix_Classes::Integer &new_aggregate_id)
see BundleModel::synchronize_ids
SumBundleHandler * bundlehandler
if the sumbundle is used, this points to the handler that operates it
Definition: SumBlockModel.hxx:121
virtual SumBlockModel * remove_model(SumBlockModel *model)
remove the submodel identified by the given models FunctionObject from this model, this does NOT destruct the model. It returns the pointer to the model if there is one, otherwise 0
Definition: SumBlockModel.hxx:186
virtual int adjust_multiplier(bool &values_may_have_changed)=0
for conic subproblems with adjustable multipliers, reset the multiplier to twice the current trace an...
virtual int get_model_aggregate(CH_Matrix_Classes::Integer &model_aggregate_id, MinorantPointer &model_aggregate)
see BundleModel::get_model_aggregate
Serves for specifying parameters regarding the construction of cutting models.
Definition: CBSolver.hxx:891
CH_Tools::Clock clock
for collecting time statistics
Definition: SumBlockModel.hxx:105
virtual const BundleParameters * get_bundle_parameters() const
returns the current parameter settings; model blocks without bundle parameters return NULL...
Definition: SumBlockModel.hxx:624
virtual void clear_model(bool discard_minorants_only=false)
modifications of this specific problem were such that old subgradient data and function values have t...
Definition: SumBlockModel.hxx:642
mimicks the model of a function with an AffineFunctionTransformation (AFT) applied to it...
Definition: AFTModel.hxx:50
virtual int get_ret_code() const
for functions given by an oracle: return the return value that was produced by the last call to the f...
Definition: SumBlockModel.hxx:653
CH_Tools::Microseconds preeval_time
total time spent in eval_function() before the oracle call
Definition: SumBlockModel.hxx:109
interface class that allows a VariableMetricModel to contribute information to a VariableMetric objec...
Definition: VariableMetric.hxx:309
virtual CH_Tools::Microseconds get_eval_time() const
return time spent in total for the oracle in eval_function()
Definition: SumBlockModel.hxx:670
virtual void set_out(std::ostream *out=0, int print_level=1)
Specifies the output level (out==NULL: no output at all, out!=NULL and level=0: errors and warnings...
void set_out(std::ostream *o=0, int pril=1)
set output and outputlevel of warnings and errors recursively, see CBout
Definition: SumBlockModel.hxx:680
virtual int call_primal_extender(PrimalExtender &, bool include_candidates=true)
see the last argument of FunctionOracle::evaluate()
virtual const PrimalData * get_approximate_primal() const
if primal data is provided by the oracle then the primal corresponding to the current aggregate is fo...
Definition: SumBlockModel.hxx:584
virtual CH_Tools::Microseconds get_posteval_time() const
return time spent in total for the oracle in eval_function()
Definition: SumBlockModel.hxx:672
virtual bool model_aggregate_modified(CH_Matrix_Classes::Integer old_model_aggregate_id)
see BundleModel::model_aggregate_modified
SumBundleParametersObject * sumbundle_parameters
this holds the default settings whether and how to start or contribute to a SumBundle ...
Definition: SumBlockModel.hxx:123
Header declaring the class ConicBundle::BundleData (see ConicBundle::SumBlockModel) ...
int get_center_minorant(CH_Matrix_Classes::Integer &function_modification_id, MinorantPointer &minorant)
see BundleModel::get_center_minorant()
ModifiableOracle provides all oracles with a uniform interface for a modification routine and an on/o...
Definition: MatrixCBSolver.hxx:309
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
virtual int start_sumaugmodel(QPModelDataPointer &blockp, CH_Matrix_Classes::Integer cand_id, const CH_Matrix_Classes::Matrix &cand_y, const CH_Matrix_Classes::Indexmatrix *indices=0, SumBundleHandler *bh=0, SumBundle::Mode mode=SumBundle::inactive, AffineFunctionTransformation *aft=0)=0
see BundleModel::start_augmodel() for the first four parameters; for the others see sumbundle_mode() ...
std::map< const FunctionObject *, FunctionObjectModification > FunObjModMap
In order to pass on problem modifications, FunObjModMap allows to specify a FunctionObjectModificatio...
Definition: FunctionObjectModification.hxx:104
std::ostream * out
not output at all if out==0, otherwise use this output stream
Definition: CBout.hxx:33
virtual int call_primal_extender(PrimalExtender &pext)
if the function is the Lagrangian dual and primal_data of previous calls has now to be updated due to...
Definition: SumBlockModel.hxx:611
routines for updating and handling SumBundle components, possibly by cooperating over several recursi...
Definition: SumBundleHandler.hxx:42
abstract interface for BundleSolver giving access to all objective function specific bundle routines ...
Definition: BundleModel.hxx:140
VariableMetricSelection * vm_selection
if not NULL this points to the selection routine for computing the local contribution to the metric ...
Definition: SumBlockModel.hxx:117
CH_Tools::Microseconds posteval_time
total time spent in eval_function() after the oracle call
Definition: SumBlockModel.hxx:110
virtual bool center_modified(CH_Matrix_Classes::Integer &center_fid, CH_Matrix_Classes::Integer center_id)
see BundleModel::center_modified
CH_Tools::Microseconds get_metric_time() const
return time spent in total for the add_variable_metric routine
Definition: SumBlockModel.hxx:674
int get_print_level() const
returns the print_level
Definition: CBout.hxx:93
virtual VariableMetricSelection * get_variable_metric_selection() const
delete old selector and set a new one (0 is allowed resulting in no local selector) ...
Definition: SumBlockModel.hxx:145
Header declaring the classes ConicBundle::MatrixCBSolver, ConicBundle::MatrixFunctionOracle, ConicBundle::PrimalMatrix, ConicBundle::MatrixMinorant, ConicBundle::ModifiableOracleObject.
CH_Tools::Microseconds evalmodel_time
total time spent in evaluating the model in eval_model()
Definition: SumBlockModel.hxx:106
basic function object (abstract class). It serves for using the same interface on distinct oracle typ...
Definition: CBSolver.hxx:236
virtual BundleData * get_data()=0
returns the essential information on the bundle date for continuing from the same point lateron...
In Lagrangean relaxation an approximate primal solution can be generated by supplying primal informat...
Definition: CBSolver.hxx:151
virtual int start_augmodel(QPModelDataPointer &blockp, CH_Matrix_Classes::Integer cand_id, const CH_Matrix_Classes::Matrix &cand_y, const CH_Matrix_Classes::Indexmatrix *indices=0)
see BundleModel::start_augmodel, here it just moves on to start_sumaugmodel
Collects modifications for the unconstrained Groundset for appending, deleting or reassigning variabl...
Definition: GroundsetModification.hxx:32
std::ostream * get_out_ptr() const
returns the pointer to the output stream
Definition: CBout.hxx:88
Header declaring and (inline) implementing the classes CH_Tools::Microseconds and CH_Tools::Clock as ...
virtual void clear_model(bool discard_minorants_only=false)
clear the cutting model and all function evaluations; for special cutting models of support functions...
Interface for extending PrimalData, e.g., in Lagrangian relaxation of column generation approaches...
Definition: CBSolver.hxx:180
virtual const PrimalData * get_center_primal() const
return the PrimalData corresponding to the aggregate
Definition: BundleData.hxx:261
CH_Tools::Microseconds get_evalmodel_time() const
return time spent in total for evaluating the model in eval_model()
Definition: SumBlockModel.hxx:664
virtual int set_sumbundle_parameters(const BundleParameters &)
set max_bundle_size and max_model_size (this may differ if the parameter is a derived class...
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
int initialize_aft(AffineFunctionTransformation *aft=0)
first it discards an old affine function transformation if there is one, then it sets the new one...
base class for use with SumBlockModel for storing and managing essential data of evaluations and the ...
Definition: BundleData.hxx:77
BundleModel * transform()
if an affine function transformation is defined for this model, return it, otherwise use this ...
SumBlockModel * sbm_transform()
like BundleModel::transform() this allows SumBlockModel routines to use a given transformation automa...
virtual int add_model(SumBlockModel *)
adds the model as submodel to this model (if this model may have submodels)
Definition: SumBlockModel.hxx:178
AFTModel * aftmodel
if not NULL this points to an AFTModel describing an AffineFunctionTransformation ...
Definition: SumBlockModel.hxx:114
virtual int sumbundle_mode(SumBundle::Mode &mode, SumBundleHandler *bh=0, AffineFunctionTransformation *aft=0)=0
called by start_sumaugmodel in order to suggest (or to force) *this to opt in or out of a common SumB...
CH_Tools::Microseconds updatemodel_time
total time spent in updating the bundle in update_model()
Definition: SumBlockModel.hxx:107
points to MinorantUseData that may be shared by many and allows computations with Minorants ...
Definition: MinorantPointer.hxx:34
Header declaring the class ConicBundle::BundleModel.
AFTModel * get_aftmodel()
returns aftmodel
Definition: SumBlockModel.hxx:566
void set_cbout(const CBout *cb, int incr)
set output and outputlevel of warnings and errors recursively with CBout
Definition: SumBlockModel.hxx:689
virtual const SumBundleParametersObject * get_sumbundle_parameters() const
returns the current parameter settings; model blocks without bundle parameters return NULL...
Definition: SumBlockModel.hxx:637
virtual void set_cbout(const CBout *cb, int incr=-1)
Specifies the output level relative to the given CBout class.
virtual const PrimalData * get_candidate_primal() const
if primal data is provided by the oracle then the primal corresponding to the best eps-subgradient of...
Definition: SumBlockModel.hxx:600
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)
see VariableMetricModel::add_variable_metric; this implements the non local option ...
Header declaring the classes ConicBundle::AffineFunctionTransformation.