10 std::cout<<#var"= "<<std::endl<<var<<std::endl 22 double* x,
int x_len,
int ce_len,
int ci_len,
double eqthre,
double* ce_err,
24 int ret = ce_len + ci_len ;
25 for (
int i = 0; i < ce_len; i++) {
26 for (
int j = 0; j < x_len; j++) {
27 ce_err[i] += CE[i * x_len + j] * x[j];
30 if ( ce_err[i] < eqthre && ce_err[i] > -eqthre ) ret-- ;
32 for (
int i = 0; i < ci_len; i++) {
33 for (
int j = 0; j < x_len; j++) {
34 ci_err[i] += CI[i * x_len + j] * x[j];
37 if ( ci_err[i] > -eqthre ) ret-- ;
46 double* ci0,
double* x,
47 int x_len,
int ce_len,
int ci_len,
50 double* ret_buf,
double* ce_err,
double* ci_err) {
51 MatrixXd G_buf(x_len, x_len);
52 Eigen::VectorXd g0_buf(x_len);
53 MatrixXd CE_buf(x_len, ce_len);
54 Eigen::VectorXd ce0_buf(ce_len);
55 MatrixXd CI_buf(x_len, ci_len);
56 Eigen::VectorXd ci0_buf(ci_len);
57 Eigen::VectorXd x_buf(x_len);
59 for (
int i=0 ; i<x_len ; i++ ){
60 for (
int j=0 ; j<x_len ; j++ ){
61 G_buf(i,j) = G[i+ x_len*j] ;
70 for (
int j=0 ; j<ce_len ; j++ ){
71 CE_buf(i,j) = CE[i+ x_len*j] ;
76 for (
int j=0 ; j<ci_len ; j++ ){
77 CI_buf(i,j) = CI[i+ x_len*j] ;
94 ret_buf[0] =
solve_quadprog(G_buf, g0_buf, CE_buf, ce0_buf, CI_buf,
96 for (
int i = 0; i < x_buf.size(); i++)
99 flag =
check_constraints(CE, ce0, CI, ci0, x, x_len, ce_len, ci_len, eqthre, ce_err, ci_err);
102 std::cout <<
"[eus-eiquadprog]" << std::endl;
103 std::cout <<
" :minimized-object " 104 << ret_buf[0] << std::endl;
105 std::cout <<
" :optimal-state [";
106 for (
int i = 0; i < x_buf.size(); i++)
107 std::cout << x[i] <<
' ';
108 std::cout <<
"]" << std::endl;
110 std::cout <<
" :eq-constraint || " ;
111 for (
int i=0 ; i <ce_len ; i++ ) std::cout << ce_err[i] <<
" " ;
112 std::cout <<
"|| < " << eqthre ;
113 std::cout << std::endl ;
114 std::cout <<
" :iq-constraint [" ;
115 for (
int i=0 ; i <ci_len ; i++ ) std::cout << ci_err[i] <<
" " ;
116 std::cout <<
"] > " << -eqthre ;
117 std::cout << std::endl ;
118 std::cout <<
" :constraint-check " ;
120 std::cout << std::endl ;
double solve_quadprog(MatrixXd &G, VectorXd &g0, const MatrixXd &CE, const VectorXd &ce0, const MatrixXd &CI, const VectorXd &ci0, VectorXd &x)
double * solve_eiquadprog(double *G, double *g0, double *CE, double *ce0, double *CI, double *ci0, double *x, int x_len, int ce_len, int ci_len, double eqthre, int debug, double *ret_buf, double *ce_err, double *ci_err)
int check_constraints(double *CE, double *ce0, double *CI, double *ci0, double *x, int x_len, int ce_len, int ci_len, double eqthre, double *ce_err, double *ci_err)
int get_constraints_check_flag()