ConicBundle
GroundsetModification.hxx
Go to the documentation of this file.
1 
2 
3 
4 #ifndef CONICBUNDLE_GROUNDSETMODIFICATION_HXX
5 #define CONICBUNDLE_GROUNDSETMODIFICATION_HXX
6 
7 
15 #include "Modification.hxx"
16 
17 namespace ConicBundle {
18 
19  class Minorant;
20 
24 
33 {
34 protected:
39 
40 public:
41  //-----------------------------------------------------------------------
45 
47  GroundsetModification(CH_Matrix_Classes::Integer var_olddim=0,const CBout* cbo=0,int incr=-1):
48  CBout(cbo,incr),mdf(var_olddim,0),offset(0.){}
49 
52  {mdf.clear(var_olddim,0);offset=0.;}
53 
54 
55  virtual ~GroundsetModification();
56 
57 
59 
60  //-----------------------------------------------------------------------
64 
67  const CH_Matrix_Classes::Matrix* start_val=0,
68  const CH_Matrix_Classes::Matrix* costs=0)
69  {return mdf.add_append_vars(append_dim,0,0,0,start_val,costs);}
70 
71 
74  {return mdf.add_reassign_vars(map_to_old);}
75 
79  {return mdf.add_delete_vars(del_ind,map_to_old);}
80 
83  {offset+=delta; return 0;}
84 
86 
87  //-----------------------------------------------------------------------
92 
95  {return mdf.apply_to_vars(&vars,0,0,0);}
96 
99  {in_offset+=offset; return mdf.apply_to_vars(0,0,0,&costs);}
100 
102 
103  //-----------------------------------------------------------------------
108 
109 
111  bool no_modification() const
112  {return mdf.no_modification();}
113 
115  int set_append_to_old(bool append_only)
116  {return mdf.set_append_to_old(append_only);}
118  bool append_to_old() const
119  {return mdf.append_to_old();}
120 
123  {
124  return ((mdf.appended_vardim()==0)&&((mdf.map_to_old_variables()==0)||(mdf.map_to_old_variables()->dim()==mdf.old_vardim())));
125  }
126 
129  {return mdf.deleted_variables_are_zero(oldpoint);}
130 
133  {return mdf.new_variables_are_zero(newpoint);}
134 
137  const CH_Matrix_Classes::Matrix& oldpoint) const
138  {return mdf.mapped_variables_are_equal(newpoint,oldpoint);}
139 
141 
142  //-----------------------------------------------------------------------
147 
149  int get_old_vardim() const {return mdf.old_vardim();}
151  int get_new_vardim() const {return mdf.new_vardim();}
153  int get_appended_vardim() const {return mdf.appended_vardim();}
154 
156  const int* get_map_to_old_variables() const
157  {return (mdf.map_to_old_variables())==0?0:(const int*)(mdf.map_to_old_variables()->get_store());}
158 
161  {return offset;}
162 
165  {return mdf.get_var_append_costs();}
166 
169  {
170  const GroundsetModification* gm=dynamic_cast<const GroundsetModification*>(&m);
171  if (gm) {offset+=gm->offset; return mdf.incorporate(gm->mdf);}
172  return 1;
173  }
174 
177  {return new GroundsetModification(old_var_dim);}
178 
180  int add_append_variables(int append_dim)
181  { return add_append_vars(append_dim); }
182 
184  int add_reassign_variables(int new_dim,const int* map_to_old_indices)
185  { CH_Matrix_Classes::Indexmatrix map_to_old(new_dim,1,map_to_old_indices);
186  return add_reassign_vars(map_to_old); }
187 
189 
190  //-----------------------------------------------------------------------
195 
202 
205  {return mdf.map_to_old_variables();}
206 
209  {return mdf.deleted_var_indices();}
210 
213  {return mdf.new_var_indices();}
214 
216 
217  //-----------------------------------------------------------------------
222 
224  void set_out(std::ostream* out=0,int print_level=1)
226 
228  void set_cbout(const CBout* cb=0,int incr=-1)
229  {CBout::set_cbout(cb,incr);mdf.set_cbout(this,0);}
230 
232 
233 };
234 
235 
236 
238 
239 }
240 
241 #endif
242 
int Integer
all integer numbers in calculations and indexing are of this type
Definition: matop.hxx:40
Base class for informing oracles (or the solver) about dynamic changes in the number and sorting of t...
Definition: CBSolver.hxx:544
CH_Matrix_Classes::Integer new_vardim() const
returns the number of variables once all stored modifications have been performed ...
Definition: Modification.hxx:671
bool append_to_old() const
returns true if this only contains appending operations and incorporating this is done with respect t...
Definition: Modification.hxx:650
int add_delete_vars(const CH_Matrix_Classes::Indexmatrix &del_ind, CH_Matrix_Classes::Indexmatrix &map_to_old)
delete the variables indexed by del_ind; for each new index map_to_old returns the old one; calls Mod...
Definition: GroundsetModification.hxx:77
double Real
all real numbers in calculations are of this type
Definition: matop.hxx:50
const int * get_map_to_old_variables() const
returns null if there are no index changes, otherwise the Indexmatrix pointed to is a vector whose i-...
Definition: GroundsetModification.hxx:156
const CH_Matrix_Classes::Matrix * get_append_costs() const
returns the change in the offste value of the groundset minorant
Definition: GroundsetModification.hxx:164
bool append_to_old() const
returns true if this only contains appending operations and incorporating this is done with respect t...
Definition: GroundsetModification.hxx:118
bool no_additions_or_deletions_in_vars() const
returns true if no variables were added or deleted (allows permutations), false otherwise ...
Definition: GroundsetModification.hxx:122
void set_out(std::ostream *out=0, int print_level=1)
see CBout::set_out
Definition: GroundsetModification.hxx:224
CH_Matrix_Classes::Real get_add_offset() const
returns the change in the offste value of the groundset minorant
Definition: GroundsetModification.hxx:160
int apply_to_vars(CH_Matrix_Classes::Matrix &vars) const
carry out the collected modifications on the given vector by calling Modification::apply_to_vars ...
Definition: GroundsetModification.hxx:94
CH_Matrix_Classes::Integer old_vardim() const
returns the number of variables before modification (given on initialization)
Definition: GroundsetModification.hxx:197
Matrix class for integral values of type Integer
Definition: indexmat.hxx:195
base class for collecting and organizing a sequence of changes to linear data so that it can be carri...
Definition: Modification.hxx:207
const CH_Matrix_Classes::Indexmatrix * deleted_var_indices() const
returns null if there were no deletions, otherwise the Indexmatrix pointed to is a vector holding the...
Definition: GroundsetModification.hxx:208
int get_appended_vardim() const
returns the number of variables that are appended (due to later reassignmentds they may no longer be ...
Definition: GroundsetModification.hxx:153
void set_cbout(const CBout *cb=0, int incr=-1)
see CBout::set_out
Definition: GroundsetModification.hxx:228
void clear(CH_Matrix_Classes::Integer var_olddim)
reset modifications to an unmodified object currently having var_olddim variables, calls Modification::clear
Definition: GroundsetModification.hxx:51
int add_reassign_variables(int new_dim, const int *map_to_old_indices)
reorder and resize the variables as given by the first new_dim entries of map_to_old_indices; each fo...
Definition: GroundsetModification.hxx:184
bool new_variables_are_zero(const CH_Matrix_Classes::Matrix &newpoint) const
returns true if all entries in newpoint (must be a vector of length new_vardim()) that correspond to ...
bool no_modification() const
returns true if no modifications need to be executed except possibly an offset change for the ground ...
Definition: GroundsetModification.hxx:111
int get_new_vardim() const
returns the number of variables once all stored modifications have been performed ...
Definition: GroundsetModification.hxx:151
const CH_Matrix_Classes::Indexmatrix * map_to_old_variables() const
returns null if there are no index changes, otherwise the Indexmatrix pointed to is a vector whose i-...
Definition: Modification.hxx:684
conic bundle method solver for sum of convex functions. See the ConicBundle_Manual for a quick introd...
Definition: CBSolver.hxx:22
OracleModification * new_initial_oraclemodification(int old_var_dim) const
returns a new object on the heap, that allows to incorporate this but starts off from a function whos...
Definition: GroundsetModification.hxx:176
bool deleted_variables_are_zero(const CH_Matrix_Classes::Matrix &oldpoint) const
returns true if all entries deleted in oldpoint (must be a vector of length old_vardim()) are 0 and f...
base class for uniform use of WARNINGS and ERRORS (at some point in time)
Definition: CBout.hxx:30
int add_delete_vars(const CH_Matrix_Classes::Indexmatrix &del_ind, CH_Matrix_Classes::Indexmatrix &map_to_old)
delete the variables indexed by the vector del_ind and return the index changes of the others in a ve...
CH_Matrix_Classes::Integer old_vardim() const
returns the number of variables before modification (given on initialization)
Definition: Modification.hxx:669
int apply_to_vars(CH_Matrix_Classes::Matrix *vars, CH_Matrix_Classes::Matrix *lb, CH_Matrix_Classes::Matrix *ub, CH_Matrix_Classes::Matrix *cost) const
carry out the collected modifications on the given vectors
Header declaring the class ConicBundle::ModificationBase.
CH_Matrix_Classes::Integer appended_vardim() const
returns the number of variables that are appended (due to later reassignmentds they may no longer be ...
Definition: Modification.hxx:673
const CH_Matrix_Classes::Indexmatrix * new_var_indices() const
returns null if no variables were added, otherwise the Indexmatrix pointed ato is a vector holding th...
Definition: GroundsetModification.hxx:212
int add_append_vars(CH_Matrix_Classes::Integer append_dim, const CH_Matrix_Classes::Matrix *start_val=0, const CH_Matrix_Classes::Matrix *costs=0)
append append_dim new variables with start_val as initial values (if NULL, use default value)...
Definition: GroundsetModification.hxx:66
int clear(CH_Matrix_Classes::Integer var_olddim, CH_Matrix_Classes::Integer row_olddim, bool ensure_start_val_box_feasibility=false, bool ensure_bounds_consistency=true, CH_Matrix_Classes::Real start_val_def=0., CH_Matrix_Classes::Real bounds_minus_infty=CB_minus_infinity, CH_Matrix_Classes::Real bounds_plus_infty=CB_plus_infinity, CH_Matrix_Classes::Real rhs_minus_infty=CB_minus_infinity, CH_Matrix_Classes::Real rhs_plus_infty=CB_plus_infinity, CH_Matrix_Classes::Real cost_def=0.)
resets all variables so that the object to be modified has starting size var_olddim (number of variab...
const CH_Matrix_Classes::Matrix * get_var_append_costs() const
returns null if nothing or default values have to be appended, otherwise it points to a matrix whose ...
Definition: Modification.hxx:736
int add_reassign_vars(const CH_Matrix_Classes::Indexmatrix &map_to_old)
reassign the current variable indices (with modifications) as specified by map_to_old ...
int add_append_variables(int append_dim)
append append_dim further variables at the end of the argument vector (without specifying their effec...
Definition: GroundsetModification.hxx:180
int get_old_vardim() const
returns the number of variables before modification
Definition: GroundsetModification.hxx:149
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...
int set_append_to_old(bool append_only)
if set to true, no deletions/reassignments may be present or specified in the future, only appensions are allowed
int apply_to_costs(CH_Matrix_Classes::Matrix &costs, CH_Matrix_Classes::Real &in_offset) const
carry out the collected modifications on the given vector by calling Modification::apply_to_vars ...
Definition: GroundsetModification.hxx:98
Matrix class for real values of type Real
Definition: matrix.hxx:74
CH_Matrix_Classes::Integer appended_vardim() const
returns the number of variables that are appended (due to later reassignmentds they may no longer be ...
Definition: GroundsetModification.hxx:201
Modification mdf
this class provides a restricted interface to this Modification instance where all modifications are ...
Definition: GroundsetModification.hxx:36
std::ostream * out
not output at all if out==0, otherwise use this output stream
Definition: CBout.hxx:33
bool new_variables_are_zero(const CH_Matrix_Classes::Matrix &newpoint) const
returns true if all entries in newpoint (must be a vector of length new_vardim()) that correspond to ...
Definition: GroundsetModification.hxx:132
const CH_Matrix_Classes::Indexmatrix * map_to_old_variables() const
returns null if there are no index changes, otherwise the Indexmatrix pointed to is a vector whose i-...
Definition: GroundsetModification.hxx:204
bool mapped_variables_are_equal(const CH_Matrix_Classes::Matrix &newpoint, const CH_Matrix_Classes::Matrix &oldpoint) const
returns true if the values in newpoint (must be a vector of length new_vardim()) that correspond to o...
Definition: GroundsetModification.hxx:136
int print_level
nonnegative level of output, 0 should mean WARNINGS and ERRORS only, 1 should represent normal output...
Definition: CBout.hxx:37
const CH_Matrix_Classes::Indexmatrix * deleted_var_indices() const
returns null if there were no deletions, otherwise the Indexmatrix pointed to is a vector holding the...
Definition: Modification.hxx:688
bool no_modification() const
returns true if no modifications need to be executed
Integer * get_store()
returns the current address of the internal value array; use cautiously, do not use delete! ...
Definition: indexmat.hxx:427
Collects modifications for the unconstrained Groundset for appending, deleting or reassigning variabl...
Definition: GroundsetModification.hxx:32
int set_append_to_old(bool append_only)
if set to true, no deletions/reassignments may be present or specified in the future, only appensions are allowed
Definition: GroundsetModification.hxx:115
bool deleted_variables_are_zero(const CH_Matrix_Classes::Matrix &oldpoint) const
returns true if all entries deleted in oldpoint (must be a vector of length old_vardim()) are 0...
Definition: GroundsetModification.hxx:128
const CH_Matrix_Classes::Indexmatrix * new_var_indices() const
returns null if no variables were added, otherwise the Indexmatrix pointed to is a vector holding the...
Definition: Modification.hxx:692
GroundsetModification(CH_Matrix_Classes::Integer var_olddim=0, const CBout *cbo=0, int incr=-1)
constructor, calls modification constructor
Definition: GroundsetModification.hxx:47
int add_offset(CH_Matrix_Classes::Real delta)
add to the current offset the value delta
Definition: GroundsetModification.hxx:82
void dim(Integer &_nr, Integer &_nc) const
returns the number of rows in _nr and the number of columns in _nc
Definition: indexmat.hxx:315
CH_Matrix_Classes::Real offset
specifies which value should be added to the offset of the groundset objective
Definition: GroundsetModification.hxx:38
int add_append_vars(CH_Matrix_Classes::Integer append_dim, const CH_Matrix_Classes::Matrix *append_lb, const CH_Matrix_Classes::Matrix *append_ub, const CH_Matrix_Classes::Sparsemat *append_cols, const CH_Matrix_Classes::Matrix *append_start_val, const CH_Matrix_Classes::Matrix *append_linear_costs)
append information on new variables at the respective ends
virtual int incorporate(const Modification &m)
add the modification specified in m on top of the modifications collected so far
bool mapped_variables_are_equal(const CH_Matrix_Classes::Matrix &newpoint, const CH_Matrix_Classes::Matrix &oldpoint) const
returns true if the values in newpoint (must be a vector of length new_vardim()) that correspond to o...
virtual void set_cbout(const CBout *cb, int incr=-1)
Specifies the output level relative to the given CBout class.
int incorporate(const OracleModification &m)
incorporate the OracleModification m (it should only contain variable changes, but this is not checke...
Definition: GroundsetModification.hxx:168
int add_reassign_vars(const CH_Matrix_Classes::Indexmatrix &map_to_old)
reassign the variables as given in map_to_old, calls Modification::add_reassign_vars ...
Definition: GroundsetModification.hxx:73
CH_Matrix_Classes::Integer new_vardim() const
returns the number of variables once all stored modifications have been performed ...
Definition: GroundsetModification.hxx:199