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
11 changes: 9 additions & 2 deletions ortools/linear_solver/xpress_interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ class XpressMPCallbackContext : public MPCallbackContext {
};
void AddLazyConstraint(const LinearRange& lazy_constraint) override {
LOG(WARNING)
<< "AddLazyConstraint is not implemented yet in XPRESS interface";
<< "AddLazyConstraint inside Callback is not implemented yet in XPRESS interface";
};
double SuggestSolution(
const absl::flat_hash_map<const MPVariable*, double>& solution) override;
Expand Down Expand Up @@ -1541,7 +1541,7 @@ void XpressInterface::ExtractNewConstraints() {
unique_ptr<char[]> sense(new char[chunk]);
unique_ptr<double[]> rhs(new double[chunk]);
unique_ptr<double[]> rngval(new double[chunk]);

std::vector<int> delayedRows;
// Loop over the new constraints, collecting rows for up to
// CHUNK constraints into the arrays so that adding constraints
// is faster.
Expand Down Expand Up @@ -1575,12 +1575,19 @@ void XpressInterface::ExtractNewConstraints() {
++nextNz;
}
}
if (ct->is_lazy()) {
delayedRows.push_back(offset + c);
}
}
if (nextRow > 0) {
CHECK_STATUS(XPRSaddrows(mLp, nextRow, nextNz, sense.get(), rhs.get(),
rngval.get(), rmatbeg.get(), rmatind.get(),
rmatval.get()));
}
if (!delayedRows.empty()) {
CHECK_STATUS(XPRSloaddelayedrows(
mLp, static_cast<int>(delayedRows.size()), delayedRows.data()));
}
}
} catch (...) {
// Undo all changes in case of error.
Expand Down
2 changes: 2 additions & 0 deletions ortools/third_party_solvers/xpress_environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ std::function<int(XPRSprob prob, char rowtype[], int first, int last)> XPRSgetro
std::function<int(XPRSprob prob, char coltype[], int first, int last)> XPRSgetcoltype = nullptr;
std::function<int(XPRSprob prob, int nbounds, const int colind[], const char bndtype[], const double bndval[])> XPRSchgbounds = nullptr;
std::function<int(XPRSprob prob, int length, const double solval[], const int colind[], const char* name)> XPRSaddmipsol = nullptr;
std::function<int(XPRSprob prob, int nrows, const int rowind[])> XPRSloaddelayedrows = nullptr;
std::function<int(XPRSprob prob, double x[], double slack[], double duals[], double djs[])> XPRSgetlpsol = nullptr;
std::function<int(XPRSprob prob, double x[], double slack[])> XPRSgetmipsol = nullptr;
std::function<int(XPRSprob prob, int ncols, const int colind[], const double objcoef[])> XPRSchgobj = nullptr;
Expand Down Expand Up @@ -167,6 +168,7 @@ void LoadXpressFunctions(DynamicLibrary* xpress_dynamic_library) {
xpress_dynamic_library->GetFunction(&XPRSgetcoltype, "XPRSgetcoltype");
xpress_dynamic_library->GetFunction(&XPRSchgbounds, "XPRSchgbounds");
xpress_dynamic_library->GetFunction(&XPRSaddmipsol, "XPRSaddmipsol");
xpress_dynamic_library->GetFunction(&XPRSloaddelayedrows, "XPRSloaddelayedrows");
xpress_dynamic_library->GetFunction(&XPRSgetlpsol, "XPRSgetlpsol");
xpress_dynamic_library->GetFunction(&XPRSgetmipsol, "XPRSgetmipsol");
xpress_dynamic_library->GetFunction(&XPRSchgobj, "XPRSchgobj");
Expand Down
1 change: 1 addition & 0 deletions ortools/third_party_solvers/xpress_environment.h
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,7 @@ OR_DLL extern std::function<int(XPRSprob prob, char rowtype[], int first, int la
OR_DLL extern std::function<int(XPRSprob prob, char coltype[], int first, int last)> XPRSgetcoltype;
extern std::function<int(XPRSprob prob, int nbounds, const int colind[], const char bndtype[], const double bndval[])> XPRSchgbounds;
extern std::function<int(XPRSprob prob, int length, const double solval[], const int colind[], const char* name)> XPRSaddmipsol;
extern std::function<int(XPRSprob prob, int nrows, const int rowind[])> XPRSloaddelayedrows;
extern std::function<int(XPRSprob prob, double x[], double slack[], double duals[], double djs[])> XPRSgetlpsol;
extern std::function<int(XPRSprob prob, double x[], double slack[])> XPRSgetmipsol;
extern std::function<int(XPRSprob prob, int ncols, const int colind[], const double objcoef[])> XPRSchgobj;
Expand Down
Loading