Skip to content

Commit

Permalink
Formatted
Browse files Browse the repository at this point in the history
  • Loading branch information
jajhall committed Jan 9, 2025
1 parent b66d2cf commit fdbf1ff
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 382 deletions.
3 changes: 2 additions & 1 deletion check/Avgas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
* @brief Utilities for tests with AVGAS
*/
#include "Avgas.h"
#include "lp_data/HConst.h"

#include <cassert>
#include <cstdio> // For printf

#include "lp_data/HConst.h"

const bool dev_run = false;

void Avgas::row(HighsInt row, HighsInt& num_row, HighsInt& num_row_nz,
Expand Down
65 changes: 33 additions & 32 deletions check/TestLpModification.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#include "catch.hpp"
#include "lp_data/HighsLpUtils.h"
#include "util/HighsRandom.h"
#include "util/HighsUtils.h"
#include "util/HighsTimer.h"
#include "util/HighsUtils.h"

const bool dev_run = false;
// const double inf = kHighsInf;
Expand Down Expand Up @@ -1982,71 +1982,73 @@ TEST_CASE("row-wise-get-row-time", "[highs_data]") {
return_status = h.addRow(0.0, kHighsInf, 2, index, value);
}
std::vector<double> lower;
std::vector<double> upper;
std::vector<double> upper;
HighsInt num_row = 0;
HighsInt num_nz = 0;
std::vector<HighsInt> matrix_start;
std::vector<HighsInt> matrix_index;
std::vector<double> matrix_value;
assert(h.getNumRow() == 2*dim-2);
assert(h.getNumRow() == 2 * dim - 2);
for (HighsInt i = 0; i < dim - 1; i++) {
return_status = h.getRows(i, i, num_row, lower.data(), upper.data(),
num_nz, nullptr, nullptr, nullptr);
num_nz, nullptr, nullptr, nullptr);
REQUIRE(num_row == 1);
REQUIRE(num_nz == 2);
matrix_start.resize(num_row);
matrix_index.resize(num_nz);
matrix_value.resize(num_nz);
return_status = h.getRows(i, i, num_row, lower.data(), upper.data(),
num_nz, matrix_start.data(), matrix_index.data(),
matrix_value.data());
num_nz, matrix_start.data(),
matrix_index.data(), matrix_value.data());
REQUIRE(matrix_start[0] == 0);
REQUIRE(matrix_index[0] == i+1);
REQUIRE(matrix_index[0] == i + 1);
REQUIRE(matrix_index[1] == i);
REQUIRE(matrix_value[0] == 1);
REQUIRE(matrix_value[1] == 2);

std::vector<HighsInt> set = {i, 2*dim-3};
return_status = h.getRows(2, set.data(), num_row, lower.data(), upper.data(),
num_nz, nullptr, nullptr, nullptr);
std::vector<HighsInt> set = {i, 2 * dim - 3};
return_status =
h.getRows(2, set.data(), num_row, lower.data(), upper.data(), num_nz,
nullptr, nullptr, nullptr);
REQUIRE(num_row == 2);
REQUIRE(num_nz == 4);
matrix_start.resize(num_row);
matrix_index.resize(num_nz);
matrix_value.resize(num_nz);
return_status = h.getRows(2, set.data(), num_row, lower.data(), upper.data(),
num_nz, matrix_start.data(), matrix_index.data(),
matrix_value.data());
return_status = h.getRows(2, set.data(), num_row, lower.data(),
upper.data(), num_nz, matrix_start.data(),
matrix_index.data(), matrix_value.data());
REQUIRE(matrix_start[0] == 0);
REQUIRE(matrix_start[1] == 2);
REQUIRE(matrix_index[0] == i+1);
REQUIRE(matrix_index[0] == i + 1);
REQUIRE(matrix_index[1] == i);
REQUIRE(matrix_index[2] == dim-1);
REQUIRE(matrix_index[3] == dim-2);
REQUIRE(matrix_index[2] == dim - 1);
REQUIRE(matrix_index[3] == dim - 2);
REQUIRE(matrix_value[0] == 1);
REQUIRE(matrix_value[1] == 2);
REQUIRE(matrix_value[2] == 1);
REQUIRE(matrix_value[3] == 2);

std::vector<HighsInt> mask;
mask.assign(2*(dim-1), 0);
mask.assign(2 * (dim - 1), 0);
mask[0] = 1;
mask[dim-1+i] = 1;
return_status = h.getRows(mask.data(), num_row, lower.data(), upper.data(),
num_nz, nullptr, nullptr, nullptr);
mask[dim - 1 + i] = 1;
return_status =
h.getRows(mask.data(), num_row, lower.data(), upper.data(), num_nz,
nullptr, nullptr, nullptr);
REQUIRE(num_row == 2);
REQUIRE(num_nz == 4);
matrix_start.resize(num_row);
matrix_index.resize(num_nz);
matrix_value.resize(num_nz);
return_status = h.getRows(mask.data(), num_row, lower.data(), upper.data(),
num_nz, matrix_start.data(), matrix_index.data(),
matrix_value.data());
return_status = h.getRows(mask.data(), num_row, lower.data(),
upper.data(), num_nz, matrix_start.data(),
matrix_index.data(), matrix_value.data());
REQUIRE(matrix_start[0] == 0);
REQUIRE(matrix_start[1] == 2);
REQUIRE(matrix_index[0] == 1);
REQUIRE(matrix_index[1] == 0);
REQUIRE(matrix_index[2] == i+1);
REQUIRE(matrix_index[2] == i + 1);
REQUIRE(matrix_index[3] == i);
REQUIRE(matrix_value[0] == 1);
REQUIRE(matrix_value[1] == 2);
Expand All @@ -2058,7 +2060,6 @@ TEST_CASE("row-wise-get-row-time", "[highs_data]") {
h.clear();
dim *= 2;
}

}

TEST_CASE("row-wise-get-row-avgas", "[highs_data]") {
Expand All @@ -2070,15 +2071,16 @@ TEST_CASE("row-wise-get-row-avgas", "[highs_data]") {
std::vector<double> colCost;
std::vector<double> colLower;
std::vector<double> colUpper;
std::vector<HighsInt> Astart;
std::vector<HighsInt> Aindex;
std::vector<double> Avalue;
std::vector<HighsInt> Astart;
std::vector<HighsInt> Aindex;
std::vector<double> Avalue;
for (HighsInt col = 0; col < avgas_num_col; col++) {
HighsInt num_col = 0;
HighsInt num_col_nz = 0;
avgas.col(col, num_col, num_col_nz, colCost, colLower, colUpper, Astart,
Aindex, Avalue);
REQUIRE(h.addCol(colCost[0], colLower[0], colUpper[0], 0, nullptr, nullptr) == HighsStatus::kOk);
REQUIRE(h.addCol(colCost[0], colLower[0], colUpper[0], 0, nullptr,
nullptr) == HighsStatus::kOk);
}

std::vector<double> rowLower;
Expand All @@ -2092,8 +2094,7 @@ TEST_CASE("row-wise-get-row-avgas", "[highs_data]") {
HighsInt num_row_nz = 0;
avgas.row(row, num_row, num_row_nz, rowLower, rowUpper, ARstart, ARindex,
ARvalue);
REQUIRE(h.addRow(rowLower[0], rowUpper[0], num_row_nz, ARindex.data(),
ARvalue.data()) == HighsStatus::kOk);
REQUIRE(h.addRow(rowLower[0], rowUpper[0], num_row_nz, ARindex.data(),
ARvalue.data()) == HighsStatus::kOk);
}

}
22 changes: 5 additions & 17 deletions src/Highs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1556,25 +1556,13 @@ class Highs {

void getColsInterface(const HighsIndexCollection& index_collection,
HighsInt& num_col, double* cost, double* lower,
double* upper, HighsInt& num_nz,
HighsInt* start, HighsInt* index,
double* value);

void getColsInterfaceArch(const HighsIndexCollection& index_collection,
HighsInt& num_col, double* cost, double* lower,
double* upper, HighsInt& num_nz,
HighsInt* start, HighsInt* index,
double* value);
double* upper, HighsInt& num_nz, HighsInt* start,
HighsInt* index, double* value);

void getRowsInterface(const HighsIndexCollection& index_collection,
HighsInt& num_row, double* lower,
double* upper, HighsInt& num_nz,
HighsInt* start, HighsInt* index, double* value);

void getRowsInterfaceArch(const HighsIndexCollection& index_collection,
HighsInt& num_row, double* row_lower, double* row_upper,
HighsInt& num_nz, HighsInt* row_matrix_start,
HighsInt* row_matrix_index, double* row_matrix_value);
HighsInt& num_row, double* lower, double* upper,
HighsInt& num_nz, HighsInt* start, HighsInt* index,
double* value);

void getCoefficientInterface(const HighsInt ext_row, const HighsInt ext_col,
double& value);
Expand Down
Loading

0 comments on commit fdbf1ff

Please sign in to comment.