Skip to content

Commit

Permalink
accept suggestion by @flomnes
Browse files Browse the repository at this point in the history
  • Loading branch information
sgatto committed Dec 8, 2023
1 parent 19bf3d3 commit 890757b
Showing 1 changed file with 0 additions and 26 deletions.
26 changes: 0 additions & 26 deletions ortools/linear_solver/xpress_interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1355,19 +1355,13 @@ void XpressInterface::ExtractNewVariables() {
unique_ptr<double[]> lb(new double[new_col_count]);
unique_ptr<double[]> ub(new double[new_col_count]);
unique_ptr<char[]> ctype(new char[new_col_count]);
std::vector<char> col_names;

bool have_names = false;
for (int j = 0, var_idx = last_extracted; j < new_col_count;
++j, ++var_idx) {
MPVariable const* const var = solver_->variables_[var_idx];
lb[j] = var->lb();
ub[j] = var->ub();
ctype[j] = var->integer() ? XPRS_INTEGER : XPRS_CONTINUOUS;
std::copy(var->name().begin(), var->name().end(),
std::back_inserter(col_names));
col_names.push_back('\0');
have_names = have_names || !var->name().empty();
obj[j] = solver_->objective_->GetCoefficient(var);
}

Expand Down Expand Up @@ -1454,12 +1448,6 @@ void XpressInterface::ExtractNewVariables() {
CHECK_STATUS(XPRSaddcols(mLp, new_col_count, nonzeros, obj.get(),
cmatbeg, cmatind.get(), cmatval.get(),
lb.get(), ub.get()));
// TODO Fixme
// Writing all names worsen the performance significantly
// Performance are //if (have_names) {
// CHECK_STATUS(XPRSaddnames(mLp, XPRS_NAMES_COLUMN, col_names.data(),
// 0, new_col_count - 1));
//}
}
}

Expand Down Expand Up @@ -1556,11 +1544,9 @@ void XpressInterface::ExtractNewConstraints() {
unique_ptr<int[]> rmatbeg(new int[chunk]);
unique_ptr<char[]> sense(new char[chunk]);
unique_ptr<double[]> rhs(new double[chunk]);
std::vector<char> name;
unique_ptr<double[]> rngval(new double[chunk]);
unique_ptr<int[]> rngind(new int[chunk]);
bool haveRanges = false;
bool have_names = false;

// Loop over the new constraints, collecting rows for up to
// CHUNK constraints into the arrays so that adding constraints
Expand Down Expand Up @@ -1598,24 +1584,12 @@ void XpressInterface::ExtractNewConstraints() {
++nextNz;
}
}

// Finally the name of the constraint.
std::copy(ct->name().begin(), ct->name().end(),
std::back_inserter(name));
name.push_back('\0');
have_names = have_names || !ct->name().empty();
}
if (nextRow > 0) {
CHECK_STATUS(XPRSaddrows(mLp, nextRow, nextNz, sense.get(), rhs.get(),
rngval.get(), rmatbeg.get(), rmatind.get(),
rmatval.get()));

//TODO fixme
// Writing all names worsen the performance significantly
//if (have_names) {
// CHECK_STATUS(XPRSaddnames(mLp, XPRS_NAMES_ROW, name.data(), offset,
// offset + c - 1));
//}
if (haveRanges) {
CHECK_STATUS(
XPRSchgrhsrange(mLp, nextRow, rngind.get(), rngval.get()));
Expand Down

0 comments on commit 890757b

Please sign in to comment.