Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Recursive stub generation for Python bindings ([#419](https://github.com/Simple-Robotics/proxsuite/pull/419))

### Changed
- Redefine the `load_qp` function in the Maros-Meszaros unit tests ([#433])(https://github.com/Simple-Robotics/proxsuite/pull/433)
- Change the default branch to `devel` ([#395](https://github.com/Simple-Robotics/proxsuite/pull/395))
- Change `dual_feasibility` test threshold in `sparse_maros_meszaros` unit test ([#403](https://github.com/Simple-Robotics/proxsuite/pull/403))
- replace `std::numeric_limits<T>::infinity()` by `std::numeric_limits<T>::max()` ([#413](https://github.com/Simple-Robotics/proxsuite/pull/413))
Expand Down
41 changes: 24 additions & 17 deletions test/include/maros_meszaros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ struct MarosMeszarosQp
Mat A;
Vec l;
Vec u;

bool skip = false;
};

auto
load_qp(char const* filename) -> MarosMeszarosQp
load_qp(char const* filename, bool check_size = false) -> MarosMeszarosQp
{
using Mat = MarosMeszarosQp::Mat;
using Vec = MarosMeszarosQp::Vec;
Expand All @@ -30,6 +32,8 @@ load_qp(char const* filename) -> MarosMeszarosQp
proxsuite::linalg::veg::defer([&] { Mat_Close(mat_fp); });
proxsuite::linalg::veg::unused(_mat_fp_cleanup);

bool skip = false;

auto load_mat = [&](char const* name) -> Mat {
matvar_t* mat_var = Mat_VarRead(mat_fp, name);
VEG_ASSERT(mat_var != nullptr);
Expand All @@ -44,27 +48,30 @@ load_qp(char const* filename) -> MarosMeszarosQp

isize nrows = isize(mat_var->dims[0]);
isize ncols = isize(mat_var->dims[1]);
Mat out;

auto optr = reinterpret_cast<mat_int32_t const*>(ptr->jc); // NOLINT
auto iptr = reinterpret_cast<mat_int32_t const*>(ptr->ir); // NOLINT
auto vptr = static_cast<double const*>(ptr->data); // NOLINT
if (!check_size || (nrows <= 1000 && ncols <= 1000)) {
auto optr = reinterpret_cast<mat_int32_t const*>(ptr->jc); // NOLINT
auto iptr = reinterpret_cast<mat_int32_t const*>(ptr->ir); // NOLINT
auto vptr = static_cast<double const*>(ptr->data); // NOLINT

Mat out;
out.resize(nrows, ncols);
out.reserve(ptr->nzmax);
for (isize j = 0; j < ncols; ++j) {
isize col_start = optr[j];
isize col_end = optr[j + 1];
out.resize(nrows, ncols);
out.reserve(ptr->nzmax);
for (isize j = 0; j < ncols; ++j) {
isize col_start = optr[j];
isize col_end = optr[j + 1];

for (isize p = col_start; p < col_end; ++p) {
for (isize p = col_start; p < col_end; ++p) {

isize i = iptr[p];
double v = vptr[p];
isize i = iptr[p];
double v = vptr[p];

out.insert(i, j) = v;
out.insert(i, j) = v;
}
}
} else {
skip = true;
}

return out;
};

Expand All @@ -86,8 +93,8 @@ load_qp(char const* filename) -> MarosMeszarosQp
};

return {
filename, load_mat("P"), load_vec("q"),
load_mat("A"), load_vec("l"), load_vec("u"),
filename, load_mat("P"), load_vec("q"), load_mat("A"),
load_vec("l"), load_vec("u"), skip,
};
}

Expand Down
7 changes: 3 additions & 4 deletions test/src/dense_maros_meszaros.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,20 +90,19 @@ TEST_CASE("dense maros meszaros using the api")
T elapsed_time = 0.0;

for (auto const* file : files) {
auto qp = load_qp(file);
auto qp = load_qp(file, true);
isize n = qp.P.rows();
isize n_eq_in = qp.A.rows();

const bool skip = n > 1000 || n_eq_in > 1000;
if (skip) {
if (qp.skip) {
std::cout << " path: " << qp.filename << " n: " << n
<< " n_eq+n_in: " << n_eq_in << " - skipping" << std::endl;
} else {
std::cout << " path: " << qp.filename << " n: " << n
<< " n_eq+n_in: " << n_eq_in << std::endl;
}

if (!skip) {
if (!qp.skip) {

auto preprocessed = preprocess_qp(qp);
auto& H = preprocessed.H;
Expand Down
7 changes: 3 additions & 4 deletions test/src/sparse_maros_meszaros.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,20 +117,19 @@ TEST_CASE("sparse maros meszaros using the API")
const T eps_abs_with_duality_gap = 1e-5;

for (auto const* file : files) {
auto qp_raw = load_qp(file);
auto qp_raw = load_qp(file, true);
isize n = qp_raw.P.rows();
isize n_eq_in = qp_raw.A.rows();

bool skip = (n > 1000 || n_eq_in > 1000);
if (skip) {
if (qp_raw.skip) {
std::cout << " path: " << qp_raw.filename << " n: " << n
<< " n_eq+n_in: " << n_eq_in << " - SKIPPING" << std::endl;
} else {
std::cout << " path: " << qp_raw.filename << " n: " << n
<< " n_eq+n_in: " << n_eq_in << std::endl;
}

if (!skip) {
if (!qp_raw.skip) {

auto preprocessed = preprocess_qp_sparse(VEG_FWD(qp_raw));
auto& H = preprocessed.H;
Expand Down
Loading