ConicBundle
NNCBoxSupportModification.hxx
Go to the documentation of this file.
1 
2 
3 
4 #ifndef CONICBUNDLE_NNCBOXSUPPORTMODIFICATION_HXX
5 #define CONICBUNDLE_NNCBOXSUPPORTMODIFICATION_HXX
6 
7 
15 #include "Modification.hxx"
16 
17 namespace ConicBundle {
18 
19  class Minorant;
20 
24 
33 {
34 protected:
37 
38 public:
39  //-----------------------------------------------------------------------
43 
46  const CBout* cb=0,
47  int incr=-1):
48  CBout(cb,incr),mdf(var_olddim,0,cb,incr,false,true,0.,0.,0.){}
49 
52  {mdf.clear(var_olddim,0);}
53 
54 
55  virtual ~NNCBoxSupportModification();
56 
57 
59 
60  //-----------------------------------------------------------------------
64 
67  const CH_Matrix_Classes::Matrix* append_lb,
68  const CH_Matrix_Classes::Matrix* append_ub)
69  {return mdf.add_append_vars(append_dim,append_lb,append_ub,0,0,0);}
70 
71 
74  {return mdf.add_reassign_vars(map_to_old);}
75 
79  {return mdf.add_delete_vars(del_ind,map_to_old);}
80 
81 
83 
84  //-----------------------------------------------------------------------
89 
92  CH_Matrix_Classes::Matrix& ub) const
93  {return mdf.apply_to_vars(0,&lb,&ub,0);}
94 
95 
97 
98  //-----------------------------------------------------------------------
103 
104 
106  bool no_modification() const
107  {return mdf.no_modification();}
108 
110  int set_append_to_old(bool append_only)
111  {return mdf.set_append_to_old(append_only);}
113  bool append_to_old() const
114  {return mdf.append_to_old();}
115 
118  {
119  return ((mdf.appended_vardim()==0)&&((mdf.map_to_old_variables()==0)||(mdf.map_to_old_variables()->dim()==mdf.old_vardim())));
120  }
121 
124  {return mdf.deleted_variables_are_zero(oldpoint);}
125 
128  {return mdf.new_variables_are_zero(newpoint);}
129 
132  const CH_Matrix_Classes::Matrix& oldpoint) const
133  {return mdf.mapped_variables_are_equal(newpoint,oldpoint);}
134 
136 
137  //-----------------------------------------------------------------------
142 
144  int get_old_vardim() const {return mdf.old_vardim();}
146  int get_new_vardim() const {return mdf.new_vardim();}
148  int get_appended_vardim() const {return mdf.appended_vardim();}
149 
151  const int* get_map_to_old_variables() const
152  {return (mdf.map_to_old_variables())==0?0:(const int*)(mdf.map_to_old_variables()->get_store());}
153 
156  {
157  const NNCBoxSupportModification* gm=dynamic_cast<const NNCBoxSupportModification*>(&m);
158  if (gm) {return mdf.incorporate(gm->mdf);}
159  return 1;
160  }
161 
164  {return new NNCBoxSupportModification(old_var_dim);}
165 
167  int add_append_variables(int append_dim)
168  { return mdf.add_append_vars(append_dim,0,0,0,0,0); }
169 
171  int add_reassign_variables(int new_dim,const int* map_to_old_indices)
172  { CH_Matrix_Classes::Indexmatrix map_to_old(new_dim,1,map_to_old_indices);
173  return add_reassign_vars(map_to_old); }
174 
176 
177  //-----------------------------------------------------------------------
182 
189 
192  {return mdf.map_to_old_variables();}
193 
196  {return mdf.deleted_var_indices();}
197 
200  {return mdf.new_var_indices();}
201 
203 
204  //-----------------------------------------------------------------------
209 
211  void set_out(std::ostream* out=0,int print_level=1)
213 
215  void set_cbout(const CBout* cb=0,int incr=-1)
216  {CBout::set_cbout(cb,incr);mdf.set_cbout(this,0);}
217 
219 
220 };
221 
222 
223 
225 
226 }
227 
228 #endif
229 
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
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: NNCBoxSupportModification.hxx:73
CH_Matrix_Classes::Integer new_vardim() const
returns the number of variables once all stored modifications have been performed ...
Definition: Modification.hxx:671
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: NNCBoxSupportModification.hxx:123
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: NNCBoxSupportModification.hxx:77
Collects modifications for NNCBoxSupport for appending, deleting or reassigning variables and respect...
Definition: NNCBoxSupportModification.hxx:32
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: NNCBoxSupportModification.hxx:191
void set_cbout(const CBout *cb=0, int incr=-1)
see CBout::set_out
Definition: NNCBoxSupportModification.hxx:215
CH_Matrix_Classes::Integer old_vardim() const
returns the number of variables before modification (given on initialization)
Definition: NNCBoxSupportModification.hxx:184
Matrix class for integral values of type Integer
Definition: indexmat.hxx:195
bool no_additions_or_deletions_in_vars() const
returns true if no variables were added or deleted (allows permutations), false otherwise ...
Definition: NNCBoxSupportModification.hxx:117
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: NNCBoxSupportModification.hxx:195
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: NNCBoxSupportModification.hxx:127
base class for collecting and organizing a sequence of changes to linear data so that it can be carri...
Definition: Modification.hxx:207
int get_old_vardim() const
returns the number of variables before modification
Definition: NNCBoxSupportModification.hxx:144
Modification mdf
this class provides a restricted interface to this Modification instance where all modifications are ...
Definition: NNCBoxSupportModification.hxx:36
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: NNCBoxSupportModification.hxx:106
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: NNCBoxSupportModification.hxx:163
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
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: NNCBoxSupportModification.hxx:171
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 get_new_vardim() const
returns the number of variables once all stored modifications have been performed ...
Definition: NNCBoxSupportModification.hxx:146
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
CH_Matrix_Classes::Integer new_vardim() const
returns the number of variables once all stored modifications have been performed ...
Definition: NNCBoxSupportModification.hxx:186
Header declaring the class ConicBundle::ModificationBase.
int add_append_vars(CH_Matrix_Classes::Integer append_dim, const CH_Matrix_Classes::Matrix *append_lb, const CH_Matrix_Classes::Matrix *append_ub)
append append_dim new variables to the box function
Definition: NNCBoxSupportModification.hxx:66
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
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...
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 ...
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 add_append_variables(int append_dim)
append append_dim further variables at the end of the argument vector (without effect on the box func...
Definition: NNCBoxSupportModification.hxx:167
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 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: NNCBoxSupportModification.hxx:110
Matrix class for real values of type Real
Definition: matrix.hxx:74
std::ostream * out
not output at all if out==0, otherwise use this output stream
Definition: CBout.hxx:33
void clear(CH_Matrix_Classes::Integer var_olddim)
reset modifications to an unmodified object currently having var_olddim variables, calls Modification::clear
Definition: NNCBoxSupportModification.hxx:51
NNCBoxSupportModification(CH_Matrix_Classes::Integer var_olddim=0, const CBout *cb=0, int incr=-1)
constructor, calls modification constructor
Definition: NNCBoxSupportModification.hxx:45
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
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: NNCBoxSupportModification.hxx:188
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
int incorporate(const OracleModification &m)
incorporate the OracleModification m (it should only contain variable changes, but this is not checke...
Definition: NNCBoxSupportModification.hxx:155
void set_out(std::ostream *out=0, int print_level=1)
see CBout::set_out
Definition: NNCBoxSupportModification.hxx:211
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: NNCBoxSupportModification.hxx:131
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: NNCBoxSupportModification.hxx:199
bool append_to_old() const
returns true if this only contains appending operations and incorporating this is done with respect t...
Definition: NNCBoxSupportModification.hxx:113
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
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
int apply_to_bounds(CH_Matrix_Classes::Matrix &lb, CH_Matrix_Classes::Matrix &ub) const
carry out the collected modifications on the given vectors of lower and upper bounds on the variables...
Definition: NNCBoxSupportModification.hxx:91
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...
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: NNCBoxSupportModification.hxx:151
int get_appended_vardim() const
returns the number of variables that are appended (due to later reassignmentds they may no longer be ...
Definition: NNCBoxSupportModification.hxx:148
virtual void set_cbout(const CBout *cb, int incr=-1)
Specifies the output level relative to the given CBout class.