Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Stack Of Tasks
eiquadprog
Commits
6b7bbcd7
Verified
Commit
6b7bbcd7
authored
Mar 30, 2022
by
Justin Carpentier
Browse files
core: fix namespaces
parent
df4b0232
Pipeline
#17938
failed with stage
in 47 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
include/eiquadprog/eiquadprog-fast.hpp
View file @
6b7bbcd7
...
...
@@ -57,12 +57,12 @@
#define DEFAULT_MAX_ITER 1000
#include
"eiquadprog/eiquadprog-utils.hxx"
namespace
eiquadprog
{
namespace
solvers
{
#include
"eiquadprog/eiquadprog-utils.hxx"
/**
* Possible states of the solver.
*/
...
...
include/eiquadprog/eiquadprog-rt.hpp
View file @
6b7bbcd7
...
...
@@ -20,6 +20,7 @@
#define __eiquadprog_rt_hpp__
#include
<Eigen/Dense>
#include
"eiquadprog/eiquadprog-utils.hxx"
#define OPTIMIZE_STEP_1_2 // compute s(x) = ci^T * x + ci0
#define OPTIMIZE_COMPUTE_D // use noalias
...
...
@@ -71,7 +72,6 @@ namespace eiquadprog {
namespace
solvers
{
#include
"eiquadprog/eiquadprog-utils.hxx"
/**
* Possible states of the solver.
*/
...
...
include/eiquadprog/eiquadprog-rt.hxx
View file @
6b7bbcd7
...
...
@@ -67,7 +67,7 @@ bool RtEiquadprog<nVars, nEqCon, nIneqCon>::add_constraint(
columns. The i - 1 element of d has to be updated to h. */
cc
=
d
(
j
-
1
);
ss
=
d
(
j
);
h
=
distance
(
cc
,
ss
);
h
=
utils
::
distance
(
cc
,
ss
);
if
(
h
==
0.0
)
continue
;
d
(
j
)
=
0.0
;
...
...
@@ -162,7 +162,7 @@ void RtEiquadprog<nVars, nEqCon, nIneqCon>::delete_constraint(
for
(
j
=
qq
;
j
<
iq
;
j
++
)
{
cc
=
R
(
j
,
j
);
ss
=
R
(
j
+
1
,
j
);
h
=
distance
(
cc
,
ss
);
h
=
utils
::
distance
(
cc
,
ss
);
if
(
h
==
0.0
)
continue
;
cc
=
cc
/
h
;
...
...
@@ -249,7 +249,7 @@ RtEiquadprog_status RtEiquadprog<nVars, nEqCon, nIneqCon>::solve_quadprog(
c2
=
m_J
.
trace
();
#ifdef EIQGUADPROG_TRACE_SOLVER
print_matrix
(
"m_J"
,
m_J
,
nVars
);
utils
::
print_matrix
(
"m_J"
,
m_J
,
nVars
);
#endif
/* c1 * c2 is an estimate for cond(Hess) */
...
...
@@ -275,7 +275,7 @@ RtEiquadprog_status RtEiquadprog<nVars, nEqCon, nIneqCon>::solve_quadprog(
f_value
=
0.5
*
g0
.
dot
(
x
);
#ifdef EIQGUADPROG_TRACE_SOLVER
std
::
cerr
<<
"Unconstrained solution: "
<<
f_value
<<
std
::
endl
;
print_vector
(
"x"
,
x
,
nVars
);
utils
::
print_vector
(
"x"
,
x
,
nVars
);
#endif
STOP_PROFILER_EIQUADPROG_RT
(
PROFILE_EIQUADPROG_STEP_1_UNCONSTR_MINIM
);
...
...
@@ -293,10 +293,10 @@ RtEiquadprog_status RtEiquadprog<nVars, nEqCon, nIneqCon>::solve_quadprog(
update_r
(
R
,
r
,
d
,
iq
);
#ifdef EIQGUADPROG_TRACE_SOLVER
print_matrix
(
"R"
,
R
,
iq
);
print_vector
(
"z"
,
z
,
nVars
);
print_vector
(
"r"
,
r
,
iq
);
print_vector
(
"d"
,
d
,
nVars
);
utils
::
print_matrix
(
"R"
,
R
,
iq
);
utils
::
print_vector
(
"z"
,
z
,
nVars
);
utils
::
print_vector
(
"r"
,
r
,
iq
);
utils
::
print_vector
(
"d"
,
d
,
nVars
);
#endif
/* compute full step length t2: i.e., the minimum step in primal space s.t.
...
...
@@ -378,7 +378,7 @@ l1:
}
#ifdef EIQGUADPROG_TRACE_SOLVER
print_vector
(
"x"
,
x
,
nVars
);
utils
::
print_vector
(
"x"
,
x
,
nVars
);
#endif
/* step 1: choose a violated constraint */
for
(
i
=
nEqCon
;
i
<
iq
;
i
++
)
{
...
...
@@ -406,7 +406,7 @@ l1:
#endif
STOP_PROFILER_EIQUADPROG_RT
(
PROFILE_EIQUADPROG_STEP_1_2
);
#ifdef EIQGUADPROG_TRACE_SOLVER
print_vector
(
"s"
,
s
,
nIneqCon
);
utils
::
print_vector
(
"s"
,
s
,
nIneqCon
);
#endif
STOP_PROFILER_EIQUADPROG_RT
(
PROFILE_EIQUADPROG_STEP_1
);
...
...
@@ -454,7 +454,7 @@ l2: /* Step 2: check for feasibility and determine a new S-pair */
#ifdef EIQGUADPROG_TRACE_SOLVER
std
::
cerr
<<
"Trying with constraint "
<<
ip
<<
std
::
endl
;
print_vector
(
"np"
,
np
,
nVars
);
utils
::
print_vector
(
"np"
,
np
,
nVars
);
#endif
STOP_PROFILER_EIQUADPROG_RT
(
PROFILE_EIQUADPROG_STEP_2
);
...
...
@@ -475,11 +475,11 @@ l2a: /* Step 2a: determine step direction */
update_r
(
R
,
r
,
d
,
iq
);
#ifdef EIQGUADPROG_TRACE_SOLVER
std
::
cerr
<<
"Step direction z"
<<
std
::
endl
;
print_vector
(
"z"
,
z
,
nVars
);
print_vector
(
"r"
,
r
,
iq
+
1
);
print_vector
(
"u"
,
u
,
iq
+
1
);
print_vector
(
"d"
,
d
,
nVars
);
print_vector
(
"A"
,
A
,
iq
+
1
);
utils
::
print_vector
(
"z"
,
z
,
nVars
);
utils
::
print_vector
(
"r"
,
r
,
iq
+
1
);
utils
::
print_vector
(
"u"
,
u
,
iq
+
1
);
utils
::
print_vector
(
"d"
,
d
,
nVars
);
utils
::
print_vector
(
"A"
,
A
,
iq
+
1
);
#endif
STOP_PROFILER_EIQUADPROG_RT
(
PROFILE_EIQUADPROG_STEP_2A
);
...
...
@@ -532,9 +532,9 @@ l2a: /* Step 2a: determine step direction */
delete_constraint
(
R
,
m_J
,
A
,
u
,
iq
,
l
);
#ifdef EIQGUADPROG_TRACE_SOLVER
std
::
cerr
<<
" in dual space: "
<<
f_value
<<
std
::
endl
;
print_vector
(
"x"
,
x
,
nVars
);
print_vector
(
"z"
,
z
,
nVars
);
print_vector
(
"A"
,
A
,
iq
+
1
);
utils
::
print_vector
(
"x"
,
x
,
nVars
);
utils
::
print_vector
(
"z"
,
z
,
nVars
);
utils
::
print_vector
(
"A"
,
A
,
iq
+
1
);
#endif
STOP_PROFILER_EIQUADPROG_RT
(
PROFILE_EIQUADPROG_STEP_2C
);
goto
l2a
;
...
...
@@ -550,16 +550,16 @@ l2a: /* Step 2a: determine step direction */
#ifdef EIQGUADPROG_TRACE_SOLVER
std
::
cerr
<<
" in both spaces: "
<<
f_value
<<
std
::
endl
;
print_vector
(
"x"
,
x
,
nVars
);
print_vector
(
"u"
,
u
,
iq
+
1
);
print_vector
(
"r"
,
r
,
iq
+
1
);
print_vector
(
"A"
,
A
,
iq
+
1
);
utils
::
print_vector
(
"x"
,
x
,
nVars
);
utils
::
print_vector
(
"u"
,
u
,
iq
+
1
);
utils
::
print_vector
(
"r"
,
r
,
iq
+
1
);
utils
::
print_vector
(
"A"
,
A
,
iq
+
1
);
#endif
if
(
t
==
t2
)
{
#ifdef EIQGUADPROG_TRACE_SOLVER
std
::
cerr
<<
"Full step has taken "
<<
t
<<
std
::
endl
;
print_vector
(
"x"
,
x
,
nVars
);
utils
::
print_vector
(
"x"
,
x
,
nVars
);
#endif
/* full step has taken */
/* add constraint ip to the active set*/
...
...
@@ -567,8 +567,8 @@ l2a: /* Step 2a: determine step direction */
iaexcl
(
ip
)
=
0
;
delete_constraint
(
R
,
m_J
,
A
,
u
,
iq
,
ip
);
#ifdef EIQGUADPROG_TRACE_SOLVER
print_matrix
(
"R"
,
R
,
nVars
);
print_vector
(
"A"
,
A
,
iq
);
utils
::
print_matrix
(
"R"
,
R
,
nVars
);
utils
::
print_vector
(
"A"
,
A
,
iq
);
#endif
for
(
i
=
0
;
i
<
nIneqCon
;
i
++
)
iai
(
i
)
=
i
;
...
...
@@ -583,8 +583,8 @@ l2a: /* Step 2a: determine step direction */
}
else
iai
(
ip
)
=
-
1
;
#ifdef EIQGUADPROG_TRACE_SOLVER
print_matrix
(
"R"
,
R
,
nVars
);
print_vector
(
"A"
,
A
,
iq
);
utils
::
print_matrix
(
"R"
,
R
,
nVars
);
utils
::
print_vector
(
"A"
,
A
,
iq
);
#endif
STOP_PROFILER_EIQUADPROG_RT
(
PROFILE_EIQUADPROG_STEP_2C
);
goto
l1
;
...
...
@@ -600,10 +600,10 @@ l2a: /* Step 2a: determine step direction */
#ifdef EIQGUADPROG_TRACE_SOLVER
std
::
cerr
<<
"Partial step has taken "
<<
t
<<
std
::
endl
;
print_vector
(
"x"
,
x
,
nVars
);
print_matrix
(
"R"
,
R
,
nVars
);
print_vector
(
"A"
,
A
,
iq
);
print_vector
(
"s"
,
s
,
nIneqCon
);
utils
::
print_vector
(
"x"
,
x
,
nVars
);
utils
::
print_matrix
(
"R"
,
R
,
nVars
);
utils
::
print_vector
(
"A"
,
A
,
iq
);
utils
::
print_vector
(
"s"
,
s
,
nIneqCon
);
#endif
STOP_PROFILER_EIQUADPROG_RT
(
PROFILE_EIQUADPROG_STEP_2C
);
...
...
include/eiquadprog/eiquadprog-utils.hxx
View file @
6b7bbcd7
...
...
@@ -5,6 +5,7 @@
#include
<iostream>
namespace
eiquadprog
{
namespace
utils
{
/// Compute sqrt(a^2 + b^2)
template
<
typename
Scalar
>
inline
Scalar
distance
(
Scalar
a
,
Scalar
b
)
{
...
...
@@ -22,14 +23,14 @@ template <typename Scalar> inline Scalar distance(Scalar a, Scalar b) {
}
template
<
class
Derived
>
void
print_vector
(
const
char
*
name
,
Eigen
::
MatrixBase
<
Derived
>
&
x
,
int
n
)
{
void
print_vector
(
const
char
*
name
,
Eigen
::
MatrixBase
<
Derived
>
&
x
,
int
/*n*/
)
{
std
::
cerr
<<
name
<<
x
.
transpose
()
<<
std
::
endl
;
}
template
<
class
Derived
>
void
print_matrix
(
const
char
*
name
,
Eigen
::
MatrixBase
<
Derived
>
&
x
,
int
n
)
{
void
print_matrix
(
const
char
*
name
,
Eigen
::
MatrixBase
<
Derived
>
&
x
,
int
/*n*/
)
{
std
::
cerr
<<
name
<<
std
::
endl
<<
x
<<
std
::
endl
;
}
}
// namespace eiquadprog
}
}
// namespace eiquadprog
::utils
#endif
src/eiquadprog-fast.cpp
View file @
6b7bbcd7
...
...
@@ -69,7 +69,7 @@ bool EiquadprogFast::add_constraint(MatrixXd &R, MatrixXd &J, VectorXd &d,
columns. The i - 1 element of d has to be updated to h. */
cc
=
d
(
j
-
1
);
ss
=
d
(
j
);
h
=
distance
(
cc
,
ss
);
h
=
utils
::
distance
(
cc
,
ss
);
if
(
h
==
0.0
)
continue
;
d
(
j
)
=
0.0
;
...
...
@@ -161,7 +161,7 @@ void EiquadprogFast::delete_constraint(MatrixXd &R, MatrixXd &J, VectorXi &A,
for
(
j
=
qq
;
j
<
iq
;
j
++
)
{
cc
=
R
(
j
,
j
);
ss
=
R
(
j
+
1
,
j
);
h
=
distance
(
cc
,
ss
);
h
=
utils
::
distance
(
cc
,
ss
);
if
(
h
==
0.0
)
continue
;
cc
=
cc
/
h
;
...
...
@@ -259,7 +259,7 @@ EiquadprogFast_status EiquadprogFast::solve_quadprog(
c2
=
m_J
.
trace
();
#ifdef EIQGUADPROG_TRACE_SOLVER
print_matrix
(
"m_J"
,
m_J
,
nVars
);
utils
::
print_matrix
(
"m_J"
,
m_J
,
nVars
);
#endif
/* c1 * c2 is an estimate for cond(Hess) */
...
...
@@ -287,7 +287,7 @@ EiquadprogFast_status EiquadprogFast::solve_quadprog(
f_value
=
0.5
*
g0
.
dot
(
x
);
#ifdef EIQGUADPROG_TRACE_SOLVER
std
::
cerr
<<
"Unconstrained solution: "
<<
f_value
<<
std
::
endl
;
print_vector
(
"x"
,
x
,
nVars
);
utils
::
print_vector
(
"x"
,
x
,
nVars
);
#endif
STOP_PROFILER_EIQUADPROG_FAST
(
EIQUADPROG_FAST_STEP_1_UNCONSTR_MINIM
);
...
...
@@ -303,10 +303,10 @@ EiquadprogFast_status EiquadprogFast::solve_quadprog(
update_r
(
R
,
r
,
d
,
iq
);
#ifdef EIQGUADPROG_TRACE_SOLVER
print_matrix
(
"R"
,
R
,
iq
);
print_vector
(
"z"
,
z
,
nVars
);
print_vector
(
"r"
,
r
,
iq
);
print_vector
(
"d"
,
d
,
nVars
);
utils
::
print_matrix
(
"R"
,
R
,
iq
);
utils
::
print_vector
(
"z"
,
z
,
nVars
);
utils
::
print_vector
(
"r"
,
r
,
iq
);
utils
::
print_vector
(
"d"
,
d
,
nVars
);
#endif
/* compute full step length t2: i.e.,
...
...
@@ -391,7 +391,7 @@ l1:
START_PROFILER_EIQUADPROG_FAST
(
EIQUADPROG_FAST_STEP_1
);
#ifdef EIQGUADPROG_TRACE_SOLVER
print_vector
(
"x"
,
x
,
nVars
);
utils
::
print_vector
(
"x"
,
x
,
nVars
);
#endif
/* step 1: choose a violated constraint */
for
(
i
=
nEqCon
;
i
<
iq
;
i
++
)
{
...
...
@@ -419,7 +419,7 @@ l1:
#endif
STOP_PROFILER_EIQUADPROG_FAST
(
EIQUADPROG_FAST_STEP_1_2
);
#ifdef EIQGUADPROG_TRACE_SOLVER
print_vector
(
"s"
,
s
,
nIneqCon
);
utils
::
print_vector
(
"s"
,
s
,
nIneqCon
);
#endif
STOP_PROFILER_EIQUADPROG_FAST
(
EIQUADPROG_FAST_STEP_1
);
...
...
@@ -466,7 +466,7 @@ l2: /* Step 2: check for feasibility and determine a new S-pair */
#ifdef EIQGUADPROG_TRACE_SOLVER
std
::
cerr
<<
"Trying with constraint "
<<
ip
<<
std
::
endl
;
print_vector
(
"np"
,
np
,
nVars
);
utils
::
print_vector
(
"np"
,
np
,
nVars
);
#endif
STOP_PROFILER_EIQUADPROG_FAST
(
EIQUADPROG_FAST_STEP_2
);
...
...
@@ -487,11 +487,11 @@ l2a: /* Step 2a: determine step direction */
update_r
(
R
,
r
,
d
,
iq
);
#ifdef EIQGUADPROG_TRACE_SOLVER
std
::
cerr
<<
"Step direction z"
<<
std
::
endl
;
print_vector
(
"z"
,
z
,
nVars
);
print_vector
(
"r"
,
r
,
iq
+
1
);
print_vector
(
"u"
,
u
,
iq
+
1
);
print_vector
(
"d"
,
d
,
nVars
);
print_vector
(
"A"
,
A
,
iq
+
1
);
utils
::
print_vector
(
"z"
,
z
,
nVars
);
utils
::
print_vector
(
"r"
,
r
,
iq
+
1
);
utils
::
print_vector
(
"u"
,
u
,
iq
+
1
);
utils
::
print_vector
(
"d"
,
d
,
nVars
);
utils
::
print_vector
(
"A"
,
A
,
iq
+
1
);
#endif
STOP_PROFILER_EIQUADPROG_FAST
(
EIQUADPROG_FAST_STEP_2A
);
...
...
@@ -544,9 +544,9 @@ l2a: /* Step 2a: determine step direction */
delete_constraint
(
R
,
m_J
,
A
,
u
,
nEqCon
,
iq
,
l
);
#ifdef EIQGUADPROG_TRACE_SOLVER
std
::
cerr
<<
" in dual space: "
<<
f_value
<<
std
::
endl
;
print_vector
(
"x"
,
x
,
nVars
);
print_vector
(
"z"
,
z
,
nVars
);
print_vector
(
"A"
,
A
,
iq
+
1
);
utils
::
print_vector
(
"x"
,
x
,
nVars
);
utils
::
print_vector
(
"z"
,
z
,
nVars
);
utils
::
print_vector
(
"A"
,
A
,
iq
+
1
);
#endif
STOP_PROFILER_EIQUADPROG_FAST
(
EIQUADPROG_FAST_STEP_2C
);
goto
l2a
;
...
...
@@ -562,16 +562,16 @@ l2a: /* Step 2a: determine step direction */
#ifdef EIQGUADPROG_TRACE_SOLVER
std
::
cerr
<<
" in both spaces: "
<<
f_value
<<
std
::
endl
;
print_vector
(
"x"
,
x
,
nVars
);
print_vector
(
"u"
,
u
,
iq
+
1
);
print_vector
(
"r"
,
r
,
iq
+
1
);
print_vector
(
"A"
,
A
,
iq
+
1
);
utils
::
print_vector
(
"x"
,
x
,
nVars
);
utils
::
print_vector
(
"u"
,
u
,
iq
+
1
);
utils
::
print_vector
(
"r"
,
r
,
iq
+
1
);
utils
::
print_vector
(
"A"
,
A
,
iq
+
1
);
#endif
if
(
t
==
t2
)
{
#ifdef EIQGUADPROG_TRACE_SOLVER
std
::
cerr
<<
"Full step has taken "
<<
t
<<
std
::
endl
;
print_vector
(
"x"
,
x
,
nVars
);
utils
::
print_vector
(
"x"
,
x
,
nVars
);
#endif
/* full step has taken */
/* add constraint ip to the active set*/
...
...
@@ -579,8 +579,8 @@ l2a: /* Step 2a: determine step direction */
iaexcl
(
ip
)
=
0
;
delete_constraint
(
R
,
m_J
,
A
,
u
,
nEqCon
,
iq
,
ip
);
#ifdef EIQGUADPROG_TRACE_SOLVER
print_matrix
(
"R"
,
R
,
nVars
);
print_vector
(
"A"
,
A
,
iq
);
utils
::
print_matrix
(
"R"
,
R
,
nVars
);
utils
::
print_vector
(
"A"
,
A
,
iq
);
#endif
for
(
i
=
0
;
i
<
nIneqCon
;
i
++
)
iai
(
i
)
=
static_cast
<
VectorXi
::
Scalar
>
(
i
);
...
...
@@ -595,8 +595,8 @@ l2a: /* Step 2a: determine step direction */
}
else
iai
(
ip
)
=
-
1
;
#ifdef EIQGUADPROG_TRACE_SOLVER
print_matrix
(
"R"
,
R
,
nVars
);
print_vector
(
"A"
,
A
,
iq
);
utils
::
print_matrix
(
"R"
,
R
,
nVars
);
utils
::
print_vector
(
"A"
,
A
,
iq
);
#endif
STOP_PROFILER_EIQUADPROG_FAST
(
EIQUADPROG_FAST_STEP_2C
);
goto
l1
;
...
...
@@ -609,10 +609,10 @@ l2a: /* Step 2a: determine step direction */
#ifdef EIQGUADPROG_TRACE_SOLVER
std
::
cerr
<<
"Partial step has taken "
<<
t
<<
std
::
endl
;
print_vector
(
"x"
,
x
,
nVars
);
print_matrix
(
"R"
,
R
,
nVars
);
print_vector
(
"A"
,
A
,
iq
);
print_vector
(
"s"
,
s
,
nIneqCon
);
utils
::
print_vector
(
"x"
,
x
,
nVars
);
utils
::
print_matrix
(
"R"
,
R
,
nVars
);
utils
::
print_vector
(
"A"
,
A
,
iq
);
utils
::
print_vector
(
"s"
,
s
,
nIneqCon
);
#endif
STOP_PROFILER_EIQUADPROG_FAST
(
EIQUADPROG_FAST_STEP_2C
);
...
...
src/eiquadprog.cpp
View file @
6b7bbcd7
...
...
@@ -101,7 +101,7 @@ double solve_quadprog(LLT<MatrixXd, Lower> &chol, double c1, VectorXd &g0,
chol
.
matrixU
().
solveInPlace
(
J
);
c2
=
J
.
trace
();
#ifdef EIQGUADPROG_TRACE_SOLVER
print_matrix
(
"J"
,
J
,
n
);
utils
::
print_matrix
(
"J"
,
J
,
n
);
#endif
/* c1 * c2 is an estimate for cond(G) */
...
...
@@ -117,7 +117,7 @@ double solve_quadprog(LLT<MatrixXd, Lower> &chol, double c1, VectorXd &g0,
f_value
=
0.5
*
g0
.
dot
(
x
);
#ifdef EIQGUADPROG_TRACE_SOLVER
std
::
cerr
<<
"Unconstrained solution: "
<<
f_value
<<
std
::
endl
;
print_vector
(
"x"
,
x
,
n
);
utils
::
print_vector
(
"x"
,
x
,
n
);
#endif
/* Add equality constraints to the working set A */
...
...
@@ -128,10 +128,10 @@ double solve_quadprog(LLT<MatrixXd, Lower> &chol, double c1, VectorXd &g0,
update_z
(
z
,
J
,
d
,
iq
);
update_r
(
R
,
r
,
d
,
iq
);
#ifdef EIQGUADPROG_TRACE_SOLVER
print_matrix
(
"R"
,
R
,
iq
);
print_vector
(
"z"
,
z
,
n
);
print_vector
(
"r"
,
r
,
iq
);
print_vector
(
"d"
,
d
,
n
);
utils
::
print_matrix
(
"R"
,
R
,
iq
);
utils
::
print_vector
(
"z"
,
z
,
n
);
utils
::
print_vector
(
"r"
,
r
,
iq
);
utils
::
print_vector
(
"d"
,
d
,
n
);
#endif
/* compute full step length t2: i.e., the minimum step in primal space s.t.
...
...
@@ -165,7 +165,7 @@ double solve_quadprog(LLT<MatrixXd, Lower> &chol, double c1, VectorXd &g0,
l1:
iter
++
;
#ifdef EIQGUADPROG_TRACE_SOLVER
print_vector
(
"x"
,
x
,
n
);
utils
::
print_vector
(
"x"
,
x
,
n
);
#endif
/* step 1: choose a violated constraint */
for
(
i
=
me
;
i
<
iq
;
i
++
)
{
...
...
@@ -184,7 +184,7 @@ l1:
psi
+=
std
::
min
(
0.0
,
sum
);
}
#ifdef EIQGUADPROG_TRACE_SOLVER
print_vector
(
"s"
,
s
,
mi
);
utils
::
print_vector
(
"s"
,
s
,
mi
);
#endif
if
(
std
::
abs
(
psi
)
<=
static_cast
<
double
>
(
mi
)
*
...
...
@@ -221,7 +221,7 @@ l2: /* Step 2: check for feasibility and determine a new S-pair */
#ifdef EIQGUADPROG_TRACE_SOLVER
std
::
cerr
<<
"Trying with constraint "
<<
ip
<<
std
::
endl
;
print_vector
(
"np"
,
np
,
n
);
utils
::
print_vector
(
"np"
,
np
,
n
);
#endif
l2a:
/* Step 2a: determine step direction */
...
...
@@ -234,11 +234,11 @@ l2a: /* Step 2a: determine step direction */
update_r
(
R
,
r
,
d
,
iq
);
#ifdef EIQGUADPROG_TRACE_SOLVER
std
::
cerr
<<
"Step direction z"
<<
std
::
endl
;
print_vector
(
"z"
,
z
,
n
);
print_vector
(
"r"
,
r
,
iq
+
1
);
print_vector
(
"u"
,
u
,
iq
+
1
);
print_vector
(
"d"
,
d
,
n
);
print_vector
(
"A"
,
A
,
iq
+
1
);
utils
::
print_vector
(
"z"
,
z
,
n
);
utils
::
print_vector
(
"r"
,
r
,
iq
+
1
);
utils
::
print_vector
(
"u"
,
u
,
iq
+
1
);
utils
::
print_vector
(
"d"
,
d
,
n
);
utils
::
print_vector
(
"A"
,
A
,
iq
+
1
);
#endif
/* Step 2b: compute step length */
...
...
@@ -287,9 +287,9 @@ l2a: /* Step 2a: determine step direction */
delete_constraint
(
R
,
J
,
A
,
u
,
p
,
iq
,
l
);
#ifdef EIQGUADPROG_TRACE_SOLVER
std
::
cerr
<<
" in dual space: "
<<
f_value
<<
std
::
endl
;
print_vector
(
"x"
,
x
,
n
);
print_vector
(
"z"
,
z
,
n
);
print_vector
(
"A"
,
A
,
iq
+
1
);
utils
::
print_vector
(
"x"
,
x
,
n
);
utils
::
print_vector
(
"z"
,
z
,
n
);
utils
::
print_vector
(
"A"
,
A
,
iq
+
1
);
#endif
goto
l2a
;
}
...
...
@@ -304,16 +304,16 @@ l2a: /* Step 2a: determine step direction */
u
(
iq
)
+=
t
;
#ifdef EIQGUADPROG_TRACE_SOLVER
std
::
cerr
<<
" in both spaces: "
<<
f_value
<<
std
::
endl
;
print_vector
(
"x"
,
x
,
n
);
print_vector
(
"u"
,
u
,
iq
+
1
);
print_vector
(
"r"
,
r
,
iq
+
1
);
print_vector
(
"A"
,
A
,
iq
+
1
);
utils
::
print_vector
(
"x"
,
x
,
n
);
utils
::
print_vector
(
"u"
,
u
,
iq
+
1
);
utils
::
print_vector
(
"r"
,
r
,
iq
+
1
);
utils
::
print_vector
(
"A"
,
A
,
iq
+
1
);
#endif
if
(
t
==
t2
)
{
#ifdef EIQGUADPROG_TRACE_SOLVER
std
::
cerr
<<
"Full step has taken "
<<
t
<<
std
::
endl
;
print_vector
(
"x"
,
x
,
n
);
utils
::
print_vector
(
"x"
,
x
,
n
);
#endif
/* full step has taken */
/* add constraint ip to the active set*/
...
...
@@ -321,8 +321,8 @@ l2a: /* Step 2a: determine step direction */
iaexcl
(
ip
)
=
0
;
delete_constraint
(
R
,
J
,
A
,
u
,
p
,
iq
,
ip
);
#ifdef EIQGUADPROG_TRACE_SOLVER
print_matrix
(
"R"
,
R
,
n
);
print_vector
(
"A"
,
A
,
iq
);
utils
::
print_matrix
(
"R"
,
R
,
n
);
utils
::
print_vector
(
"A"
,
A
,
iq
);
#endif
for
(
i
=
0
;
i
<
m
;
i
++
)
iai
(
i
)
=
static_cast
<
VectorXi
::
Scalar
>
(
i
);
...
...
@@ -336,8 +336,8 @@ l2a: /* Step 2a: determine step direction */
}
else
iai
(
ip
)
=
-
1
;
#ifdef EIQGUADPROG_TRACE_SOLVER
print_matrix
(
"R"
,
R
,
n
);
print_vector
(
"A"
,
A
,
iq
);
utils
::
print_matrix
(
"R"
,
R
,
n
);
utils
::
print_vector
(
"A"
,
A
,
iq
);
#endif
goto
l1
;
}
...
...
@@ -345,20 +345,20 @@ l2a: /* Step 2a: determine step direction */
/* a patial step has taken */
#ifdef EIQGUADPROG_TRACE_SOLVER
std
::
cerr
<<
"Partial step has taken "
<<
t
<<
std
::
endl
;
print_vector
(
"x"
,
x
,
n
);
utils
::
print_vector
(
"x"
,
x
,
n
);
#endif
/* drop constraint l */
iai
(
l
)
=
static_cast
<
VectorXi
::
Scalar
>
(
l
);
delete_constraint
(
R
,
J
,
A
,
u
,
p
,
iq
,
l
);
#ifdef EIQGUADPROG_TRACE_SOLVER
print_matrix
(
"R"
,
R
,
n
);
print_vector
(
"A"
,
A
,
iq
);
utils
::
print_matrix
(
"R"
,
R
,
n
);
utils
::
print_vector
(
"A"
,
A
,
iq
);
#endif
s
(
ip
)
=
CI
.
col
(
ip
).
dot
(
x
)
+
ci0
(
ip
);
#ifdef EIQGUADPROG_TRACE_SOLVER
print_vector
(
"s"
,
s
,
mi
);
utils
::
print_vector
(
"s"
,
s
,
mi
);
#endif
goto
l2a
;
}
...
...
@@ -387,7 +387,7 @@ bool add_constraint(MatrixXd &R, MatrixXd &J, VectorXd &d, size_t &iq,
The i - 1 element of d has to be updated to h. */
cc
=
d
(
j
-
1
);
ss
=
d
(
j
);
h
=
distance
(
cc
,
ss
);
h
=
utils
::
distance
(
cc
,
ss
);
if
(
h
==
0.0
)
continue
;
d
(
j
)
=
0.0
;
...
...
@@ -465,7 +465,7 @@ void delete_constraint(MatrixXd &R, MatrixXd &J, VectorXi &A, VectorXd &u,
for
(
j
=
qq
;
j
<
iq
;
j
++
)
{
cc
=
R
(
j
,
j
);
ss
=
R
(
j
+
1
,
j
);
h
=
distance
(
cc
,
ss
);
h
=
utils
::
distance
(
cc
,
ss
);
if
(
h
==
0.0
)
continue
;
cc
=
cc
/
h
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment