38 const double gain_position,
39 const double gain_velocity,
40 const double gain_acceleration,
41 const double gain_jerk,
43 const bool obj_computation_on_,
44 const unsigned int max_added_constraints_num_,
45 const bool constraint_removal_on_) :
87 const double h_initial_,
89 const double* zref_x_,
90 const double* zref_y_,
107 for (
int i = 0, cind = 0; i <
N; ++i)
109 double cosR = cos(angle[i]);
110 double sinR = sin(angle[i]);
142 const double *x_coord,
143 const double *y_coord,
144 const double *init_state,
145 const bool tilde_state,
149 form_init_fp_tilde<problem_parameters>(*
this, x_coord, y_coord, init_state, tilde_state,
X);
164 int activated_var_num = -1;
168 for (
unsigned int i = 0; i <
constraints.size(); ++i)
180 if ( d_constr < -
tol )
182 const double t = (c.
lb - constr)/d_constr;
186 activated_var_num = i;
190 else if ( d_constr >
tol )
192 const double t = (c.
ub - constr)/d_constr;
196 activated_var_num = i;
202 if (activated_var_num != -1)
209 return (activated_var_num);
228 double min_lambda = -
tol;
229 int ind_exclude = -1;
232 for (
unsigned int i = 0; i <
active_set.size(); ++i)
234 if (lambda[i] *
active_set[i].sign < min_lambda)
241 if (ind_exclude != -1)
247 return (ind_exclude);
260 for (
int i = 0; i <
N; ++i)
297 if (activated_var_num != -1)
312 if (ind_exclude == -1)
326 for (
int i = 0; i <
N; ++i)
356 const double X_copy[6] = {
X[i],
X[i+1],
X[i+2],
X[i+3],
X[i+4],
X[i+5]};
359 obj_pos += X_copy[0]*X_copy[0] + X_copy[3]*X_copy[3];
360 obj_vel += X_copy[1]*X_copy[1] + X_copy[4]*X_copy[4];
361 obj_acc += X_copy[2]*X_copy[2] + X_copy[5]*X_copy[5];
366 obj_jerk +=
X[i] *
X[i] +
X[i+1] *
X[i+1];
369 return (0.5*(obj_pos/
i2Q[0] + obj_vel/
i2Q[1] + obj_acc/
i2Q[2] + obj_jerk/
i2P));
bool constraint_removal_on
#define SMPC_NUM_STATE_VAR
Number of state variables.
void set_state_parameters(const double *, const double *, const double)
Initializes quadratic problem.
void up_resolve(const AS::problem_parameters &, const vector< AS::constraint > &, const double *, double *)
A wrapper around private functions, which update Cholesky factor and resolve the system.
vector< AS::constraint > active_set
A set of active constraints.
double coef_y
Coefficients.
#define SMPC_NUM_VAR
Total number of variables.
double coef_x
Coefficients.
unsigned int max_added_constraints_num
int choose_excl_constr(const double *)
Selects a constraint for removal from active set.
unsigned int active_set_size
double compute_obj()
Compute value of the objective function.
A set of problem parameters.
void form_init_fp(const double *, const double *, const double *, const bool, double *)
Generates an initial feasible point.
#define SMPC_NUM_CONTROL_VAR
Number of control variables.
Defines constraints associated with states of the system.
unsigned int removed_constraints_num
qp_as(const int N_, const double, const double, const double, const double, const double, const bool, const unsigned int, const bool)
Constructor: initialization of the constant parameters.
void solve(const AS::problem_parameters &, const double *, double *)
Determines feasible descent direction.
int ind
Index of the first element of a state in the vector of states.
unsigned int added_constraints_num
void solve(vector< double > &)
Solve QP problem.
double * get_lambda(const AS::problem_parameters &)
int check_blocking_constraints()
Checks for blocking constraints.
AS::chol_solve chol
An instance of AS::chol_solve class.
vector< AS::constraint > constraints
Vector of constraints.
void down_resolve(const AS::problem_parameters &, const vector< AS::constraint > &, const int, const double *, double *)
A wrapper around private functions, which downdate Cholesky factor and resolve the system.
void set_parameters(const double *, const double *, const double, const double *, const double *, const double *, const double *, const double *)
Initializes quadratic problem.