ConicBundle
LPGroundset.hxx
Go to the documentation of this file.
1 
2 
3 
4 #ifndef CONICBUNDLE_LPGROUNDSET_HXX
5 #define CONICBUNDLE_LPGROUNDSET_HXX
6 
7 
15 #include "Groundset.hxx"
16 #include "QPSolver.hxx"
17 #include "UQPSolver.hxx"
18 
19 namespace ConicBundle {
20 
48 class LPGroundset:public Groundset
49 {
50 private:
53 
56 
59 
62 
64  bool use_yfixing;
65 
68 
69  //the QPSolver for solving the bundle subproblem with Groundset
74 
75 
76  //data for describing the QP
80 
82 
83  //variable metric information
84 
86 
94 
95 protected:
96 
97 public:
99  virtual void clear( CH_Matrix_Classes::Integer indim=0,
100  CH_Matrix_Classes::Integer in_groundset_id=0);
101 
103  LPGroundset(CBout* cb=0):CBout(cb),vm_selection(0){qpsolver=new QPSolver(cb); uqpsolver.set_cbout(cb); clear(0,0);}
104 
107  const CH_Matrix_Classes::Matrix* lbyp=0,
108  const CH_Matrix_Classes::Matrix* ubyp=0,
109  const CH_Matrix_Classes::Sparsemat* Gp=0,
110  const CH_Matrix_Classes::Matrix* rhslbp=0,
111  const CH_Matrix_Classes::Matrix* rhsubp=0,
112  const CH_Matrix_Classes::Matrix* start_val=0,
113  const CH_Matrix_Classes::Matrix* costs=0,
114  const CH_Matrix_Classes::Real offset=0.,
115  CH_Matrix_Classes::Integer in_groundset_id=0,
116  CBout* cb=0);
117 
118  ~LPGroundset(){delete qpsolver; delete vm_selection;}
119 
122 
124  void set_groundset_id(CH_Matrix_Classes::Integer gsid){groundset_id=gsid;}
125 
128  {return dim;}
129 
131  int set_qpsolver(QPSolverParametersObject* qpparams,QPSolverObject* qpsolver=0);
132 
134  bool constrained() const
135  {return qpsolver->QPconstrained();}
136 
138  //CH_Matrix_Classes::Integer rowdim() const {return qpsolver.rowdim();}
139 
141  const CH_Matrix_Classes::Matrix* get_lby() const;
142 
144  const CH_Matrix_Classes::Matrix* get_uby() const;
145 
147  //const CH_Matrix_Classes::Indexmatrix& get_lbindex() const { return qpsolver.get_lbindex();}
148 
150  //const CH_Matrix_Classes::Indexmatrix& get_ubindex() const { return qpsolver.get_ubindex();}
151 
153  //const CH_Matrix_Classes::Sparsemat& get_G() const { return qpsolver.get_A();}
154 
156  //const CH_Matrix_Classes::Matrix& get_rhslb() const {return qpsolver.get_rhslb();}
157 
159  //const CH_Matrix_Classes::Matrix& get_rhsub() const {return qpsolver.get_rhsub();}
160 
162  //const CH_Matrix_Classes::Indexmatrix& get_rhslbind() const {return qpsolver.get_rhslbind();}
163 
165  //const CH_Matrix_Classes::Indexmatrix& get_rhsubind() const {return qpsolver.get_rhsubind();}
166 
168  virtual bool is_feasible(CH_Matrix_Classes::Integer& in_groundset_id,
169  const CH_Matrix_Classes::Matrix& y,
170  CH_Matrix_Classes::Real relprec=1e-10);
171 
173  int ensure_feasibility(CH_Matrix_Classes::Integer& in_groundset_id,
175  bool& ychanged,
176  BundleProxObject* Hp,
177  CH_Matrix_Classes::Real relprec=1e-10);
178 
180  virtual QPSolverObject* get_qp_solver(bool& solves_model_without_gs,
181  BundleProxObject* Hp);
182 
185  {
186  return 0;
187  }
188 
191  {return starting_point;}
192 
195  {starting_point=vec; int dummy=-1; return (is_feasible(dummy,vec)==false);}
196 
198  virtual int candidate(CH_Matrix_Classes::Integer& gs_id,
200  CH_Matrix_Classes::Real& cand_gs_val,
201  CH_Matrix_Classes::Real& linval,
202  CH_Matrix_Classes::Real& augval_lb,
203  CH_Matrix_Classes::Real& augval_ub,
204  CH_Matrix_Classes::Real& subgnorm2,
205  const CH_Matrix_Classes::Matrix& center_y,
206  CH_Matrix_Classes::Real center_value,
207  const MinorantPointer& model_minorant,
208  BundleProxObject* Hp,
209  MinorantPointer* delta_groundset_minorant=0,
210  CH_Matrix_Classes::Indexmatrix* delta_index=0,
211  CH_Matrix_Classes::Real relprec=1e-2);
212 
214  virtual const MinorantPointer& get_gs_aggregate() const { return gs_aggregate;}
215 
217  const MinorantPointer& get_gs_minorant() const { return gs_minorant;}
218 
221  {return (use_yfixing? &yfixed : 0);}
222 
225  {return (use_yfixing? &yfixed : 0);}
226 
228  bool get_use_yfixing() const {return use_yfixing;}
229 
231  void set_use_yfixing(bool uyf) {use_yfixing=uyf;}
232 
235  { delete vm_selection; vm_selection=vms; return 0;}
236 
239  { return vm_selection;}
240 
244  const CH_Matrix_Classes::Matrix& y,
245  bool descent_step,
246  CH_Matrix_Classes::Real weightu,
247  CH_Matrix_Classes::Real model_maxviol,
248  const CH_Matrix_Classes::Indexmatrix* indices=0);
249 
252  { return qpsolver->QPstart_modification();}
253 
256 
257 
259  int mfile_data(std::ostream& out) const;
260 
262  void set_cbout(const CBout* cb, int incr=-1)
263  {
265  qpsolver->set_cbout(this);
266  uqpsolver.set_cbout(this);
267  }
268 
269 };
270 
277 }
278 
279 #endif
280 
int Integer
all integer numbers in calculations and indexing are of this type
Definition: matop.hxx:40
abstract interface for a QPSolver
Definition: QPSolverObject.hxx:105
GroundsetModification * start_modification()
propagates the call to QPSolverObject::QPstart_modification() of the current qpsolver ...
Definition: LPGroundset.hxx:251
const CH_Matrix_Classes::Matrix * get_lby() const
number of linear constraints
abstract interface that allows to use different -norms with a positive definite matrix in the proxi...
Definition: BundleProxObject.hxx:88
CH_Matrix_Classes::Matrix old_lowrank
used by the variable metric low rank heuristic
Definition: LPGroundset.hxx:91
virtual void clear(CH_Matrix_Classes::Integer indim=0, CH_Matrix_Classes::Integer in_groundset_id=0)
resets all values as described in Groundset::clear()
CH_Matrix_Classes::Integer dim
current dimension of the ground set
Definition: LPGroundset.hxx:52
double Real
all real numbers in calculations are of this type
Definition: matop.hxx:50
QPSolver is the access point for ConicBundle to the internal constrained QP Solver, see Internal QP Solver for linearly constrained groundsets.
Definition: QPSolver.hxx:120
Matrix class for integral values of type Integer
Definition: indexmat.hxx:195
virtual QPSolverObject * get_qp_solver(bool &solves_model_without_gs, BundleProxObject *Hp)
returns a pointer to an internal QPSolverObject that is able to solve bundle suproblems efficiently f...
CH_Matrix_Classes::Indexmatrix yfixed
in constrained versions, when use_yfixing is true, this indicates whether a coordinate should be cons...
Definition: LPGroundset.hxx:67
virtual bool QPconstrained() const =0
returns false if the feasible set is the entire space (unconstrained optimization), true otherwise.
MinorantPointer gs_aggregate
the ground set aggregate, here giving the linear coefficients of the affine cost function ...
Definition: LPGroundset.hxx:61
CH_Matrix_Classes::Symmatrix old_sym
used by the variable metric heuristic
Definition: LPGroundset.hxx:93
int set_variable_metric_selection(VariableMetricSelection *vms=0)
delete old selector and set a new one (0 is allowed resulting in no local selector) ...
Definition: LPGroundset.hxx:234
virtual const MinorantPointer & get_gs_aggregate() const
returns the groundset aggregate computed in candidate()
Definition: LPGroundset.hxx:214
virtual bool is_feasible(CH_Matrix_Classes::Integer &in_groundset_id, const CH_Matrix_Classes::Matrix &y, CH_Matrix_Classes::Real relprec=1e-10)
returns the indices of variable lower bounds > ConicBundle::CB_minus_infinity
virtual GroundsetModification * QPstart_modification()=0
return a new modification object on the heap that is initialized for modification of *this...
CH_Matrix_Classes::Matrix old_diagonal
used by the variable metric low rank heuristic
Definition: LPGroundset.hxx:92
CH_Matrix_Classes::Integer max_minorants
maximum number of minorants
Definition: LPGroundset.hxx:89
Matrix class of symmetric matrices with real values of type Real
Definition: symmat.hxx:43
CH_Matrix_Classes::Integer minorant_nexti
used by the variable metric low rank heuristic
Definition: LPGroundset.hxx:90
unconstrained QP solver combining the properties of a QPModelDataPointer and QPSolverObject ...
Definition: UQPSolver.hxx:138
in order to pass parameters to a customized QPSolverObject, derive the parameters from this object; n...
Definition: QPSolverObject.hxx:46
bool constrained() const
returns false if the feasible set is the entire space (unconstrained optimization), true otherwise.
Definition: LPGroundset.hxx:134
conic bundle method solver for sum of convex functions. See the ConicBundle_Manual for a quick introd...
Definition: CBSolver.hxx:22
UQPSolver uqpsolver
special solver for easy groundsets
Definition: LPGroundset.hxx:71
virtual CH_Matrix_Classes::Integer get_dim() const
returns the dimension of the ground set, i.e., the length of the variables vector y ...
Definition: LPGroundset.hxx:127
CH_Matrix_Classes::Real gamma
constant offset for QP-subproblems
Definition: LPGroundset.hxx:79
VariableMetricSelection * vm_selection
specifieable routine for computing a metric contribution of the groundset, see Variable Metric ...
Definition: LPGroundset.hxx:85
bool solve_model_without_gs
selected varaint of solving the subproblem
Definition: LPGroundset.hxx:73
base class for uniform use of WARNINGS and ERRORS (at some point in time)
Definition: CBout.hxx:30
QPSolverObject * qpsolver
general solver for all groundsets
Definition: LPGroundset.hxx:70
virtual const CH_Matrix_Classes::Matrix & get_starting_point() const
returns a stored starting point, note: this need not be feasible; if generated automatically, its dimension is correct.
Definition: LPGroundset.hxx:190
int apply_modification(const GroundsetModification &mdf)
change the groundset description as specified by the argument
void set_use_yfixing(bool uyf)
set to true to switch on the cooridinate fixing heuristic (only constrained cases) ...
Definition: LPGroundset.hxx:231
Header declaring the class ConicBundle::UQPSolver.
bool use_yfixing
if set to true in constrained versions, y-variables that are at strongly active bounds should be fixe...
Definition: LPGroundset.hxx:64
QPSolverObject * qp_solver
the selected solver
Definition: LPGroundset.hxx:72
CH_Matrix_Classes::Integer get_groundset_id() const
returns the current groundset_id, increased values indicate changes in the ground set ...
Definition: LPGroundset.hxx:121
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 VariableMetric
virtual const CH_Matrix_Classes::Indexmatrix * get_yfixed() const
if not NULL (iff get_use_yfixing()==false) it returns the vector yfixed with yfixed(i)=0 if not fixed...
Definition: LPGroundset.hxx:220
int set_qp_solver_parameters(QPSolverParametersObject *)
set parameters for the QP_Solver
Definition: LPGroundset.hxx:184
abstract representation of the feasible convex ground set to be optimized over, provides the QP solve...
Definition: Groundset.hxx:77
interface class that allows a VariableMetricModel to contribute information to a VariableMetric objec...
Definition: VariableMetric.hxx:309
bool store_old_minorants
false by default, set to true if variable metric is used
Definition: LPGroundset.hxx:87
CH_Matrix_Classes::Matrix starting_point
the starting point
Definition: LPGroundset.hxx:58
VariableMetricSelection * get_variable_metric_selection() const
delete old selector and set a new one (0 is allowed resulting in no local selector) ...
Definition: LPGroundset.hxx:238
int set_qpsolver(QPSolverParametersObject *qpparams, QPSolverObject *qpsolver=0)
Set the qp solver's parameters to qpparams (if not null); if the second argument qpsolver is also giv...
Matrix class for real values of type Real
Definition: matrix.hxx:74
abstract interface, that allows to specify a routine for providing or computing a suitable variable m...
Definition: VariableMetric.hxx:237
represents a polyhedral feasible ground set by affine constraints as in Linear Programming with speci...
Definition: LPGroundset.hxx:48
std::ostream * out
not output at all if out==0, otherwise use this output stream
Definition: CBout.hxx:33
Matrix class of sparse matrices with real values of type Real
Definition: sparsmat.hxx:74
std::vector< MinorantPointer > MinorantBundle
a bundle is a vector with MinorantPointer entries
Definition: MinorantPointer.hxx:24
void set_cbout(const CBout *cb, int incr=-1)
output settings
Definition: LPGroundset.hxx:262
virtual int set_starting_point(const CH_Matrix_Classes::Matrix &vec)
stores the a new starting point irrespective of whether it is feasible or not and returns 0 if it fea...
Definition: LPGroundset.hxx:194
virtual int candidate(CH_Matrix_Classes::Integer &gs_id, CH_Matrix_Classes::Matrix &newy, CH_Matrix_Classes::Real &cand_gs_val, CH_Matrix_Classes::Real &linval, CH_Matrix_Classes::Real &augval_lb, CH_Matrix_Classes::Real &augval_ub, CH_Matrix_Classes::Real &subgnorm2, const CH_Matrix_Classes::Matrix &center_y, CH_Matrix_Classes::Real center_value, const MinorantPointer &model_minorant, BundleProxObject *Hp, MinorantPointer *delta_groundset_minorant=0, CH_Matrix_Classes::Indexmatrix *delta_index=0, CH_Matrix_Classes::Real relprec=1e-2)
computes the next ground set minorant and candidate, see Groundset::candidate()
const CH_Matrix_Classes::Matrix * get_uby() const
returns the upper bounds vector on y if it exists
int mfile_data(std::ostream &out) const
m-file output routine for debugging or testing in Matlab (not yet working)
bool get_use_yfixing() const
true if the cooridinate fixing heuristic is switched on (only constrained cases)
Definition: LPGroundset.hxx:228
Header declaring the class ConicBundle::QPSolver.
Collects modifications for the unconstrained Groundset for appending, deleting or reassigning variabl...
Definition: GroundsetModification.hxx:32
void set_groundset_id(CH_Matrix_Classes::Integer gsid)
sets the groundset_id to the desired value, increasing it is safer here because this is used to indic...
Definition: LPGroundset.hxx:124
MinorantBundle old_minorants
minorants collected for variable metric purpose
Definition: LPGroundset.hxx:88
const MinorantPointer & get_gs_minorant() const
returns the linear minorant valid on the entire ground set (e.g. a linear cost funciton) ...
Definition: LPGroundset.hxx:217
LPGroundset(CBout *cb=0)
calls clear() with the same parameters
Definition: LPGroundset.hxx:103
virtual CH_Matrix_Classes::Indexmatrix * set_yfixed()
if not NULL (iff get_use_yfixing()==false) returns the vector yfixed with yfixed(i)=0 if not fixed...
Definition: LPGroundset.hxx:224
CH_Matrix_Classes::Integer groundset_id
nonnegative update counter for recognizing changes in the groundset description
Definition: LPGroundset.hxx:55
points to MinorantUseData that may be shared by many and allows computations with Minorants ...
Definition: MinorantPointer.hxx:34
int ensure_feasibility(CH_Matrix_Classes::Integer &in_groundset_id, CH_Matrix_Classes::Matrix &y, bool &ychanged, BundleProxObject *Hp, CH_Matrix_Classes::Real relprec=1e-10)
makes y feasible if not so, see Groundset::ensure_feasibility()
BundleProxObject * Hp
points to the quadratic cost matrix inside ensure_feasibility() and candidate(), otherwise ==NULL ...
Definition: LPGroundset.hxx:77
virtual void set_cbout(const CBout *cb, int incr=-1)
Specifies the output level relative to the given CBout class.
MinorantPointer gs_minorant
affine cost function for the ground set
Definition: LPGroundset.hxx:81
Header declaring the class ConicBundle::Groundset.
CH_Matrix_Classes::Matrix c
linear cost term for QP-subproblems
Definition: LPGroundset.hxx:78