Skip to content

Commit

Permalink
fix Mehrotra solver for QPs without ineaquality constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
e-arnold committed Feb 25, 2014
1 parent 80001a0 commit 62a37d6
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 1 deletion.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2014-02-25 <e-arnold>

* hqp/Hqp_IpsMehrotra.C:
- fix treatment of QP without inequality constraints

2014-02-19 <rfranke>

* configure.in, configure, hqp/Makefile.in:
Expand Down
59 changes: 58 additions & 1 deletion hqp/Hqp_IpsMehrotra.C
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,64 @@ void Hqp_IpsMehrotra::step()
Real alpha_aff, alpha_corr, mu_aff, mu, sigma, zmin, wmin, fpd, mu_pl;
int code, mod_terlaky = 1;

if ( ( v_min(_z, &izmin) <= 0.0 ) || ( v_min(_w, &iwmin) <= 0.0 ) )
// solve a program without inequality constraints

if ( _m == 0 ) {
sp_mv_symmlt(_qp->Q, _qp->x, _r1);
v_add(_r1, _qp->c, _r1);
sp_vm_mltadd(_r1, _y, _qp->A, -1.0, _r1);
sp_mv_mlt(_qp->A, _qp->x, _r2);
v_add(_r2, _qp->b, _r2);
sv_mlt(-1.0, _r2, _r2); //-
v_resize(_r3, 0);
v_resize(_r4, 0);
// sv_mlt(-1.0, _r2, _r2); //-
#ifdef m_catch
m_catch(E_SING,
// try
_matrix->factor(_qp, _z, _w);
residuum =
_matrix->solve(_qp, _z, _w,
_r1, _r2, _r3, _r4, _dx, _dy, _dz, _dw),
// catch(E_SING)
if ( _logging )
printf("\nHqp_Degenerate: QP without inequality constraints\n");
_result = Hqp_Degenerate;
return);
#else
_matrix->factor(_qp, _z, _w);
if ((code = setjmp(restart)) != 0) {
set_err_flag(EF_EXIT); // avoid recursive error calls
if (code == E_SING) {
_result = Hqp_Degenerate;

if ( _logging )
printf("\nHqp_Degenerate: QP without inequality constraints\n");
return;
}
else
error(code, "Hqp_IpsMehrotra::step");
}
else {
# ifdef DEBUG
set_err_flag(EF_JUMP);
# else
set_err_flag(EF_SILENT);
# endif
}
residuum = _matrix->solve(_qp, _z, _w,
_r1, _r2, _r3, _r4, _dx, _dy, _dz, _dw);
#endif
v_add(_qp->x, _dx, _qp->x);
v_add(_y, _dy, _y);
_iter++;
_result = Hqp_Optimal;
return;
}

// solve a program with inequality constraints

if ( ( v_min(_z, &izmin) <= 0.0 ) || ( v_min(_w, &iwmin) <= 0.0 ) )
printf("Should never occure: min(_z)=%g, min(_w)=%g\n",
_z->ve[izmin], _w->ve[iwmin]);

Expand Down

0 comments on commit 62a37d6

Please sign in to comment.