ConicBundle
QPSolver.hxx
Go to the documentation of this file.
1 
2 #ifndef CONICBUNDLE_QPSOLVER_HXX
3 #define CONICBUNDLE_QPSOLVER_HXX
4 
13 #include "Groundset.hxx"
15 
16 namespace ConicBundle {
17 
18 
113 
114 
115 class GroundsetModification;
116 
120  class QPSolver:public virtual QPSolverBasicStructures
121 {
122 private:
126  public:
142 
143 
147  //data for describing the quadratic cost matrix Q
151 
154 
155  };
156 
162 
165 
170  std::map<MinorantPointer,MinorantPointer> preproc_bundle_projection;
171 
173 
174 
178  CH_Matrix_Classes::Real sol_val_lb;
179  CH_Matrix_Classes::Real sol_val_ub;
180  CH_Matrix_Classes::Matrix sol_point;
181  CH_Matrix_Classes::Real gs_aggr_offset;
182  CH_Matrix_Classes::Matrix gs_aggr_gradient;
184 
185 
186 
195 
196 
200 
203 
205  int preprocess_data(const CH_Matrix_Classes::Matrix& center_y,
207  bool& no_changes);
208 
209  int postprocess_data(bool round_to_active_bounds);
210 
212 
213 protected:
214 
218  CH_Matrix_Classes::Integer QPget_xdim() const {return qp_data->dim;}
221  CH_Matrix_Classes::Integer QPget_ydim() const {return qp_data->A.rowdim();}
222 
225  {return qp_data->Hp->add_Hx(xin,outplusQx);}
226 
228  const CH_Matrix_Classes::Matrix& QPget_c() const {return qp_data->c;}
229 
231  CH_Matrix_Classes::Real QPget_gamma() const {return qp_data->gamma;}
232 
234  const CH_Matrix_Classes::Matrix& QPget_rhslb() const {return qp_data->rhslb;}
235 
237  const CH_Matrix_Classes::Matrix& QPget_rhsub() const {return qp_data->rhsub;}
238 
240  const CH_Matrix_Classes::Indexmatrix& QPget_rhslbind() const {return qp_data->rhslbindex;}
241 
243  const CH_Matrix_Classes::Indexmatrix& QPget_rhsubind() const {return qp_data->rhsubindex;}
244 
246  const CH_Matrix_Classes::Matrix& QPget_lb() const {return qp_data->lby;}
247 
249  const CH_Matrix_Classes::Matrix& QPget_ub() const {return qp_data->uby;}
250 
252  const CH_Matrix_Classes::Indexmatrix& QPget_lbind() const {return qp_data->lbindex;}
253 
255  const CH_Matrix_Classes::Indexmatrix& QPget_ubind() const {return qp_data->ubindex;}
256 
259  {return CH_Matrix_Classes::genmult(qp_data->A,xin,outplusAx,1.,1.);}
260 
263  {return CH_Matrix_Classes::genmult(qp_data->A,yin,outplusAty,1.,1.,1);}
265 
266 
267 public:
268 
270  void QPclear();
271 
273  QPSolver(CBout* cb=0,int cbinc=-1):
274  CBout(cb,cbinc),QPSolverBasicStructures(0,cb)
275  { original_data.Hp=0;preproc_data.Hp=0; QPclear();}
276 
277  ~QPSolver(){}
278 
279  //------------ QPSolverOject routines
280 
283  {
284  QPSolverParameters* qpp=dynamic_cast<QPSolverParameters*>(params);
285  if (qpp==0)
286  return 1;
287  return QPset_solver_parameters(qpp);
288  }
289 
292  { return false;}
293 
296  virtual bool QPsupports_updates()
297  { return false;}
298 
301  { return QPget_dualval(); }
302 
304  int QPsolve(const CH_Matrix_Classes::Matrix& center_y,
305  CH_Matrix_Classes::Real lower_bound,
306  CH_Matrix_Classes::Real upper_bound,
307  CH_Matrix_Classes::Real relprec,
309  const MinorantPointer& gs_aggr,
311 
313  int QPupdate(const CH_Matrix_Classes::Matrix& center_y,
314  CH_Matrix_Classes::Real lower_bound,
315  CH_Matrix_Classes::Real upper_bound,
316  CH_Matrix_Classes::Real relprec,
317  QPSolverProxObject* Hp,
318  const MinorantPointer& gs_aggr,
320  const MinorantPointer& delta_gs_aggr,
321  const CH_Matrix_Classes::Indexmatrix& delta_index);
322 
324  int QPresolve(CH_Matrix_Classes::Real lower_bound,
325  CH_Matrix_Classes::Real upper_bound,
326  CH_Matrix_Classes::Real relprec);
327 
330  CH_Matrix_Classes::Real& augval_ub,
331  CH_Matrix_Classes::Matrix& new_point,
332  CH_Matrix_Classes::Real& gsaggr_offset,
333  CH_Matrix_Classes::Matrix& gsaggr_gradient);
334 
336  std::ostream& QPprint_statistics(std::ostream& out,int /* printlevel*/ =0)
337  {return out;}
338 
341  {return new LPGroundsetModification(original_data.dim,original_data.A.rowdim(),this);}
342 
345 
348  CH_Matrix_Classes::Real relprec=1e-10);
349 
352  bool& ychanged,
353  QPSolverProxObject* inHp,
354  CH_Matrix_Classes::Real relprec=1e-10);
355 
357  int solve(BundleProxObject* Hp,
360  CH_Matrix_Classes::Real lowerbound,
361  CH_Matrix_Classes::Real upperbound,
362  CH_Matrix_Classes::Real relprec,
363  CH_Matrix_Classes::Real skip_factor);
364 
367 
369  bool QPconstrained() const
370  {return (original_data.lbindex.rowdim()+original_data.ubindex.rowdim()+original_data.A.rowdim()==0)?false:true;}
371 
373  CH_Matrix_Classes::Integer rowdim() const {return original_data.A.rowdim();}
374 
376  const CH_Matrix_Classes::Matrix& get_lby() const { return original_data.lby;}
377 
379  const CH_Matrix_Classes::Matrix& get_uby() const { return original_data.uby;}
380 
382  const CH_Matrix_Classes::Indexmatrix& get_lbindex() const { return original_data.lbindex;}
383 
385  const CH_Matrix_Classes::Indexmatrix& get_ubindex() const { return original_data.ubindex;}
386 
388  const CH_Matrix_Classes::Sparsemat& get_A() const { return original_data.A;}
389 
391  const CH_Matrix_Classes::Matrix& get_rhslb() const {return original_data.rhslb;}
392 
394  const CH_Matrix_Classes::Matrix& get_rhsub() const {return original_data.rhsub;}
395 
397  const CH_Matrix_Classes::Indexmatrix& get_rhslbind() const {return original_data.rhslbindex;}
398 
400  const CH_Matrix_Classes::Indexmatrix& get_rhsubind() const {return original_data.rhsubindex;}
401 
404  const CH_Matrix_Classes::Matrix*& ub,
405  const CH_Matrix_Classes::Indexmatrix*& lbind,
406  const CH_Matrix_Classes::Indexmatrix*& ubind
407  ) const
408  {
409  lb=&get_lby();
410  ub=&get_uby();
411  lbind=&get_lbindex();
412  ubind=&get_ubindex();
413  if ((!QPconstrained())||(original_data.A.rowdim()!=0))
414  return false;
415  return true;
416  }
417 
419  int mfile_data(std::ostream& out) const;
420 
422  void set_cbout(const CBout* cb, int incr=-1)
423  {
424  CBout::set_cbout(cb,incr);
425  if (model_block)
426  model_block->set_cbout(cb,incr);
427  }
428 
429 };
430 
431 
432 
433 
435 
436 }
437 
438 #endif
439 
int Integer
all integer numbers in calculations and indexing are of this type
Definition: matop.hxx:40
bool QPis_feasible(const CH_Matrix_Classes::Matrix &y, CH_Matrix_Classes::Real relprec=1e-10)
check feasiblity of y for the current groundset constraints
CH_Matrix_Classes::Real objective_gap_eps
relative precision for QP objective termination
Definition: QPSolver.hxx:194
CH_Matrix_Classes::Real lower_bound_gap_eps
distance to lower bound termination parameter
Definition: QPSolver.hxx:192
parameters for steering the termination criteria and solution method of the solver ...
Definition: QPSolverParameters.hxx:26
QPModelBlock * model_block
stores a pointer to the current starting block giving access to the cutting model(s) [it does not own...
Definition: QPModelBlock.hxx:451
abstract interface that allows to use different -norms with a positive definite matrix in the proxi...
Definition: BundleProxObject.hxx:88
const CH_Matrix_Classes::Indexmatrix & get_rhsubind() const
returns the indices with constraint upper bound slacks
Definition: QPSolver.hxx:400
int QPresolve(CH_Matrix_Classes::Real lower_bound, CH_Matrix_Classes::Real upper_bound, CH_Matrix_Classes::Real relprec)
resolve the bundle subproblem (usually because of modified penalty parameters) so that precision requ...
CH_Matrix_Classes::Indexmatrix preproc_fixed
1 if coordinate has fixed value, 0 otherwise; dimension is (0,0) if not initialized ...
Definition: QPSolver.hxx:166
double Real
all real numbers in calculations are of this type
Definition: matop.hxx:50
virtual int QPset_solver_parameters(QPSolverParameters *params)
pass on new parameters, ownership is tranferred to this, will be deleted here
Definition: QPSolverBasicStructures.hxx:447
const CH_Matrix_Classes::Indexmatrix & QPget_rhsubind() const
QP-sover-interface routine for indices of constraint upper bound slacks.
Definition: QPSolver.hxx:243
const CH_Matrix_Classes::Matrix & QPget_lb() const
QP-solver-interface routine for variable lower bounds.
Definition: QPSolver.hxx:246
const CH_Matrix_Classes::Indexmatrix & QPget_rhslbind() const
QP-sover-interface routine for indices of constraint lower bound slacks.
Definition: QPSolver.hxx:240
CH_Matrix_Classes::Real QPget_lower_bound()
returns the current lower bound on the optimal value (if feasibility is good enough) ...
Definition: QPSolver.hxx:300
virtual CH_Matrix_Classes::Matrix & add_Hx(const CH_Matrix_Classes::Matrix &x, CH_Matrix_Classes::Matrix &outplusHx, CH_Matrix_Classes::Real alpha=1.) const =0
add to outplusHx and return this
CH_Matrix_Classes::Integer dim
dimension of the y ground set
Definition: QPSolver.hxx:130
std::ostream & QPprint_statistics(std::ostream &out, int=0)
currently it does nothing
Definition: QPSolver.hxx:336
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
Header declaring the classes ConicBundle::QPSolverBasicInterface, ConicBundle::CentralPathPoint, ConicBundle::QPSolverBasicStructures.
int QPget_solution(CH_Matrix_Classes::Real &augval_lb, CH_Matrix_Classes::Real &augval_ub, CH_Matrix_Classes::Matrix &new_point, CH_Matrix_Classes::Real &gsaggr_offset, CH_Matrix_Classes::Matrix &gsaggr_gradient)
retrieve the solution produced (see Abstract interface for qp solvers)
Header declaring the class ConicBundle::LPGroundsetModification.
Matrix class for integral values of type Integer
Definition: indexmat.hxx:195
AffineFunctionTransformation preproc_aft
the transformation of the bundle
Definition: QPSolver.hxx:169
QPProblemData original_data
collects the original problem data and the data describing the quadratic costs
Definition: QPSolver.hxx:161
CH_Matrix_Classes::Indexmatrix rhsubindex
indices i with (Gy)(i) upper bounded (sorted increasingly, used for slacks, equations are not listed)...
Definition: QPSolver.hxx:139
CH_Matrix_Classes::Real QPget_gamma() const
QP-sover-interface routine for constant cost term.
Definition: QPSolver.hxx:231
const CH_Matrix_Classes::Matrix & get_uby() const
returns the upper bounds on y
Definition: QPSolver.hxx:379
bool QPboxconstrained(const CH_Matrix_Classes::Matrix *&lb, const CH_Matrix_Classes::Matrix *&ub, const CH_Matrix_Classes::Indexmatrix *&lbind, const CH_Matrix_Classes::Indexmatrix *&ubind) const
return true if only box constraints are present and return the present box constraints ...
Definition: QPSolver.hxx:403
BundleProxObject * Hp
points to the quadratic cost matrix inside ensure_feasibility() and candidate(), otherwise ==NULL ...
Definition: QPSolver.hxx:148
CH_Matrix_Classes::Integer rowdim() const
number of linear constraints
Definition: QPSolver.hxx:373
CH_Matrix_Classes::Matrix lby
lower bounds on y, same dim as y
Definition: QPSolver.hxx:131
CH_Matrix_Classes::Indexmatrix ubindex
indices i with y(i) upper bounded (sorted increasingly)
Definition: QPSolver.hxx:134
CH_Matrix_Classes::Integer QPget_xdim() const
QP-solver-interface routine, returns primal dimension (length of y)
Definition: QPSolver.hxx:219
bool QPprefer_UQPSolver(QPSolverProxObject *) const
returns true if, for the current constraints and the requested ProxObject, it might be better to use ...
CH_Matrix_Classes::Matrix & QPadd_Ax(const CH_Matrix_Classes::Matrix &xin, CH_Matrix_Classes::Matrix &outplusAx) const
QP-solver-interface routine for adding constraint matrix times vector.
Definition: QPSolver.hxx:258
provides the basic variables and implements basic routines for the primal dual interior point solver ...
Definition: QPSolverBasicStructures.hxx:304
in order to pass parameters to a customized QPSolverObject, derive the parameters from this object; n...
Definition: QPSolverObject.hxx:46
int determine_indices(QPProblemData &qpd)
given lby,uby,rhslb,rhsub compute lbindex,ubindex,rhslbindex,rhsubindex
conic bundle method solver for sum of convex functions. See the ConicBundle_Manual for a quick introd...
Definition: CBSolver.hxx:22
CH_Matrix_Classes::Matrix rhsub
right hand side upper bounds
Definition: QPSolver.hxx:137
CH_Matrix_Classes::Indexmatrix preproc_indices
the sequence of original non fixed indices used in preproc_data; dimension is (0,0) if not initialize...
Definition: QPSolver.hxx:168
base class for uniform use of WARNINGS and ERRORS (at some point in time)
Definition: CBout.hxx:30
int solve(BundleProxObject *Hp, const CH_Matrix_Classes::Matrix &c, CH_Matrix_Classes::Real gamma, CH_Matrix_Classes::Real lowerbound, CH_Matrix_Classes::Real upperbound, CH_Matrix_Classes::Real relprec, CH_Matrix_Classes::Real skip_factor)
solve the quadratic problem for the given cost function and precision (without cutting model...
int QPensure_feasibility(CH_Matrix_Classes::Matrix &y, bool &ychanged, QPSolverProxObject *inHp, CH_Matrix_Classes::Real relprec=1e-10)
makes y feasible if not so, see Groundset::ensure_feasibility()
CH_Matrix_Classes::Real dual_infeasibility_eps
dual infeasibility termination parameter
Definition: QPSolver.hxx:191
CH_Matrix_Classes::Real gamma
constant offset for QP-subproblems
Definition: QPSolver.hxx:150
int mfile_data(std::ostream &out) const
output the data describing the QP in m-file style
QPProblemData * qp_data
either points to original_data or to fixing_data
Definition: QPSolver.hxx:172
const CH_Matrix_Classes::Indexmatrix & get_rhslbind() const
returns the indices with constraint lower bound slacks
Definition: QPSolver.hxx:397
bool QPsupports_yfixing()
yfixing is currently not supported, this returns false.
Definition: QPSolver.hxx:291
CH_Matrix_Classes::Real upper_bound_gap_eps
distance to upper bound termination parameter
Definition: QPSolver.hxx:193
bool QPconstrained() const
returns false if the feasible set is the entire space (unconstrained optimization), true otherwise.
Definition: QPSolver.hxx:369
GroundsetModification * QPstart_modification()
return a new modification object on the heap that is initialized for modification of *this ...
Definition: QPSolver.hxx:340
const CH_Matrix_Classes::Matrix & QPget_ub() const
QP-solver-interface routine for variable upper bounds.
Definition: QPSolver.hxx:249
CH_Matrix_Classes::Matrix y
dual variables to the affine constraints
Definition: QPSolverBasicStructures.hxx:310
int preprocess_data(const CH_Matrix_Classes::Matrix &center_y, CH_Matrix_Classes::Indexmatrix *yfixed, bool &no_changes)
initialize preproc_data for
const CH_Matrix_Classes::Matrix & get_lby() const
returns the lower bounds on y
Definition: QPSolver.hxx:376
int QPapply_modification(const GroundsetModification &mdf)
groundset changes are communicated to the solver here
void set_cbout(const CBout *cb, int incr=-1)
set output settings
Definition: QPSolver.hxx:422
Matrix class for real values of type Real
Definition: matrix.hxx:74
CH_Matrix_Classes::Matrix preproc_fixedval
if fixed it gives the value the coordinate is fixed to, otherwise the value is zero ...
Definition: QPSolver.hxx:167
const CH_Matrix_Classes::Indexmatrix & get_ubindex() const
returns the indices of variable lower bounds < ConicBundle::CB_plus_infinity
Definition: QPSolver.hxx:385
Collects modifications for the linearly constrained LPGroundset for appending, deleting or reassignin...
Definition: LPGroundsetModification.hxx:32
QPSolver(CBout *cb=0, int cbinc=-1)
default constructor
Definition: QPSolver.hxx:273
const CH_Matrix_Classes::Matrix & QPget_rhslb() const
QP-sover-interface routine for constraint lower bounds.
Definition: QPSolver.hxx:234
std::ostream * out
not output at all if out==0, otherwise use this output stream
Definition: CBout.hxx:33
CH_Matrix_Classes::Matrix c
linear cost term for QP-subproblems
Definition: QPSolver.hxx:149
Matrix class of sparse matrices with real values of type Real
Definition: sparsmat.hxx:74
CH_Matrix_Classes::Sparsemat A
feasible set is lby<=y<=uby with rhslb<=Ay<=rhsub
Definition: QPSolver.hxx:135
CH_Matrix_Classes::Indexmatrix lbindex
indices i with y(i) lower bounded (sorted increasingly)
Definition: QPSolver.hxx:133
int QPset_parameters(QPSolverParametersObject *params)
check whether the parameters are QPSolverParameters and set them if so
Definition: QPSolver.hxx:282
std::map< MinorantPointer, MinorantPointer > preproc_bundle_projection
stores the transformed minorants of the bundle
Definition: QPSolver.hxx:170
const CH_Matrix_Classes::Sparsemat & get_A() const
returns the constraint matrix of the feasible set
Definition: QPSolver.hxx:388
const CH_Matrix_Classes::Indexmatrix & QPget_lbind() const
QP-solver-interface routine for indices of variable lower bounds > ConicBundle::CB_minus_infinity.
Definition: QPSolver.hxx:252
this class facilitates switching between original data and preprocessed data that removes fixed varia...
Definition: QPSolver.hxx:125
const CH_Matrix_Classes::Matrix & get_rhsub() const
returns the constraint upper bounds
Definition: QPSolver.hxx:394
CH_Matrix_Classes::Integer QPget_ydim() const
QP-solver-interface routine, returns primal dimension (length of y)
Definition: QPSolver.hxx:221
virtual CH_Matrix_Classes::Real QPget_dualval() const
after QPIsolve, retrieve the dual objective value (quadratic and dual variables)
Definition: QPSolverBasicStructures.hxx:481
Integer rowdim() const
returns the row dimension
Definition: indexmat.hxx:321
const CH_Matrix_Classes::Indexmatrix & QPget_ubind() const
QP-solver-interface routine for indices of variable upper < ConicBundle::CB_plus_infinity.
Definition: QPSolver.hxx:255
CH_Matrix_Classes::Matrix groundset_c
linear cost term of the groundset
Definition: QPSolver.hxx:152
CH_Matrix_Classes::Matrix uby
upper bounds on y, same dim as y
Definition: QPSolver.hxx:132
const CH_Matrix_Classes::Indexmatrix & get_lbindex() const
returns the indices of variable lower bounds > ConicBundle::CB_minus_infinity
Definition: QPSolver.hxx:382
int QPupdate(const CH_Matrix_Classes::Matrix &center_y, CH_Matrix_Classes::Real lower_bound, CH_Matrix_Classes::Real upper_bound, CH_Matrix_Classes::Real relprec, QPSolverProxObject *Hp, const MinorantPointer &gs_aggr, CH_Matrix_Classes::Indexmatrix *yfixed, const MinorantPointer &delta_gs_aggr, const CH_Matrix_Classes::Indexmatrix &delta_index)
solve the bundle subproblem for updated box multipliers so that precision requirements are met (see A...
const CH_Matrix_Classes::Matrix & QPget_rhsub() const
QP-sover-interface routine for constraint upper bounds.
Definition: QPSolver.hxx:237
Indexmatrix & genmult(const Indexmatrix &A, const Indexmatrix &B, Indexmatrix &C, Integer alpha=1, Integer beta=0, int atrans=0, int btrans=0)
returns C=beta*C+alpha*A*B, where A and B may be transposed; C must not be equal to A and B; if beta=...
Collects modifications for the unconstrained Groundset for appending, deleting or reassigning variabl...
Definition: GroundsetModification.hxx:32
const CH_Matrix_Classes::Matrix & get_rhslb() const
returns the constraint lower bounds
Definition: QPSolver.hxx:391
const CH_Matrix_Classes::Matrix & QPget_c() const
QP-sover-interface routine for linear cost term.
Definition: QPSolver.hxx:228
CH_Matrix_Classes::Real primal_infeasibility_eps
primal infeasibility termination parameter
Definition: QPSolver.hxx:190
QPProblemData preproc_data
collects the preprocessed problem data (some fixed variables may be eliminated) and the data describi...
Definition: QPSolver.hxx:164
CH_Matrix_Classes::Real groundset_gamma
constant offset of the groundset
Definition: QPSolver.hxx:153
int QPsolve(const CH_Matrix_Classes::Matrix &center_y, CH_Matrix_Classes::Real lower_bound, CH_Matrix_Classes::Real upper_bound, CH_Matrix_Classes::Real relprec, QPSolverProxObject *Hp, const MinorantPointer &gs_aggr, CH_Matrix_Classes::Indexmatrix *yfixed)
solve the current bundle subproblem so that precision requirements are met (see Abstract interface fo...
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
Integer rowdim() const
returns the row dimension
Definition: sparsmat.hxx:199
points to MinorantUseData that may be shared by many and allows computations with Minorants ...
Definition: MinorantPointer.hxx:34
CH_Matrix_Classes::Indexmatrix rhslbindex
indices i with (Gy)(i) lower bounded (sorted increasingly; used for slacks, equations are not listed)...
Definition: QPSolver.hxx:138
CH_Matrix_Classes::Matrix rhslb
right hand side lower bounds
Definition: QPSolver.hxx:136
CH_Matrix_Classes::Matrix & QPadd_Aty(const CH_Matrix_Classes::Matrix &yin, CH_Matrix_Classes::Matrix &outplusAty) const
QP-solver-interface routine for adding transposed constraint matrix times vector. ...
Definition: QPSolver.hxx:262
virtual void set_cbout(const CBout *cb, int incr=-1)
Specifies the output level relative to the given CBout class.
Header declaring the class ConicBundle::Groundset.
void QPclear()
(re)initialize to empty
in order to pass a ConicBundle::BundleProxObject, see Quadratic Proximal Terms, to a custzomized QPSo...
Definition: QPSolverObject.hxx:55
virtual bool QPsupports_updates()
return true iff the code supports QPupdate(), i.e., it supports external updates of the groundset agg...
Definition: QPSolver.hxx:296
CH_Matrix_Classes::Matrix & QPadd_Qx(const CH_Matrix_Classes::Matrix &xin, CH_Matrix_Classes::Matrix &outplusQx) const
QP-solver-interface routine for adding quadratic matrix times vector.
Definition: QPSolver.hxx:224