Skip to content

Commit

Permalink
check that dimension/counts from get_nlp_info are nonnegative, ref #717
Browse files Browse the repository at this point in the history
  • Loading branch information
svigerske committed Oct 23, 2023
1 parent dc0affe commit f8af317
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Interfaces/IpTNLPAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,10 @@ bool TNLPAdapter::GetSpaces(
Index n_full_x, n_full_g, nz_full_jac_g, nz_full_h;
bool retval = tnlp_->get_nlp_info(n_full_x, n_full_g, nz_full_jac_g, nz_full_h, index_style_);
ASSERT_EXCEPTION(retval, INVALID_TNLP, "get_nlp_info returned false");
ASSERT_EXCEPTION(n_full_x >= 0, INVALID_TNLP, "number of variables negative");
ASSERT_EXCEPTION(n_full_g >= 0, INVALID_TNLP, "number of constraints negative");
ASSERT_EXCEPTION(nz_full_jac_g >= 0, INVALID_TNLP, "number of nonzeros in Jacobian negative");
ASSERT_EXCEPTION(nz_full_h >= 0, INVALID_TNLP, "number of nonzeros in Hessian negative");
ASSERT_EXCEPTION(
!warm_start_same_structure_
|| (n_full_x == n_full_x_ && n_full_g == n_full_g_ && nz_full_jac_g == nz_full_jac_g_
Expand Down Expand Up @@ -3003,6 +3007,10 @@ bool TNLPAdapter::CheckDerivatives(
TNLP::IndexStyleEnum index_style;
retval = tnlp_->get_nlp_info(nx, ng, nz_jac_g, nz_hess_lag, index_style);
ASSERT_EXCEPTION(retval, INVALID_TNLP, "get_nlp_info returned false for derivative checker");
ASSERT_EXCEPTION(nx >= 0, INVALID_TNLP, "number of variables negative");
ASSERT_EXCEPTION(ng >= 0, INVALID_TNLP, "number of constraints negative");
ASSERT_EXCEPTION(nz_jac_g >= 0, INVALID_TNLP, "number of nonzeros in Jacobian negative");
ASSERT_EXCEPTION(nz_hess_lag >= 0, INVALID_TNLP, "number of nonzeros in Hessian negative");

// Obtain starting point as reference point at which derivative
// test should be performed
Expand Down

0 comments on commit f8af317

Please sign in to comment.