ConicBundle
AFTModel.hxx
Go to the documentation of this file.
1 
2 
3 #ifndef CONICBUNDLE_AFTMODEL_HXX
4 #define CONICBUNDLE_AFTMODEL_HXX
5 
14 #include "SumBlockModel.hxx"
15 #include "AFTData.hxx"
17 
18 namespace ConicBundle {
19 
23 
50 class AFTModel: public SumBlockModel
51 {
52 private:
53  //================== dummy oracle =====================
60 
61  //=================== data of the AFT ==================
66 
67  //=================== data of function evaluations ==================
70 
71  //--- lazy evaluation of the the candidate subgradient
74 
77 
78 
79  //=================== quadratic subproblems ==================
82 
84  std::map<MinorantPointer,MinorantPointer> precomputed;
90 
91 
92  //=================== private functions ======================
93 
96  { return model_is_owner? model: model->sbm_transform();}
99  { return model_is_owner? model: model->sbm_transform();}
100 
101 
121  const CH_Matrix_Classes::Matrix& cand_y
122  );
123 
135 
136 
138  int compute_qp_data(const CH_Matrix_Classes::Indexmatrix* indices=0) const;
139 
140 
141 public:
144  CH_Matrix_Classes::Integer start_modification_id=0);
145 
147  virtual void clear(){clear(0);}
148 
150  AFTModel(SumBlockModel* in_model,
152  CH_Matrix_Classes::Integer start_modification_id=0,
153  bool in_model_is_owner=false,
154  CBout* cb=0);
156  ~AFTModel();
157 
159  const AffineFunctionTransformation* get_aft() const {return aft;}
160 
161  //----------------------------------------------------------------------
164 
169  const CH_Matrix_Classes::Matrix& y,
170  CH_Matrix_Classes::Real nullstep_bound,
171  CH_Matrix_Classes::Real relprec);
172 
173 
177  const CH_Matrix_Classes::Matrix& y,
178  CH_Matrix_Classes::Real relprec);
179 
180  //eval_augmodel //as in SumBlockModel
181 
182  //reeval_augmodel //as in SumBlockModel
183 
184  //get_model_aggregate(three parameters) //as in SumBlockModel
185 
187  int update_model(ModelUpdate model_update,
188  CH_Matrix_Classes::Integer center_id,
189  const CH_Matrix_Classes::Matrix& center_y,
191  const CH_Matrix_Classes::Matrix& cand_y,
192  CH_Matrix_Classes::Real model_maxviol,
193  BundleProxObject& H);
194 
196  int synchronize_ids(CH_Matrix_Classes::Integer& new_center_ub_fid,
197  CH_Matrix_Classes::Integer new_center_id,
198  CH_Matrix_Classes::Integer old_center_id,
199  CH_Matrix_Classes::Integer& new_cand_ub_fid,
200  CH_Matrix_Classes::Integer new_cand_id,
201  CH_Matrix_Classes::Integer old_cand_id,
202  CH_Matrix_Classes::Integer& new_aggregate_id);
203 
206 
208  int recompute_center(CH_Matrix_Classes::Integer& new_center_ub_fid,
209  CH_Matrix_Classes::Real& new_center_ub,
210  CH_Matrix_Classes::Integer center_id,
211  const CH_Matrix_Classes::Matrix& y,
212  bool accept_only_higher_values=false,
213  CH_Matrix_Classes::Real relprec=-1.);
214 
216  bool model_aggregate_modified(CH_Matrix_Classes::Integer old_model_aggregate_id);
217 
220  const CH_Matrix_Classes::Matrix& y);
221 
223  int apply_modification(bool& no_changes,
224  const GroundsetModification& gsmdf,
225  const FunObjModMap& funmdfmap,
226  CH_Matrix_Classes::Integer new_center_id,
227  const CH_Matrix_Classes::Matrix& new_center,
228  CH_Matrix_Classes::Integer old_center_id,
229  const CH_Matrix_Classes::Matrix& old_center);
230 
233  CH_Matrix_Classes::Integer center_id,
234  const CH_Matrix_Classes::Matrix& y,
235  bool descent_step,
236  CH_Matrix_Classes::Real weightu,
237  CH_Matrix_Classes::Real model_maxviol,
238  const CH_Matrix_Classes::Indexmatrix* indices=0);
239 
241  int check_center_validity_by_candidate(bool& cand_minorant_is_below,
242  CH_Matrix_Classes::Integer center_id,
243  const CH_Matrix_Classes::Matrix& center_y);
244 
246 
247  //----------------------------------------------------------------------
250 
253 
254  // start_augmodel as in SumBlockModel::start_augmodel
255 
257  int make_model_aggregate(bool& penalty_parameter_increased,
258  bool keep_penalty_fixed);
259 
261  int get_model_aggregate(CH_Matrix_Classes::Integer& model_aggregate_id,
262  MinorantPointer& model_aggregate,
263  bool all_parts=true,
264  const AffineFunctionTransformation* aft=0);
265 
268  const CH_Matrix_Classes::Matrix& y);
269 
272  const AffineFunctionTransformation* aft=0);
273 
275  int get_center_minorant(MinorantPointer& minorant,
276  const AffineFunctionTransformation* aft=0);
277 
279  int adjust_multiplier(bool& values_may_have_changed);
280 
283  SumBundleHandler* bh=0,
285 
286 
288  virtual int start_sumaugmodel(QPModelDataPointer& blockp,
290  const CH_Matrix_Classes::Matrix& cand_y,
291  const CH_Matrix_Classes::Indexmatrix* indices=0,
292  SumBundleHandler* bh=0,
295 
296 
298  virtual int update_model(ModelUpdate model_update,
299  CH_Matrix_Classes::Integer center_id,
300  const CH_Matrix_Classes::Matrix& center_y,
302  const CH_Matrix_Classes::Matrix& cand_y,
303  CH_Matrix_Classes::Real model_maxviol,
304  BundleProxObject& H,
305  CH_Matrix_Classes::Real& model_deviation,
306  CH_Matrix_Classes::Real& model_curvature);
307 
308 
310  BundleData* get_data() {return &data;}
311 
313  const BundleData* get_data() const {return &data;}
314 
316  int set_data(BundleData* bd){return data.init(bd);}
317 
319 
320  //----------------------------------------------------------------------
323 
325  const PrimalData* get_approximate_primal() const {return 0;}
326 
328  const PrimalData* get_center_primal() const {return 0;}
329 
330 
332  const PrimalData* get_candidate_primal() const {return 0;}
333 
335  virtual int call_primal_extender(PrimalExtender& /* pext */) {return 1;}
336 
338  int set_bundle_parameters(const BundleParameters& /* bp */) {return 1;}
339 
342 
344  void clear_model(bool discard_minorants_only=false);
345 
347  void clear_aggregates();
348 
349  //get_ret_code() // as in SumBlockModel
350 
352 
353  //----------------------------------------------------------------------
356 
358  std::ostream& output_bundle_data(std::ostream& out) const;
359 
361  //----------------------------------------------------------------------
364 
365  //get_QPcoeff_time() // as in SumBlockModel
366 
367  //get_QPsolve_time() // as in SumBlockModel
368 
369  //get_evalaugmodel_time() // as in SumBlockModel
370 
371  //get_evalmodel_time() // as in SumBlockModel
372 
373  //get_updatemodel_time() // as in SumBlockModel
374 
377  {
379  if (model) ms+= model->get_preeval_time();
380  return ms;
381  }
384  {
386  if (model) ms= model->get_eval_time();
387  return ms;
388  }
389 
392  {
394  if (model) ms+= model->get_posteval_time();
395  return ms;
396  }
397 
399  void set_out(std::ostream* o=0,int pril=1)
400  {
401  SumBlockModel::set_out(o,pril);
402  if (model)
403  model->set_cbout(this,0);
404  aft->set_cbout(this,0);
405  if (block)
406  block->set_cbout(this,-1);
407  }
408 
409  //set_cbout() // calls set_out in SumBlockModel
410 
411 
413 
414 };
415 
417 
418 }
419 
420 #endif
421 
const CH_Matrix_Classes::Matrix & generate_aft_cand(CH_Matrix_Classes::Integer cand_id, const CH_Matrix_Classes::Matrix &cand_y)
computes and returns a reference to the transformed point (maybe the input point itself, if identity) and assigns a new aftpoint_id if necessary
int Integer
all integer numbers in calculations and indexing are of this type
Definition: matop.hxx:40
virtual CH_Tools::Microseconds get_preeval_time() const
return time spent in total for the oracle in eval_function()
Definition: SumBlockModel.hxx:668
Header declaring the class ConicBundle::SumBlockModel.
abstract interface that allows to use different -norms with a positive definite matrix in the proxi...
Definition: BundleProxObject.hxx:88
int check_function_id_change(CH_Matrix_Classes::Integer function_id)
if a call to some function evaluation returned an increased function_id, this increases data...
ModifiableOracleObject * get_oracle_object()
as AFTModel has no oracle of its own, this returns the dummy oracle
Definition: AFTModel.hxx:252
abstract interface extending BundleModel so that any such model can be used alone or within SumModel ...
Definition: SumBlockModel.hxx:102
virtual int call_primal_extender(PrimalExtender &)
an AFT has no primals, so it returns 1, see SumBlockModel::call_primal_extender
Definition: AFTModel.hxx:335
int sumbundle_mode(SumBundle::Mode &mode, SumBundleHandler *bh=0, AffineFunctionTransformation *aft=0)
see SumBlockModel::sumbundle_mode
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
void set_out(std::ostream *o=0, int pril=1)
set output and outputlevel of warnings and errors recursively, see CBout
Definition: AFTModel.hxx:399
double Real
all real numbers in calculations are of this type
Definition: matop.hxx:50
QPConeModelDataObject * block
usually not used, but if aft->get_fun_coeff()==0 an empty block may have to be returned ...
Definition: AFTModel.hxx:81
CH_Matrix_Classes::Integer ncalls
number of calls to model->eval_function or model->recompute_center
Definition: AFTModel.hxx:69
abstract interface for automatically generating and retrieving the qp blocks with the model data that...
Definition: QPModelDataObject.hxx:298
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,const CH_Matrix_Classes::Matrix&,CH_Matrix_Classes::Integer,const CH_Matrix_Classes::Matrix&,const FunObjModMap&,const GroundsetModification&)
the SumBundle/part is maybe maintained but currently not in use anywhere
Definition: SumBundle.hxx:197
CH_Matrix_Classes::Indexmatrix qp_indices
if its dimension is >0 it gives the (ordered) subset of indices for which subgradient entries are nee...
Definition: AFTModel.hxx:87
Matrix class for integral values of type Integer
Definition: indexmat.hxx:195
AFTData data
the relevant data for running BundleSolver consistently
Definition: AFTModel.hxx:65
int compute_qp_data(const CH_Matrix_Classes::Indexmatrix *indices=0) const
checks whether it is necessary to precompute the qp_data and does so if required
std::ostream & output_bundle_data(std::ostream &out) const
this outputs the qp model data recursively for testing purposes
CH_Matrix_Classes::Real lb_function(CH_Matrix_Classes::Integer y_id, const CH_Matrix_Classes::Matrix &y)
see SumBlockModel::lb_function
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
const PrimalData * get_approximate_primal() const
an AFT has no primals, so it returns 1, see SumBlockModel::get_approximate_primal ...
Definition: AFTModel.hxx:325
abstract interface extension of QPModelDataObject to allow uniform generation of tuned quadratic solv...
Definition: QPModelDataObject.hxx:144
the latest function evaluation and its subgradient give rise to a descent step, preserving the aggreg...
Definition: BundleModel.hxx:151
virtual void clear()
overloads the SumBlockModel::clear calling the other clear with parameter 0
Definition: AFTModel.hxx:147
Header declaring the class ConicBundle::AFTData (needed for ConicBundle::ConvexProblem) ...
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
int provide_model_aggregate(CH_Matrix_Classes::Integer y_id, const CH_Matrix_Classes::Matrix &y)
see BundleModel::provide_model_aggregate
Mode
specifies for different parts of the sumbundle whether it is active and who is responsible for handli...
Definition: SumBundle.hxx:194
SumBlockModel * cond_model_trafo()
returns model if model_is_owner, and model->sbm_transform() otherwise
Definition: AFTModel.hxx:95
conic bundle method solver for sum of convex functions. See the ConicBundle_Manual for a quick introd...
Definition: CBSolver.hxx:22
int add_variable_metric(VariableMetric &H, CH_Matrix_Classes::Integer center_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 DynamicScaling
BundleParameters * get_bundle_parameters() const
an AFT has no bundle, so it returns 1, see SumBlockModel::get_bundle_parameters
Definition: AFTModel.hxx:341
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
bool model_is_owner
the following is true if the model above is the owner of this AFTModel
Definition: AFTModel.hxx:57
AFTModel(SumBlockModel *in_model, AffineFunctionTransformation *inaft=0, CH_Matrix_Classes::Integer start_modification_id=0, bool in_model_is_owner=false, CBout *cb=0)
sets model to in_model and model_is_owner to in_model_is_owner (or false if in_model==0) and calls cl...
ModifiableOracleObject dummy_oracle
the oracle object of this model
Definition: AFTModel.hxx:59
int set_data(BundleData *bd)
see SumBlockModel::set_data
Definition: AFTModel.hxx:316
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 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
int make_model_aggregate(bool &penalty_parameter_increased, bool keep_penalty_fixed)
see SumBlockModel::make_model_aggregate
Serves for specifying parameters regarding the construction of cutting models.
Definition: CBSolver.hxx:891
SumBlockModel * model
points to the model which this AFT works on
Definition: AFTModel.hxx:55
bool center_modified(CH_Matrix_Classes::Integer &center_ub_fid, CH_Matrix_Classes::Integer center_id)
see BundleModel::center_modified
virtual CH_Tools::Microseconds get_posteval_time() const
see SumBlockModel::get_posteval_time()
Definition: AFTModel.hxx:391
mimicks the model of a function with an AffineFunctionTransformation (AFT) applied to it...
Definition: AFTModel.hxx:50
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 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...
const BundleData * get_data() const
see SumBlockModel::get_data
Definition: AFTModel.hxx:313
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 CH_Tools::Microseconds get_posteval_time() const
return time spent in total for the oracle in eval_function()
Definition: SumBlockModel.hxx:672
virtual CH_Tools::Microseconds get_preeval_time() const
see SumBlockModel::get_preeval_time()
Definition: AFTModel.hxx:376
MinorantPointer cand_minorant
the (lazy) transformed minorant in the candidate
Definition: AFTModel.hxx:73
int adjust_multiplier(bool &values_may_have_changed)
see SumBlockModel::adjust_multiplier
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
const SumBlockModel * cond_model_trafo() const
const version of cond_model_trafo
Definition: AFTModel.hxx:98
CH_Matrix_Classes::Indexmatrix old_indices
for checking whether the old results can be reused
Definition: AFTModel.hxx:89
int set_bundle_parameters(const BundleParameters &)
an AFT has no bundle, so it returns 1, see SumBlockModel::set_bundle_parameters
Definition: AFTModel.hxx:338
AffineFunctionTransformation * aft
the affine function transformation in use, must always be != NULL
Definition: AFTModel.hxx:63
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
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
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 get_center_minorant(MinorantPointer &minorant, const AffineFunctionTransformation *aft=0)
see SumBlockModel::get_center_minorant
MinorantPointer center_minorant
the (lazy) transformed minorant in the center
Definition: AFTModel.hxx:76
~AFTModel()
delets aft
const PrimalData * get_center_primal() const
an AFT has no primals, so it returns 1, see SumBlockModel::get_center_primal
Definition: AFTModel.hxx:328
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
void clear_aggregates()
see SumBlockModel::clear_aggregates
BundleData * get_data()
see SumBlockModel::get_data
Definition: AFTModel.hxx:310
void clear_model(bool discard_minorants_only=false)
see SumBlockModel::clear_model
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
bool model_aggregate_modified(CH_Matrix_Classes::Integer old_model_aggregate_id)
see BundleModel::model_aggregate_modified
Interface for extending PrimalData, e.g., in Lagrangian relaxation of column generation approaches...
Definition: CBSolver.hxx:180
const PrimalData * get_candidate_primal() const
an AFT has no primals, so it returns 1, see SumBlockModel::get_candidate_primal
Definition: AFTModel.hxx:332
virtual CH_Tools::Microseconds get_eval_time() const
see SumBlockModel::get_eval_time()
Definition: AFTModel.hxx:383
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 get_function_minorant(MinorantPointer &minorant, const AffineFunctionTransformation *aft=0)
see SumBlockModel::get_function_minorant
base class for use with SumBlockModel for storing and managing essential data of evaluations and the ...
Definition: BundleData.hxx:77
virtual int init(const BundleData *bd)
initialize from other BundleData
SumBlockModel * sbm_transform()
like BundleModel::transform() this allows SumBlockModel routines to use a given transformation automa...
specialized BundleData class for use with AFTModel for storing and managing essential data of evaluat...
Definition: AFTData.hxx:58
const AffineFunctionTransformation * get_aft() const
allows to inspect the current AffineFunctionTransformation
Definition: AFTModel.hxx:159
points to MinorantUseData that may be shared by many and allows computations with Minorants ...
Definition: MinorantPointer.hxx:34
void set_cbout(const CBout *cb, int incr)
set output and outputlevel of warnings and errors recursively with CBout
Definition: SumBlockModel.hxx:689
std::map< MinorantPointer, MinorantPointer > precomputed
if a MinorantPointer has already been transformed, this is stored here
Definition: AFTModel.hxx:84
virtual void set_cbout(const CBout *cb, int incr=-1)
Specifies the output level relative to the given CBout class.
int get_model_aggregate(CH_Matrix_Classes::Integer &model_aggregate_id, MinorantPointer &model_aggregate, bool all_parts=true, const AffineFunctionTransformation *aft=0)
see SumBlockModle::get_modle_aggregate(CH_Matrix_Classes::Integer&,CH_Matrix_Classes::Real&,CH_Matrix_Classes::Matrix&,bool,bool,const AffineFunctionTransformation*)
Header declaring the classes ConicBundle::AffineFunctionTransformation.