ConicBundle
SumBundle.hxx
Go to the documentation of this file.
1 
2 
3 #ifndef CONICBUNDLE_SUMBUNDLE_HXX
4 #define CONICBUNDLE_SUMBUNDLE_HXX
5 
6 
15 #include <map>
16 #include "VariableMetric.hxx"
18 
19 namespace ConicBundle {
20 
21 
73 
74 
75 
190 class SumBundle : public CBout
191 {
192 public:
194  enum Mode {
199  };
200 
202  SumBundle();
204  SumBundle(const SumBundle& sb);
206  ~SumBundle();
207 
209  void init(const SumBundle& sb);
210 
212  void synchronize_ids(CH_Matrix_Classes::Integer new_modification_id,
213  CH_Matrix_Classes::Integer new_center_id,
214  CH_Matrix_Classes::Integer old_center_id,
215  CH_Matrix_Classes::Integer new_cand_id,
216  CH_Matrix_Classes::Integer old_cand_id,
217  CH_Matrix_Classes::Integer new_prex_id=0);
218 
220  bool has_bundle_for(FunctionTask ft) const;
221 
223  bool has_bundle_data() const;
224 
226  int bundle_size(FunctionTask ft) const;
227 
229  bool has_roots() const;
230 
232  bool has_working_roots() const;
233 
235  bool active() const;
236 
238  bool has_contributions() const;
239 
240 
241  // gets the corresponding valid flag (call only if a has_bundle_for(ft)==true)
242  //bool get_valid(FunctionTask ft) const;
243 
245  Mode get_mode(FunctionTask ft) const;
246 
249 
252 
254  const MinorantBundle& get_bundle(FunctionTask ft) const;
255 
258 
260  const MinorantPointer& get_aggregate(FunctionTask ft) const;
261 
264 
268  const CH_Matrix_Classes::Matrix& y,
269  CH_Matrix_Classes::Real nullstep_bound,
270  CH_Matrix_Classes::Real relprec) const;
271 
274  const CH_Matrix_Classes::Matrix& y) const;
275 
278  CH_Matrix_Classes::Real factor=1.,
279  const AffineFunctionTransformation* aft=0) const;
280 
283  CH_Matrix_Classes::Real factor=1.,
284  const AffineFunctionTransformation* aft=0) const;
285 
289  FunctionTask ft);
290 
292  int apply_modification(const GroundsetModification& gsmdf,
294  MinorantExtender* mex,
295  FunctionTask ft);
296 
297 private:
298  friend class SumBundleHandler;
299 
344  class BData: public CBout
345  {
346  public:
349 
352 
355 
358 
361 
364 
367 
369  BData();
371  BData(const BData& bd);
373  ~BData();
375  void clear(CH_Matrix_Classes::Real fun_factor=1.);
377  void init(const BData& bd);
379  void synchronize_ids(CH_Matrix_Classes::Integer new_modification_id,
380  CH_Matrix_Classes::Integer new_center_id,
381  CH_Matrix_Classes::Integer old_center_id,
382  CH_Matrix_Classes::Integer new_cand_id,
383  CH_Matrix_Classes::Integer old_cand_id,
384  CH_Matrix_Classes::Integer new_prex_id=0);
386  BData& operator=(const BData& bd);
387 
390 
393 
395  int get_model_aggregate(MinorantPointer& aggregate,
396  CH_Matrix_Classes::Real factor=1.,
397  const AffineFunctionTransformation* aft=0) const;
398 
402 
404  int apply_modification(const GroundsetModification& gsmdf,
406  MinorantExtender* mex);
407  };
408 
410  typedef std::vector<BData> BDataVector;
411 
413  BDataVector bdata;
414 
416  void clear();
417 
419  void clear(FunctionTask ft);
420 
422  SumBundle& operator=(const SumBundle& sb);
423 
425  void init(FunctionTask ft,CH_Matrix_Classes::Real fun_factor=1.);
426 
429  void take_control(Mode mode);
430 
431  // allows to set the corresponding valid flag (call only if a has_bundle_for(ft)==true)
432  //bool& set_valid(FunctionTask ft);
433 
436 
439 
442 
445 
448 
451 
454 
457 
458 
459 };
460 
461 
463 
464 }
465 
466 #endif
467 
int Integer
all integer numbers in calculations and indexing are of this type
Definition: matop.hxx:40
CH_Matrix_Classes::Matrix coeff
the coefficients for forming the next aggregate generated by the last quadratic bundle subproblem...
Definition: SumBundle.hxx:357
class for use with SumBlockModel and BundlData for storing and managing a common bundle describing (p...
Definition: SumBundle.hxx:190
bool has_roots() const
returns true if one of its parts is a root
MinorantPointer cand_minorant
the minorant in the current candidate is stored and collected here and does NOT include the function_...
Definition: SumBundle.hxx:366
double Real
all real numbers in calculations are of this type
Definition: matop.hxx:50
the SumBundle/part is maybe maintained but currently not in use anywhere
Definition: SumBundle.hxx:197
void take_control(Mode mode)
if mode==root or mode==child and *this has a part marked as child, switch the mode to root; if mode==...
CH_Matrix_Classes::Integer get_n_contributors(FunctionTask ft) const
gets the corresponding n_contributors (call only if a has_bundle_for(ft)==true)
int apply_modification(const GroundsetModification &gsmdf, CH_Matrix_Classes::Integer mod_id, MinorantExtender *mex)
rearrange/extend the minorants according to the given groundset modifications
const PrimalData * get_approximate_primal(FunctionTask ft) const
if active, get the approximate primal (if add==false, initialize if possible and set add=true in this...
Interface for extending a Minorant, e.g., in Lagrangian Relaxation of cutting plane approaches...
Definition: CBSolver.hxx:490
CH_Matrix_Classes::Real get_function_factor(FunctionTask ft) const
gets the corresponding function factor (call only if a has_bundle_for(ft)==true)
BData()
default constructor
void synchronize_ids(CH_Matrix_Classes::Integer new_modification_id, CH_Matrix_Classes::Integer new_center_id, CH_Matrix_Classes::Integer old_center_id, CH_Matrix_Classes::Integer new_cand_id, CH_Matrix_Classes::Integer old_cand_id, CH_Matrix_Classes::Integer new_prex_id=0)
sets the modification_id to id
void clear(CH_Matrix_Classes::Real fun_factor=1.)
resets all to initial state
MinorantPointer & set_aggregate(FunctionTask ft)
allows to set the corresponding aggregate (call only if a has_bundle_for(ft)==true) ...
const MinorantBundle & get_bundle(FunctionTask ft) const
gets the corresponding minorants (call only if a has_bundle_for(ft)==true)
Mode
specifies for different parts of the sumbundle whether it is active and who is responsible for handli...
Definition: SumBundle.hxx:194
conic bundle method solver for sum of convex functions. See the ConicBundle_Manual for a quick introd...
Definition: CBSolver.hxx:22
int eval_model(CH_Matrix_Classes::Real &lb, CH_Matrix_Classes::Integer yid, const CH_Matrix_Classes::Matrix &y, CH_Matrix_Classes::Real nullstep_bound, CH_Matrix_Classes::Real relprec) const
evaluate the model values for all root parts, it may only be called if there are such because otherwi...
base class for uniform use of WARNINGS and ERRORS (at some point in time)
Definition: CBout.hxx:30
MinorantPointer aggregate
This is empty or stores last aggregate computed. If not empty, it includes the function_factor.
Definition: SumBundle.hxx:363
CH_Matrix_Classes::Real & set_function_factor(FunctionTask ft)
allows to set the corresponding function factor (call only if a has_bundle_for(ft)==true) ...
CH_Matrix_Classes::Real lb_model(CH_Matrix_Classes::Integer yid, const CH_Matrix_Classes::Matrix &y) const
returns a quick lower bound for the model value
bool has_contributions() const
returns true if one of its parts is a child
const CH_Matrix_Classes::Matrix & get_coeff(FunctionTask ft) const
gets the corresponding aggregation coefficients (call only if a has_bundle_for(ft)==true) ...
MinorantBundle & set_bundle(FunctionTask ft)
allows to set the corresponding minorants (call only if a has_bundle_for(ft)==true) ...
Header declaring the classes ConicBundle::VariableMetricModel, ConicBundle::VariableMetricBundleData...
BData & operator=(const BData &bd)
make a copy (uses init)
CH_Matrix_Classes::Integer n_contributors
the number of different subbundles added to this sumbundle part
Definition: SumBundle.hxx:351
int apply_modification(const GroundsetModification &gsmdf, CH_Matrix_Classes::Integer mod_id, MinorantExtender *mex, FunctionTask ft)
rearrange/extend the minorants according to the given groundset modifications
const MinorantPointer & get_cand_minorant(FunctionTask ft) const
gets the corresponding candidate minorant (call only if a has_bundle_for(ft)==true) ...
void init(const SumBundle &sb)
initialize
int get_local_model_aggregate(MinorantPointer &aggregate, CH_Matrix_Classes::Real factor=1., const AffineFunctionTransformation *aft=0) const
get the aggregate that is due to root sumbundle parts handled here
Mode & set_mode(FunctionTask ft)
allows to set the corresponding mode (call only if a has_bundle_for(ft)==true)
the SumBundle/part is active and contributes to the parent, no control here
Definition: SumBundle.hxx:196
CH_Matrix_Classes::Real lb_model(CH_Matrix_Classes::Integer yid, const CH_Matrix_Classes::Matrix &y) const
returns a quick lower bound for the root parts, it may only be called if there are such because other...
bool has_bundle_for(FunctionTask ft) const
returns true if BData exists for this mode
CH_Matrix_Classes::Real function_factor
for external use all offsets and minorants have to be mulitplied by this factor
Definition: SumBundle.hxx:354
MinorantPointer & set_cand_minorant(FunctionTask ft)
allows to set the corresponding aggregate (call only if a has_bundle_for(ft)==true) ...
std::vector< BData > BDataVector
for storing separate data for ObjectiveFunciton, ConstantPenaltyFunction, AdaptivePenaltyFunction ...
Definition: SumBundle.hxx:410
Matrix class for real values of type Real
Definition: matrix.hxx:74
bool has_bundle_data() const
returns true if BData exists
routines for updating and handling SumBundle components, possibly by cooperating over several recursi...
Definition: SumBundleHandler.hxx:42
FunctionTask
Each function represented by a FunctionModel is equipped with a function_factor (it defaults to 1...
Definition: CBSolver.hxx:221
std::vector< MinorantPointer > MinorantBundle
a bundle is a vector with MinorantPointer entries
Definition: MinorantPointer.hxx:24
void init(const BData &bd)
make a copy
int call_primal_extender(PrimalExtender &prex, CH_Matrix_Classes::Integer prex_id, FunctionTask ft)
call this primal extender for the primals; if there minorants but no primals or if it fails...
CH_Matrix_Classes::Integer & set_n_contributors(FunctionTask ft)
allows to set the corresponding n_contributors (call only if a has_bundle_for(ft)==true) ...
const MinorantPointer & get_aggregate(FunctionTask ft) const
gets the corresponding aggregate (call only if a has_bundle_for(ft)==true)
MinorantBundle bundle
the minorants collected and not discarded over time, they do NOT include function_factor yet ...
Definition: SumBundle.hxx:360
Definition: SumBundle.hxx:344
bool has_working_roots() const
returns true if one of its parts is a root with n_contributors>0
the SumBundle/part is active and starts here, it does not contribute to parent
Definition: SumBundle.hxx:195
the SumBundle/part is not even maintained
Definition: SumBundle.hxx:198
int bundle_size(FunctionTask ft) const
if BData exists for this mode it returns its bundle_size (possibly 0), otherwise 0 ...
void synchronize_ids(CH_Matrix_Classes::Integer new_modification_id, CH_Matrix_Classes::Integer new_center_id, CH_Matrix_Classes::Integer old_center_id, CH_Matrix_Classes::Integer new_cand_id, CH_Matrix_Classes::Integer old_cand_id, CH_Matrix_Classes::Integer new_prex_id=0)
sets the modification_id to id
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
Interface for extending PrimalData, e.g., in Lagrangian relaxation of column generation approaches...
Definition: CBSolver.hxx:180
int get_contributed_model_aggregate(MinorantPointer &aggregate, CH_Matrix_Classes::Real factor=1., const AffineFunctionTransformation *aft=0) const
get the aggregate that is due to child parts of the sumbundle, which are contributed to parents ...
int eval_model(CH_Matrix_Classes::Real &lb, CH_Matrix_Classes::Integer yid, const CH_Matrix_Classes::Matrix &y) const
evaluate the model value
BDataVector bdata
stores separate bundle data for ObjectiveFunciton, ConstantPenaltyFunction, AdaptivePenaltyFunction ...
Definition: SumBundle.hxx:413
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 call_primal_extender(PrimalExtender &prex, CH_Matrix_Classes::Integer prex_id)
call this primal extender for the primals; if there are minorants but no primals or if it fails...
int get_model_aggregate(MinorantPointer &aggregate, CH_Matrix_Classes::Real factor=1., const AffineFunctionTransformation *aft=0) const
get the aggregate multiplied by factor, add it if add==true, and with applying the AffineFunctionTran...
Mode get_mode(FunctionTask ft) const
gets the corresponding mode (call only if a has_bundle_for(ft)==true)
CH_Matrix_Classes::Matrix & set_coeff(FunctionTask ft)
allows to set the corresponding aggregation coefficients (call only if a has_bundle_for(ft)==true) ...
bool active() const
returns true if one of its parts is not inactive
points to MinorantUseData that may be shared by many and allows computations with Minorants ...
Definition: MinorantPointer.hxx:34
Mode mode
==root is handled here, ==child is handled at a parent, ==inactive if currently not in use but kept i...
Definition: SumBundle.hxx:348
Header declaring the classes ConicBundle::AffineFunctionTransformation.