37 icL =
new double*[N*2];
39 for(
int i = 0; i < N*2; ++i)
82 double i2H = ppar.
i2Q[0];
83 int first_num = c.
ind;
87 memset(row, 0, ic_len *
sizeof(
double));
91 row[first_num] = -i2H * c.
coef_x;
92 row[first_num + 3] = -i2H * c.
coef_y;
97 row[first_num + 6] = i2H * c.
coef_x;
98 row[first_num + 9] = i2H * c.
coef_y;
136 s_nu[i+1] = -s_nu[i+1];
137 s_nu[i+2] = -s_nu[i+2];
138 s_nu[i+3] = -s_nu[i+3];
139 s_nu[i+4] = -s_nu[i+4];
140 s_nu[i+5] = -s_nu[i+5];
178 const vector <AS::constraint>& active_set,
182 int ic_num = active_set.size()-1;
187 resolve (ppar, active_set, x, dx);
206 double *new_row =
icL[ic_num];
227 double tmp_copy_el[6] = {new_row[i],
235 new_row[last_num] -= tmp_copy_el[0] * tmp_copy_el[0]
236 + tmp_copy_el[1] * tmp_copy_el[1]
237 + tmp_copy_el[2] * tmp_copy_el[2]
238 + tmp_copy_el[3] * tmp_copy_el[3]
239 + tmp_copy_el[4] * tmp_copy_el[4]
240 + tmp_copy_el[5] * tmp_copy_el[5];
244 for (j = 0; j < ic_num; ++j)
246 new_row_end[j] -= tmp_copy_el[0] *
icL[j][i]
247 + tmp_copy_el[1] *
icL[j][i+1]
248 + tmp_copy_el[2] *
icL[j][i+2]
249 + tmp_copy_el[3] *
icL[j][i+3]
250 + tmp_copy_el[4] *
icL[j][i+4]
251 + tmp_copy_el[5] *
icL[j][i+5];
259 new_row[i] /=
icL[k][i];
260 double tmp_copy_el = new_row[i];
265 new_row[last_num] -= tmp_copy_el * tmp_copy_el;
267 for (j = k+1; j < ic_num; ++j)
269 new_row_end[j] -= tmp_copy_el *
icL[j][i];
274 new_row[last_num] = sqrt(new_row[last_num]);
296 const int first_num = c.
ind;
298 double zn = -x[first_num] * c.
coef_x 299 -x[first_num+3] * c.
coef_y;
302 memmove (
nu,
z, zind *
sizeof(
double));
303 for (
int i = first_num; i < zind; ++i)
305 zn -=
z[i] *
icL[ic_num][i];
307 nu[zind] =
z[zind] = zn/
icL[ic_num][zind];
324 const vector <AS::constraint>& active_set,
329 const int nW = active_set.size();
332 for (i = nW-1; i >= 0; --i)
335 nu[last_el_num] /=
icL[i][last_el_num];
337 for (
int j = active_set[i].ind; j < last_el_num; ++j)
339 nu[j] -=
nu[last_el_num] *
icL[i][j];
368 const double i2Q0 = ppar.
i2Q[0];
369 for (i = 0; i < nW; ++i)
372 dx[c.
ind] -= i2Q0 * c.
coef_x * lambda[i];
373 dx[c.
ind+3] -= i2Q0 * c.
coef_y * lambda[i];
393 const vector <AS::constraint>& active_set,
394 const int ind_exclude,
398 const int nW = active_set.size();
404 for (
int i = nW; i > ind_exclude; --i)
407 double zn =
z[zind] *
icL[i][zind];
410 for (
int j = last_el_ind; j < zind; ++j)
412 zn +=
z[j] *
icL[i][j];
416 z[last_el_ind] = z_tmp;
420 downdate (ppar, nW, ind_exclude, x);
424 for (
int i = ind_exclude; i < nW; i++)
431 for (
int j = last_el_ind; j < zind; j++)
433 zn -=
z[j] *
icL[i][j];
435 z[zind] = zn/
icL[i][zind];
441 resolve (ppar, active_set, x, dx);
469 const int ind_exclude,
473 double * downdate_row =
icL[ind_exclude];
474 for (
int i = ind_exclude + 1; i < nW + 1; i++)
478 icL[nW] = downdate_row;
481 for (
int i = ind_exclude; i < nW; i++)
484 double *cur_el = &
icL[i][el_index];
485 double x1 = cur_el[0];
486 double x2 = cur_el[1];
491 if (abs(x2) >= abs(x1))
494 sinT = 1/sqrt(1 + t*t);
500 cosT = 1/sqrt(1 + t*t);
506 cur_el[0] = cosT*x1 + sinT*x2;
511 double sign = copysign(1, cur_el[0]);
512 cur_el[0] = fabs(cur_el[0]);
515 for (
int j = i + 1; j < nW; j++)
517 x1 =
icL[j][el_index];
518 x2 =
icL[j][el_index + 1];
520 icL[j][el_index] = sign * (cosT*x1 + sinT*x2);
521 icL[j][el_index + 1] = -sinT*x1 + cosT*x2;
#define SMPC_NUM_STATE_VAR
Number of state variables.
void form_i2HETx(const problem_parameters &, const double *, double *)
Forms i2H * E' * x.
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.
void update(const AS::problem_parameters &, const AS::constraint &, const int)
Adds a row corresponding to some inequality constraint to L, see 'pCholUpAlg'.
double coef_y
Coefficients.
int cind
The sequential number of the constraint.
void resolve(const AS::problem_parameters &, const vector< AS::constraint > &, const double *, double *)
Determines feasible descent direction with respect to added inequality constraints.
#define SMPC_NUM_VAR
Total number of variables.
void form_Ex(const problem_parameters &, const double *, double *)
Forms E*x.
double coef_x
Coefficients.
AS::matrix_E E
matrix of equality AS::constraints
void form_sa_row(const AS::problem_parameters &, const AS::constraint &, const int, double *)
Forms row vector 's_a' (pCholUp).
A set of problem parameters.
Defines constraints associated with states of the system.
double ** icL
L for inequality AS::constraints.
void form(const problem_parameters &)
Builds matrix L.
void solve(const AS::problem_parameters &, const double *, double *)
Determines feasible descent direction.
void update_z(const AS::problem_parameters &, const AS::constraint &, const int, const double *)
Adjust vector 'z' after update.
int ind
Index of the first element of a state in the vector of states.
double * icL_mem
All lines of icL are stored in one chunk of memory.
double * nu
Vector of Lagrange multipliers.
AS::matrix_ecL ecL
L for equality AS::constraints.
void solve_forward(const int, double *, const int start_ind=0) const
Solve system ecL * x = b using forward substitution.
void downdate(const AS::problem_parameters &, const int, const int, const double *)
Delete a line from icL, see page 'pCholDown'.
double * get_lambda(const AS::problem_parameters &)
void solve_backward(const int, double *) const
Solve system ecL' * x = b using backward substitution.
chol_solve(const int)
Constructor.
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.