Skip to content

Commit

Permalink
print the right log messages
Browse files Browse the repository at this point in the history
  • Loading branch information
a-zakir committed Nov 15, 2023
1 parent 6340cb2 commit fa6cbf6
Showing 1 changed file with 13 additions and 21 deletions.
34 changes: 13 additions & 21 deletions src/cpp/multisolver_interface/environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,9 @@ void printXpressBanner(bool error) {
XPRSgetbanner(banner);

if (error) {
std::cerr << "XpressInterface : Xpress banner :\n" << banner << "\n";
std::cerr << "Xpress banner :\n" << banner << "\n";
} else {
std::cout << "Warning: "
<< "XpressInterface : Xpress banner :\n"
<< banner << "\n";
std::cout << "Xpress banner :\n" << banner << "\n";
}
}

Expand Down Expand Up @@ -333,9 +331,7 @@ bool initXpressEnv(bool verbose, int xpress_oem_license_key) {
std::string xpress_from_env = GetXpressVarFromEnvironmentVariables("XPRESS");
if (xpress_from_env == "") {
if (verbose) {
std::cout
<< "Warning: "
<< "XpressInterface Error : Environment variable XPRESS undefined.\n";
std::cout << "Warning: Environment variable XPRESS undefined.\n";
}
if (xpresspath.empty()) {
return false;
Expand All @@ -349,9 +345,8 @@ bool initXpressEnv(bool verbose, int xpress_oem_license_key) {
// if not an OEM key
if (xpress_oem_license_key == 0) {
if (verbose) {
std::cout << "Warning: "
<< "XpressInterface : Initialising xpress-MP with parameter "
<< xpresspath << "\n";
std::cout << "Initialising xpress-MP with parameter " << xpresspath
<< "\n";
}

code = XPRSinit(xpresspath.c_str());
Expand All @@ -364,16 +359,16 @@ bool initXpressEnv(bool verbose, int xpress_oem_license_key) {
XPRSgetversion(version);
std::cout << "Warning: "
<< "Optimizer version: " << version
<< " (OR-Tools was compiled with version " << XPVERSION
<< ").\n";
<< " (Antares-Xpansion was compiled with version "
<< XPVERSION << ").\n";
}
return true;
} else {
std::cerr << "XpressInterface: Xpress found at " << xpresspath << "\n";
char errmsg[256];
XPRSgetlicerrmsg(errmsg, 256);

std::cerr << "XpressInterface : License error : " << errmsg
std::cerr << "Xpress License error : " << errmsg
<< " (XPRSinit returned code " << code << "). Please check"
<< " environment variable XPRESS.\n";

Expand All @@ -383,7 +378,7 @@ bool initXpressEnv(bool verbose, int xpress_oem_license_key) {
// if OEM key
if (verbose) {
std::cout << "Warning: "
<< "XpressInterface : Initialising xpress-MP with OEM key "
<< "Initialising xpress-MP with OEM key "
<< xpress_oem_license_key << "\n";
}

Expand All @@ -394,27 +389,24 @@ bool initXpressEnv(bool verbose, int xpress_oem_license_key) {

XPRSlicense(&nvalue, slicmsg);
if (verbose) {
std::cout << "XpressInterface : First message from XPRSLicense : "
<< slicmsg << "\n";
std::cout << "First message from XPRSLicense : " << slicmsg << "\n";
}

nvalue = xpress_oem_license_key - ((nvalue * nvalue) / 19);
ierr = XPRSlicense(&nvalue, slicmsg);

if (verbose) {
std::cout << "XpressInterface : Second message from XPRSLicense : "
<< slicmsg << "\n";
std::cout << "Second message from XPRSLicense : " << slicmsg << "\n";
}
if (ierr == 16) {
if (verbose) {
std::cout
<< "XpressInterface : Optimizer development software detected\n";
std::cout << "Optimizer development software detected\n";
}
} else if (ierr != 0) {
// get the license error message
XPRSgetlicerrmsg(errmsg, 256);

std::cerr << "XpressInterface : " << errmsg << "\n";
std::cerr << "Xpress Error Message: " << errmsg << "\n";
return false;
}

Expand Down

0 comments on commit fa6cbf6

Please sign in to comment.