Skip to content

Commit

Permalink
use XPRSmipoptimize and XPRSlpoptimize instead of XPRSminim and XPRSm…
Browse files Browse the repository at this point in the history
…axim (#114)

* use XPRSmipoptimize and XPRSlpoptimize instead of XPRSminim and XPRSmaxim

* clean xpress/environment files

* accept changes: empty char* parameter for XPRS*optimize
  • Loading branch information
sgatto committed Nov 17, 2023
1 parent d47c2ee commit 2505eab
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
10 changes: 2 additions & 8 deletions ortools/linear_solver/xpress_interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1912,16 +1912,10 @@ MPSolver::ResultStatus XpressInterface::Solve(MPSolverParameters const& param) {

int xpress_stat = 0;
if (mMip) {
if (this->maximize_)
status = XPRSmaxim(mLp, "g");
else
status = XPRSminim(mLp, "g");
status = XPRSmipoptimize(mLp,"");
XPRSgetintattrib(mLp, XPRS_MIPSTATUS, &xpress_stat);
} else {
if (this->maximize_)
status = XPRSmaxim(mLp, "");
else
status = XPRSminim(mLp, "");
status = XPRSlpoptimize(mLp,"");
XPRSgetintattrib(mLp, XPRS_LPSTATUS, &xpress_stat);
}

Expand Down
9 changes: 5 additions & 4 deletions ortools/xpress/environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ std::function<int(XPRSprob prob, int nrows, const int rowind[], const char rowty
std::function<int(XPRSprob prob, void (XPRS_CC *f_intsol)(XPRSprob cbprob, void* cbdata), void* p, int priority)> XPRSaddcbintsol = nullptr;
std::function<int(XPRSprob prob, void (XPRS_CC *f_intsol)(XPRSprob cbprob, void* cbdata), void* p)> XPRSremovecbintsol = nullptr;
std::function<int(XPRSprob prob, void (XPRS_CC *f_message)(XPRSprob cbprob, void* cbdata, const char* msg, int msglen, int msgtype), void* p, int priority)> XPRSaddcbmessage = nullptr;
std::function<int(XPRSprob prob, const char* flags)> XPRSminim = nullptr;
std::function<int(XPRSprob prob, const char* flags)> XPRSmaxim = nullptr;
std::function<int(XPRSprob prob, const char* flags)> XPRSlpoptimize = nullptr;
std::function<int(XPRSprob prob, const char* flags)> XPRSmipoptimize = nullptr;

absl::Status LoadXpressFunctions(DynamicLibrary* xpress_dynamic_library) {
// This was generated with the parse_header_xpress.py script.
Expand Down Expand Up @@ -156,8 +156,9 @@ absl::Status LoadXpressFunctions(DynamicLibrary* xpress_dynamic_library) {
xpress_dynamic_library->GetFunction(&XPRSaddcbintsol, "XPRSaddcbintsol");
xpress_dynamic_library->GetFunction(&XPRSremovecbintsol, "XPRSremovecbintsol");
xpress_dynamic_library->GetFunction(&XPRSaddcbmessage, "XPRSaddcbmessage");
xpress_dynamic_library->GetFunction(&XPRSminim, "XPRSminim");
xpress_dynamic_library->GetFunction(&XPRSmaxim, "XPRSmaxim");
xpress_dynamic_library->GetFunction(&XPRSlpoptimize, "XPRSlpoptimize");
xpress_dynamic_library->GetFunction(&XPRSmipoptimize, "XPRSmipoptimize");


auto notFound = xpress_dynamic_library->FunctionsNotFound();
if (!notFound.empty()) {
Expand Down
4 changes: 2 additions & 2 deletions ortools/xpress/environment.h
Original file line number Diff line number Diff line change
Expand Up @@ -491,8 +491,8 @@ extern std::function<int(XPRSprob prob, int nrows, const int rowind[], const cha
extern std::function<int(XPRSprob prob, void (XPRS_CC *f_intsol)(XPRSprob cbprob, void* cbdata), void* p, int priority)> XPRSaddcbintsol;
extern std::function<int(XPRSprob prob, void (XPRS_CC *f_intsol)(XPRSprob cbprob, void* cbdata), void* p)> XPRSremovecbintsol;
extern std::function<int(XPRSprob prob, void (XPRS_CC *f_message)(XPRSprob cbprob, void* cbdata, const char* msg, int msglen, int msgtype), void* p, int priority)> XPRSaddcbmessage;
extern std::function<int(XPRSprob prob, const char* flags)> XPRSminim;
extern std::function<int(XPRSprob prob, const char* flags)> XPRSmaxim;
extern std::function<int(XPRSprob prob, const char* flags)> XPRSlpoptimize;
extern std::function<int(XPRSprob prob, const char* flags)> XPRSmipoptimize;

} // namespace operations_research

Expand Down

0 comments on commit 2505eab

Please sign in to comment.