QLD.h
Go to the documentation of this file.
1 /*
2  * Copyright 2012-2020 CNRS-UM LIRMM, CNRS-AIST JRL
3  */
4 
5 #pragma once
6 
7 #include "QLDDirect.h"
8 
9 namespace Eigen
10 {
11 
15 class QLD : public QLDDirect
16 {
17 public:
22 
26  EIGEN_QLD_API QLD(int nrvar, int nreq, int nrineq, int ldq = -1, bool verbose = false);
27 
36  EIGEN_QLD_API void problem(int nrvar, int nreq, int nrineq, int ldq = -1);
37 
48  EIGEN_QLD_API const VectorXd & multipliers() const;
49 
76  template<typename MatObj,
77  typename VecObj,
78  typename MatEq,
79  typename VecEq,
80  typename MatIneq,
81  typename VecIneq,
82  typename VecVar>
83  bool solve(const MatrixBase<MatObj> & Q,
84  const MatrixBase<VecObj> & c,
85  const MatrixBase<MatEq> & Aeq,
86  const MatrixBase<VecEq> & beq,
87  const MatrixBase<MatIneq> & Aineq,
88  const MatrixBase<VecIneq> & bineq,
89  const MatrixBase<VecVar> & xl,
90  const MatrixBase<VecVar> & xu,
91  bool isDecomp = false,
92  double eps = 1e-12);
93 
94 private:
95  MatrixXd A_;
96  VectorXd B_;
97 };
98 
99 template<typename MatObj,
100  typename VecObj,
101  typename MatEq,
102  typename VecEq,
103  typename MatIneq,
104  typename VecIneq,
105  typename VecVar>
106 inline bool QLD::solve(const MatrixBase<MatObj> & Q,
107  const MatrixBase<VecObj> & c,
108  const MatrixBase<MatEq> & Aeq,
109  const MatrixBase<VecEq> & beq,
110  const MatrixBase<MatIneq> & Aineq,
111  const MatrixBase<VecIneq> & bineq,
112  const MatrixBase<VecVar> & xl,
113  const MatrixBase<VecVar> & xu,
114  bool isDecomp,
115  double eps)
116 {
117  assert(Aeq.rows() == beq.rows()); // check equality size
118  assert(Aeq.cols() == A_.cols());
119  assert(Aineq.rows() == bineq.rows()); // check inequality size
120  assert(Aineq.cols() == A_.cols());
121 
122  int nreq = int(beq.rows());
123  int nrineq = int(bineq.rows());
124 
125  A_.topRows(nreq) = -Aeq;
126  A_.middleRows(nreq, nrineq) = -Aineq;
127 
128  B_.head(nreq) = beq;
129  B_.segment(nreq, nrineq) = bineq;
130 
131  return QLDDirect::solve(Q, c, A_.topRows(nreq + nrineq), B_.head(nreq + nrineq), xl, xu, nreq, isDecomp, eps);
132 }
133 
134 } // namespace Eigen
A lightweight wrapper of the ql algorithm by Professor Schittkowski. It handles the workspace memory ...
Definition: QLDDirect.h:24
bool solve(const MatrixBase< MatObj > &Q, const MatrixBase< VecObj > &c, const MatrixBase< MatConstr > &A, const MatrixBase< VecConstr > &b, const MatrixBase< VecVar > &xl, const MatrixBase< VecVar > &xu, int nreq, bool isDecomp=false, double eps=1e-12)
Definition: QLDDirect.h:156
EIGEN_QLD_API bool verbose() const
A wrapper of the ql algorithm by Professor Schittkowski, with some convention changes on the way the ...
Definition: QLD.h:16
EIGEN_QLD_API const VectorXd & multipliers() const
EIGEN_QLD_API QLD()
bool solve(const MatrixBase< MatObj > &Q, const MatrixBase< VecObj > &c, const MatrixBase< MatEq > &Aeq, const MatrixBase< VecEq > &beq, const MatrixBase< MatIneq > &Aineq, const MatrixBase< VecIneq > &bineq, const MatrixBase< VecVar > &xl, const MatrixBase< VecVar > &xu, bool isDecomp=false, double eps=1e-12)
Definition: QLD.h:106
EIGEN_QLD_API QLD(int nrvar, int nreq, int nrineq, int ldq=-1, bool verbose=false)
EIGEN_QLD_API void problem(int nrvar, int nreq, int nrineq, int ldq=-1)
#define EIGEN_QLD_API
Definition: eigen_qld_api.h:18
Definition: QLD.h:10