ConicBundle
SumModel.hxx
Go to the documentation of this file.
1 
2 
3 #ifndef CONICBUNDLE_SUMMODEL_HXX
4 #define CONICBUNDLE_SUMMODEL_HXX
5 
13 #include <list>
14 #include "SumBlockModel.hxx"
15 #include "AFTModel.hxx"
16 
17 namespace ConicBundle {
22 
23 class SumModelParametersObject;
24 
58 class SumModel: public SumBlockModel
59 {
60 public:
61  //================== models description ====================
80  class ModelData
81  {
82  friend SumModel;
83  private:
94 
97 
100 
103 
106 
109 
111  public:
113  {return oracle_model->sbm_transform();}
115  ~ModelData();
117  ModelData(SumBlockModel* oracle_model);
118 
121  {return model_deviation;}
122 
125  {return model_curvature;}
126 
129  {return deviation_contribution;}
130 
133  {return weighted_curvature;}
134 
137  {return suggested_mode;}
138  };
139 
141  typedef std::map<const FunctionObject*,ModelData*> ModelMap;
142 
143 private:
144  //================== dummy oracle =====================
147 
148  //--- data describing the model
151 
153  ModelMap modelmap;
154 
156  std::list<const ModelData*> local_augmodel;
157 
158  //=================== data of function evaluations ==================
161 
164 
167 
168 
169  //=================== quadratic subproblems ==================
172 
175 
176 
177 public:
179  void clear();
180 
182  SumModel(CBout* cb=0);
183 
185  ~SumModel();
186 
188  const SumBlockModel* model(const FunctionObject* fo) const;
189 
192  {return CH_Matrix_Classes::Integer(modelmap.size());}
193 
196 
199 
200 
201  //----------------------------------------------------------------------
204 
209  const CH_Matrix_Classes::Matrix& y,
210  CH_Matrix_Classes::Real nullstep_bound,
211  CH_Matrix_Classes::Real relprec);
212 
213 
217  const CH_Matrix_Classes::Matrix& y,
218  CH_Matrix_Classes::Real relprec);
219 
220  //eval_augmodel //as in SumBlockModel
221 
222  //reeval_augmodel //as in SumBlockModel
223 
224  //get_model_aggregate(three parameters) //as in SumBlockModel
225 
227  int update_model(ModelUpdate model_update,
228  CH_Matrix_Classes::Integer center_id,
229  const CH_Matrix_Classes::Matrix& center_y,
231  const CH_Matrix_Classes::Matrix& cand_y,
232  CH_Matrix_Classes::Real model_maxviol,
233  BundleProxObject& H);
234 
236  int synchronize_ids(CH_Matrix_Classes::Integer& new_center_ub_fid,
237  CH_Matrix_Classes::Integer new_center_id,
238  CH_Matrix_Classes::Integer old_center_id,
239  CH_Matrix_Classes::Integer& new_cand_ub_fid,
240  CH_Matrix_Classes::Integer new_cand_id,
241  CH_Matrix_Classes::Integer old_cand_id,
242  CH_Matrix_Classes::Integer& new_aggregate_id);
243 
245  bool center_modified(CH_Matrix_Classes::Integer& function_modification_id,
246  CH_Matrix_Classes::Integer center_id);
247 
249  int recompute_center(CH_Matrix_Classes::Integer& new_center_ub_fid,
250  CH_Matrix_Classes::Real& new_center_ub,
251  CH_Matrix_Classes::Integer center_id,
252  const CH_Matrix_Classes::Matrix& y,
253  bool accept_only_higher_values=false,
254  CH_Matrix_Classes::Real relprec=-1.);
255 
257  bool model_aggregate_modified(CH_Matrix_Classes::Integer old_model_aggregate_id);
258 
261  const CH_Matrix_Classes::Matrix& y);
262 
264  int apply_modification(bool& no_changes,
265  const GroundsetModification& gsmdf,
266  const FunObjModMap& funmdfmap,
267  CH_Matrix_Classes::Integer new_center_id,
268  const CH_Matrix_Classes::Matrix& new_center,
269  CH_Matrix_Classes::Integer old_center_id,
270  const CH_Matrix_Classes::Matrix& old_center);
271 
272 
276  const CH_Matrix_Classes::Matrix& y,
277  bool descent_step,
278  CH_Matrix_Classes::Real weightu,
279  CH_Matrix_Classes::Real model_maxviol,
280  const CH_Matrix_Classes::Indexmatrix* indices=0);
281 
283  int check_center_validity_by_candidate(bool& cand_minorant_is_below,
284  CH_Matrix_Classes::Integer center_id,
285  const CH_Matrix_Classes::Matrix& center_y);
286 
288 
289  //----------------------------------------------------------------------
292 
295 
296  // start_augmodel as in SumBlockModel::start_augmode()l
297 
299  int make_model_aggregate(bool& penalty_parameter_increased,
300  bool keep_penalty_fixed);
301 
302  // get_model_aggregate(six parameters) //as in SumBlockModel
303 
306  const CH_Matrix_Classes::Matrix& y);
307 
310  const AffineFunctionTransformation* aft=0);
311 
313  int get_center_minorant(MinorantPointer& minorant,
314  const AffineFunctionTransformation* aft=0);
315 
317  int adjust_multiplier(bool& values_may_have_changed);
318 
321  SumBundleHandler* bh=0,
323 
325  virtual int start_sumaugmodel(QPModelDataPointer& blockp,
327  const CH_Matrix_Classes::Matrix& cand_y,
328  const CH_Matrix_Classes::Indexmatrix* indices=0,
329  SumBundleHandler* bh=0,
332 
333 
335  int update_model(ModelUpdate model_update,
336  CH_Matrix_Classes::Integer center_id,
337  const CH_Matrix_Classes::Matrix& center_y,
339  const CH_Matrix_Classes::Matrix& cand_y,
340  CH_Matrix_Classes::Real null_step_factor,
341  BundleProxObject& H,
344 
346  BundleData* get_data() {return &data;}
347 
349  const BundleData* get_data() const {return &data;}
350 
352  int set_data(BundleData* bd){return data.init(bd);}
353 
355 
356 
357  //----------------------------------------------------------------------
360 
362  const PrimalData* get_approximate_primal() const {return 0;}
363 
365  const PrimalData* get_center_primal() const {return 0;}
366 
368  const PrimalData* get_candidate_primal() const {return 0;}
369 
371  virtual int call_primal_extender(PrimalExtender& /* pext */) {return 1;}
372 
374  int set_bundle_parameters(const BundleParameters& bp);
375 
378 
380  void clear_model(bool discard_minorants_only=false);
381 
383  void clear_aggregates();
384 
385  //get_ret_code() // as in SumBlockModel
386 
388 
389  //----------------------------------------------------------------------
392 
393  //get_QPcoeff_time() // as in SumBlockModel
394 
395  //get_QPsolve_time() // as in SumBlockModel
396 
397  //get_evalaugmodel_time() // as in SumBlockModel
398 
399  //get_evalmodel_time() // as in SumBlockModel
400 
401  //get_updatemodel_time() // as in SumBlockModel
402 
403  //get_eval_time() // as in SumBlockModel
404 
406  void set_out(std::ostream* o=0,int pril=1);
407 
408  //set_cbout() // calls set_out in SumBlockModel
409 
412  {
414  for (ModelMap::const_iterator it=modelmap.begin();it!=modelmap.end();it++){
415  ms+=it->second->model()->get_preeval_time();
416  }
417  return ms;
418  }
421  {
423  for (ModelMap::const_iterator it=modelmap.begin();it!=modelmap.end();it++){
424  ms+=it->second->model()->get_eval_time();
425  }
426  return ms;
427  }
428 
431  {
433  for (ModelMap::const_iterator it=modelmap.begin();it!=modelmap.end();it++){
434  ms+=it->second->model()->get_posteval_time();
435  }
436  return ms;
437  }
438 
439 
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
SumModelParametersObject * model_selection
parameters and routines for choosing the models for SumBundle
Definition: SumModel.hxx:174
SumBlockModel * remove_model(const FunctionObject *fo)
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
const BundleData * get_data() const
see SumBlockModel::get_data()
Definition: SumModel.hxx:349
virtual int init(const BundleData *bd)
initialize from other BundleData
Header declaring the class ConicBundle::SumBlockModel.
int eval_function(CH_Matrix_Classes::Integer &ub_fid, CH_Matrix_Classes::Real &ub, CH_Matrix_Classes::Integer y_id, const CH_Matrix_Classes::Matrix &y, CH_Matrix_Classes::Real nullstep_bound, CH_Matrix_Classes::Real relprec)
see BundleModel::eval_function
BundleData data
the relevant data for running BundleSolver consistently
Definition: SumModel.hxx:150
abstract interface that allows to use different -norms with a positive definite matrix in the proxi...
Definition: BundleProxObject.hxx:88
QPSumModelDataObject * block
collects the blocks of the submodels
Definition: SumModel.hxx:171
SumBlockModel * model() const
returns aft_model if this is not NULL, otherwise oracle_model
Definition: SumModel.hxx:112
abstract interface extending BundleModel so that any such model can be used alone or within SumModel ...
Definition: SumBlockModel.hxx:102
std::list< const ModelData * > local_augmodel
if the sumbundle is active, this collects all models that have a separate augmented model part and ne...
Definition: SumModel.hxx:156
double Real
all real numbers in calculations are of this type
Definition: matop.hxx:50
ModifiableOracleObject * get_oracle_object()
as AFTModel has no oracle of its own, this returns the dummy oracle
Definition: SumModel.hxx:294
CH_Matrix_Classes::Real model_deviation
for judging whether to use a local model or to suggest contribution to summodel, function_value(y)-ag...
Definition: SumModel.hxx:96
For each model added to the sum, there is an object ModelData that stores required information...
Definition: SumModel.hxx:80
ModelMap modelmap
this holds the ModelData indexed by the (unique) FunctionObject pointer
Definition: SumModel.hxx:153
abstract interface for automatically generating and retrieving the qp blocks with the model data that...
Definition: QPModelDataObject.hxx:298
the SumBundle/part is maybe maintained but currently not in use anywhere
Definition: SumBundle.hxx:197
int set_data(BundleData *bd)
see SumBlockModel::set_data()
Definition: SumModel.hxx:352
bool model_aggregate_modified(CH_Matrix_Classes::Integer old_model_aggregate_id)
see BundleModel::model_aggregate_modified
CH_Matrix_Classes::Real weighted_curvature
for judging whether to use a local model or to suggest contribution to summodel, this is changed/upda...
Definition: SumModel.hxx:105
ModifiableOracleObject dummy_oracle
the oracle object of this model
Definition: SumModel.hxx:146
Matrix class for integral values of type Integer
Definition: indexmat.hxx:195
abstract interface for SumModel for the models selection routine when using SumBundle and SumBundleHa...
Definition: SumModelParametersObject.hxx:40
int get_center_minorant(MinorantPointer &minorant, const AffineFunctionTransformation *aft=0)
see SumBlockModel::get_center_minorant()
const PrimalData * get_approximate_primal() const
this has no primals, so it returns 1, see SumBlockModel::get_approximate_primal
Definition: SumModel.hxx:362
int adjust_multiplier(bool &values_may_have_changed)
see SumBlockModel::adjust_multiplier()
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
Header declaring the class ConicBundle::AFTModel.
the latest function evaluation and its subgradient give rise to a descent step, preserving the aggreg...
Definition: BundleModel.hxx:151
CH_Matrix_Classes::Real & set_deviation_contribution()
get and set the accumulated contribution of this function to the total deviation
Definition: SumModel.hxx:128
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)
see BundleModel::start_augmodel() for the first four parameters; for the others see sumbundle_contrib...
virtual CH_Tools::Microseconds get_eval_time() const
see SumBlockModel::get_eval_time()
Definition: SumModel.hxx:420
CH_Matrix_Classes::Integer cand_ub_fid
-1 if not initialized, otherwise the identifier returned by the calls giving the cand_ub_value ...
Definition: SumModel.hxx:91
CH_Matrix_Classes::Integer center_ub_fid
-1 if not initialized, otherwise the identifier returned by the call giving the center_ub_value ...
Definition: SumModel.hxx:89
~SumModel()
calls clear()
int make_model_aggregate(bool &penalty_parameter_increased, bool keep_penalty_fixed)
see SumBlockModel::make_model_aggregate
CH_Matrix_Classes::Real & set_weighted_curvature()
get and set the accumulated curvature information of this function
Definition: SumModel.hxx:132
Mode
specifies for different parts of the sumbundle whether it is active and who is responsible for handli...
Definition: SumBundle.hxx:194
void clear_model(bool discard_minorants_only=false)
see SumBlockModel::clear_model
conic bundle method solver for sum of convex functions. See the ConicBundle_Manual for a quick introd...
Definition: CBSolver.hxx:22
gives a SumBlockModel interface to a sum of (possibly AffineFunctionTransformation transformed) SumBl...
Definition: SumModel.hxx:58
base class for uniform use of WARNINGS and ERRORS (at some point in time)
Definition: CBout.hxx:30
const PrimalData * get_center_primal() const
this has no primals, so it returns 1, see SumBlockModel::get_center_primal
Definition: SumModel.hxx:365
int provide_model_aggregate(CH_Matrix_Classes::Integer y_id, const CH_Matrix_Classes::Matrix &y)
see BundleModel::provide_model_aggregate
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
int get_function_minorant(MinorantPointer &minorant, const AffineFunctionTransformation *aft=0)
see SumBlockModel::get_function_minorant()
void clear_aggregates()
see SumBlockModel::clear_aggregates
std::map< const FunctionObject *, ModelData * > ModelMap
a ModelMap maps FunctionObject pointers (these must be unique) to their ModelData ...
Definition: SumModel.hxx:141
virtual CH_Tools::Microseconds get_posteval_time() const
see SumBlockModel::get_posteval_time()
Definition: SumModel.hxx:430
Serves for specifying parameters regarding the construction of cutting models.
Definition: CBSolver.hxx:891
bool center_modified(CH_Matrix_Classes::Integer &function_modification_id, CH_Matrix_Classes::Integer center_id)
see BundleModel::center_modified
int sumbundle_mode(SumBundle::Mode &mode, SumBundleHandler *bh=0, AffineFunctionTransformation *aft=0)
see SumBlockModel::sumbundle_mode
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
int eval_model(CH_Matrix_Classes::Real &lb, CH_Matrix_Classes::Integer y_id, const CH_Matrix_Classes::Matrix &y, CH_Matrix_Classes::Real relprec)
see BundleModel::eval_model
int set_bundle_parameters(const BundleParameters &bp)
if bp is a SumBundleParametersObject, it is cloned, otherwise the paraemters are copied ...
CH_Matrix_Classes::Integer aggregate_id
-1 if not initialized, otherwise the identifier returned by the last call to get_model_aggregate ...
Definition: SumModel.hxx:93
void set_out(std::ostream *o=0, int pril=1)
set output and outputlevel of warnings and errors recursively, see CBout
void clear()
resets the SumModel to its initial state, in particular it removes but does not delete any Models add...
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 BundleModel::add_dynamic_scaling
MinorantPointer cand_minorant
the minorant in the candidate (if collected explicitly)
Definition: SumModel.hxx:163
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
CH_Matrix_Classes::Integer ncalls
number of (recursive) calls to eval_function or recompute_center
Definition: SumModel.hxx:160
std::map< const FunctionObject *, FunctionObjectModification > FunObjModMap
In order to pass on problem modifications, FunObjModMap allows to specify a FunctionObjectModificatio...
Definition: FunctionObjectModification.hxx:104
routines for updating and handling SumBundle components, possibly by cooperating over several recursi...
Definition: SumBundleHandler.hxx:42
CH_Tools::Microseconds posteval_time
total time spent in eval_function() after the oracle call
Definition: SumBlockModel.hxx:110
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)
see BundleModel::apply_modfication()
CH_Matrix_Classes::Integer function_id
-1 if not initialized, otherwise the maximum of the identifiers returned by the various calls to eval...
Definition: SumModel.hxx:87
virtual CH_Tools::Microseconds get_preeval_time() const
see SumBlockModel::get_preeval_time()
Definition: SumModel.hxx:411
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)
see BundleModel::update_model
basic function object (abstract class). It serves for using the same interface on distinct oracle typ...
Definition: CBSolver.hxx:236
ModelData(SumBlockModel *oracle_model)
sets the oracle_model
SumBundle::Mode & set_suggested_mode()
get and set the sumbundle mode suggested to the model of the function
Definition: SumModel.hxx:136
abstract interface extension of QPModelDataObject for use in SumModel where several blocks are concat...
Definition: QPModelDataObject.hxx:105
In Lagrangean relaxation an approximate primal solution can be generated by supplying primal informat...
Definition: CBSolver.hxx:151
Collects modifications for the unconstrained Groundset for appending, deleting or reassigning variabl...
Definition: GroundsetModification.hxx:32
friend SumModel
SumModel may access any of this directly.
Definition: SumModel.hxx:82
int recompute_center(CH_Matrix_Classes::Integer &new_center_ub_fid, CH_Matrix_Classes::Real &new_center_ub, CH_Matrix_Classes::Integer center_id, const CH_Matrix_Classes::Matrix &y, bool accept_only_higher_values=false, CH_Matrix_Classes::Real relprec=-1.)
see BundleModel::recompute_center
CH_Matrix_Classes::Real model_curvature
for judging whether to use a local model or to suggest contribution to summodel, an estimate of retur...
Definition: SumModel.hxx:102
Interface for extending PrimalData, e.g., in Lagrangian relaxation of column generation approaches...
Definition: CBSolver.hxx:180
MinorantPointer center_minorant
the minorant in the center (if collected explicitly)
Definition: SumModel.hxx:166
CH_Matrix_Classes::Real lb_function(CH_Matrix_Classes::Integer y_id, const CH_Matrix_Classes::Matrix &y)
see SumBlockModel::lb_function()
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
base class for use with SumBlockModel for storing and managing essential data of evaluations and the ...
Definition: BundleData.hxx:77
SumBlockModel * oracle_model
this oracle model is part of the sum, it will NOT be deleted on exit
Definition: SumModel.hxx:85
BundleData * get_data()
see SumBlockModel::get_data()
Definition: SumModel.hxx:346
SumBlockModel * sbm_transform()
like BundleModel::transform() this allows SumBlockModel routines to use a given transformation automa...
int check_center_validity_by_candidate(bool &cand_minorant_is_below, CH_Matrix_Classes::Integer center_id, const CH_Matrix_Classes::Matrix &center_y)
see BundleModel::check_center_validity_by_candidate
CH_Matrix_Classes::Real get_model_curvature() const
get recent estimate of the function&#39;s "curvature" in candidate
Definition: SumModel.hxx:124
points to MinorantUseData that may be shared by many and allows computations with Minorants ...
Definition: MinorantPointer.hxx:34
int add_model(SumBlockModel *model)
adds the model as submodel to this model (if this model may have submodels); if any error occurs the ...
const PrimalData * get_candidate_primal() const
this has no primals, so it returns 1, see SumBlockModel::get_candidate_primal
Definition: SumModel.hxx:368
SumBundle::Mode suggested_mode
suggested mode for this model set by the last call to SumModelSelection::select_model() ...
Definition: SumModel.hxx:108
CH_Matrix_Classes::Real get_model_deviation() const
get recent difference between model and function value in candidate
Definition: SumModel.hxx:120
CH_Matrix_Classes::Integer nsubmodels() const
returns the number of submodels in this model
Definition: SumModel.hxx:191
const BundleParameters * get_bundle_parameters() const
see SumBlockModel::get_bundle_parameters()
virtual int call_primal_extender(PrimalExtender &)
this has no primals, so it returns 1, see SumBlockModel::call_primal_extender
Definition: SumModel.hxx:371
CH_Matrix_Classes::Real deviation_contribution
for judging whether to use a local model or to suggest contribution to summodel, this is changed/upda...
Definition: SumModel.hxx:99