2121
2222#include < Eigen/Dense>
2323
24+ #include " eiquadprog/eiquadprog-utils.hxx"
25+
2426#define OPTIMIZE_STEP_1_2 // compute s(x) = ci^T * x + ci0
2527#define OPTIMIZE_COMPUTE_D // use noalias
2628#define OPTIMIZE_UPDATE_Z // use noalias
4850#define PROFILE_EIQUADPROG_STEP_1 " EIQUADPROG_RT STEP_1"
4951#define PROFILE_EIQUADPROG_STEP_1_1 " EIQUADPROG_RT STEP_1_1"
5052#define PROFILE_EIQUADPROG_STEP_1_2 " EIQUADPROG_RT STEP_1_2"
51- #define PROFILE_EIQUADPROG_STEP_1_UNCONSTR_MINIM " EIQUADPROG_RT STEP_1_UNCONSTR_MINIM"
53+ #define PROFILE_EIQUADPROG_STEP_1_UNCONSTR_MINIM \
54+ " EIQUADPROG_RT STEP_1_UNCONSTR_MINIM"
5255#define PROFILE_EIQUADPROG_STEP_2 " EIQUADPROG_RT STEP_2"
5356#define PROFILE_EIQUADPROG_STEP_2A " EIQUADPROG_RT STEP_2A"
5457#define PROFILE_EIQUADPROG_STEP_2B " EIQUADPROG_RT STEP_2B"
@@ -71,7 +74,6 @@ namespace eiquadprog {
7174
7275namespace solvers {
7376
74- #include " eiquadprog/eiquadprog-utils.hxx"
7577/* *
7678 * Possible states of the solver.
7779 */
@@ -118,7 +120,10 @@ class RtEiquadprog {
118120 /* *
119121 * @return The Lagrange multipliers
120122 */
121- const typename RtVectorX<nIneqCon + nEqCon>::d& getLagrangeMultipliers () const { return u; }
123+ const typename RtVectorX<nIneqCon + nEqCon>::d& getLagrangeMultipliers ()
124+ const {
125+ return u;
126+ }
122127
123128 /* *
124129 * Return the active set, namely the indeces of active constraints.
@@ -128,20 +133,24 @@ class RtEiquadprog {
128133 * is the size of the active set.
129134 * @return The set of indexes of the active constraints.
130135 */
131- const typename RtVectorX<nIneqCon + nEqCon>::i& getActiveSet () const { return A; }
136+ const typename RtVectorX<nIneqCon + nEqCon>::i& getActiveSet () const {
137+ return A;
138+ }
132139
133140 /* *
134141 * solves the problem
135142 * min. x' Hess x + 2 g0' x
136143 * s.t. CE x + ce0 = 0
137144 * CI x + ci0 >= 0
138145 */
139- RtEiquadprog_status solve_quadprog (const typename RtMatrixX<nVars, nVars>::d& Hess,
140- const typename RtVectorX<nVars>::d& g0,
141- const typename RtMatrixX<nEqCon, nVars>::d& CE,
142- const typename RtVectorX<nEqCon>::d& ce0,
143- const typename RtMatrixX<nIneqCon, nVars>::d& CI,
144- const typename RtVectorX<nIneqCon>::d& ci0, typename RtVectorX<nVars>::d& x);
146+ RtEiquadprog_status solve_quadprog (
147+ const typename RtMatrixX<nVars, nVars>::d& Hess,
148+ const typename RtVectorX<nVars>::d& g0,
149+ const typename RtMatrixX<nEqCon, nVars>::d& CE,
150+ const typename RtVectorX<nEqCon>::d& ce0,
151+ const typename RtMatrixX<nIneqCon, nVars>::d& CI,
152+ const typename RtVectorX<nIneqCon>::d& ci0,
153+ typename RtVectorX<nVars>::d& x);
145154
146155 typename RtMatrixX<nVars, nVars>::d m_J; // J * J' = Hessian
147156 bool is_inverse_provided_;
@@ -153,7 +162,8 @@ class RtEiquadprog {
153162 Eigen::LLT<typename RtMatrixX<nVars, nVars>::d, Eigen::Lower> chol_;
154163 double solver_return_;
155164
156- // / from QR of L' N, where L is Cholewsky factor of Hessian, and N is the matrix of active constraints
165+ // / from QR of L' N, where L is Cholewsky factor of Hessian, and N is the
166+ // / matrix of active constraints
157167 typename RtMatrixX<nVars, nVars>::d R;
158168
159169 // / CI*x+ci0
@@ -187,8 +197,8 @@ class RtEiquadprog {
187197 // / initialized as [1, ..., 1, .]
188198 // / if iaexcl(i)!=1 inequality constraint i cannot be added to the active set
189199 // / if adding ineq constraint i fails => iaexcl(i)=0
190- // / iaexcl(i)=0 iff ineq constraint i is linearly dependent to other active constraints
191- // / iaexcl(i)=1 otherwise
200+ // / iaexcl(i)=0 iff ineq constraint i is linearly dependent to other active
201+ // / constraints iaexcl(i)=1 otherwise
192202 typename RtVectorX<nIneqCon>::i iaexcl;
193203
194204 typename RtVectorX<nVars>::d x_old; // old value of x
@@ -199,7 +209,8 @@ class RtEiquadprog {
199209 typename RtVectorX<nVars>::d T1; // tmp vector
200210#endif
201211
202- // / size of the active set A (containing the indices of the active constraints)
212+ // / size of the active set A (containing the indices of the active
213+ // / constraints)
203214 int q;
204215
205216 // / number of active-set iterations
@@ -220,7 +231,8 @@ class RtEiquadprog {
220231 return a1 * std::sqrt (2.0 );
221232 }
222233
223- inline void compute_d (typename RtVectorX<nVars>::d& d, const typename RtMatrixX<nVars, nVars>::d& J,
234+ inline void compute_d (typename RtVectorX<nVars>::d& d,
235+ const typename RtMatrixX<nVars, nVars>::d& J,
224236 const typename RtVectorX<nVars>::d& np) {
225237#ifdef OPTIMIZE_COMPUTE_D
226238 d.noalias () = J.adjoint () * np;
@@ -229,7 +241,8 @@ class RtEiquadprog {
229241#endif
230242 }
231243
232- inline void update_z (typename RtVectorX<nVars>::d& z, const typename RtMatrixX<nVars, nVars>::d& J,
244+ inline void update_z (typename RtVectorX<nVars>::d& z,
245+ const typename RtMatrixX<nVars, nVars>::d& J,
233246 const typename RtVectorX<nVars>::d& d, int iq) {
234247#ifdef OPTIMIZE_UPDATE_Z
235248 z.noalias () = J.rightCols (nVars - iq) * d.tail (nVars - iq);
@@ -238,24 +251,31 @@ class RtEiquadprog {
238251#endif
239252 }
240253
241- inline void update_r (const typename RtMatrixX<nVars, nVars>::d& R, typename RtVectorX<nIneqCon + nEqCon>::d& r,
254+ inline void update_r (const typename RtMatrixX<nVars, nVars>::d& R,
255+ typename RtVectorX<nIneqCon + nEqCon>::d& r,
242256 const typename RtVectorX<nVars>::d& d, int iq) {
243257 r.head (iq) = d.head (iq);
244- R.topLeftCorner (iq, iq).template triangularView <Eigen::Upper>().solveInPlace (r.head (iq));
258+ R.topLeftCorner (iq, iq)
259+ .template triangularView <Eigen::Upper>()
260+ .solveInPlace (r.head (iq));
245261 }
246262
247- bool add_constraint (typename RtMatrixX<nVars, nVars>::d& R, typename RtMatrixX<nVars, nVars>::d& J,
263+ bool add_constraint (typename RtMatrixX<nVars, nVars>::d& R,
264+ typename RtMatrixX<nVars, nVars>::d& J,
248265 typename RtVectorX<nVars>::d& d, int & iq, double & R_norm);
249266
250- void delete_constraint (typename RtMatrixX<nVars, nVars>::d& R, typename RtMatrixX<nVars, nVars>::d& J,
251- typename RtVectorX<nIneqCon + nEqCon>::i& A, typename RtVectorX<nIneqCon + nEqCon>::d& u,
252- int & iq, int l);
267+ void delete_constraint (typename RtMatrixX<nVars, nVars>::d& R,
268+ typename RtMatrixX<nVars, nVars>::d& J,
269+ typename RtVectorX<nIneqCon + nEqCon>::i& A,
270+ typename RtVectorX<nIneqCon + nEqCon>::d& u, int & iq,
271+ int l);
253272};
254273
255274} /* namespace solvers */
256275} /* namespace eiquadprog */
257276
258277#include " eiquadprog/eiquadprog-rt.hxx"
259- /* --- Details -------------------------------------------------------------------- */
278+ /* --- Details
279+ * -------------------------------------------------------------------- */
260280
261281#endif /* __eiquadprog_rt_hpp__ */
0 commit comments