reformat
This commit is contained in:
@@ -1,3 +1,16 @@
|
||||
# Copyright 2010-2022 Google LLC
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
cc_library(
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
# Copyright 2010-2022 Google LLC
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
file(GLOB _SRCS "*.h" "*.cc")
|
||||
set(NAME ${PROJECT_NAME}_xpress)
|
||||
|
||||
|
||||
@@ -15,15 +15,17 @@
|
||||
|
||||
#include "ortools/xpress/environment.h"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <filesystem>
|
||||
#include <mutex>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/status/status.h"
|
||||
#include "absl/strings/match.h"
|
||||
#include "absl/strings/str_cat.h"
|
||||
#include "absl/strings/str_join.h"
|
||||
#include "absl/synchronization/mutex.h"
|
||||
#include "ortools/base/dynamic_library.h"
|
||||
#include "ortools/base/logging.h"
|
||||
|
||||
namespace operations_research {
|
||||
@@ -31,6 +33,8 @@ namespace operations_research {
|
||||
#define STRINGIFY2(X) #X
|
||||
#define STRINGIFY(X) STRINGIFY2(X)
|
||||
|
||||
// Let's not reformat for rest of the file.
|
||||
// clang-format off
|
||||
// This was generated with the parse_header_xpress.py script.
|
||||
// See the comment at the top of the script.
|
||||
|
||||
@@ -159,6 +163,7 @@ void LoadXpressFunctions(DynamicLibrary* xpress_dynamic_library) {
|
||||
xpress_dynamic_library->GetFunction(&XPRSlpoptimize, "XPRSlpoptimize");
|
||||
xpress_dynamic_library->GetFunction(&XPRSmipoptimize, "XPRSmipoptimize");
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
void printXpressBanner(bool error) {
|
||||
char banner[XPRS_MAXBANNERLENGTH];
|
||||
@@ -217,7 +222,7 @@ absl::Status LoadXpressDynamicLibrary(std::string& xpresspath) {
|
||||
static std::once_flag xpress_loading_done;
|
||||
static absl::Status xpress_load_status;
|
||||
static DynamicLibrary xpress_library;
|
||||
static absl::Mutex mutex;
|
||||
static absl::Mutex mutex(absl::kConstInit);
|
||||
|
||||
absl::MutexLock lock(&mutex);
|
||||
|
||||
@@ -253,7 +258,7 @@ absl::Status LoadXpressDynamicLibrary(std::string& xpresspath) {
|
||||
|
||||
void log_message_about_XPRSinit_argument();
|
||||
void log_full_license_error(int code, const std::string& xpress_lib_dir);
|
||||
/** init XPRESS environment */
|
||||
//! init XPRESS environment.
|
||||
bool initXpressEnv(bool verbose, int xpress_oem_license_key) {
|
||||
std::string xpress_lib_dir;
|
||||
absl::Status status = LoadXpressDynamicLibrary(xpress_lib_dir);
|
||||
@@ -335,13 +340,12 @@ bool initXpressEnv(bool verbose, int xpress_oem_license_key) {
|
||||
}
|
||||
}
|
||||
void log_full_license_error(int code, const std::string& xpress_lib_dir) {
|
||||
LOG(WARNING) << "XpressInterface: Xpress found at " << xpress_lib_dir
|
||||
<< "\n";
|
||||
LOG(WARNING) << "XpressInterface: Xpress found at " << xpress_lib_dir << "\n";
|
||||
char errmsg[256];
|
||||
XPRSgetlicerrmsg(errmsg, 256);
|
||||
|
||||
LOG(ERROR) << "XpressInterface : License error : " << errmsg
|
||||
<< " (XPRSinit returned code " << code << "). \n";
|
||||
<< " (XPRSinit returned code " << code << "). \n";
|
||||
LOG(ERROR)
|
||||
<< "|_Your Xpress installation should have set the env var XPAUTH_PATH"
|
||||
" to the full path of your licence file\n";
|
||||
|
||||
@@ -13,14 +13,13 @@
|
||||
|
||||
// Initial version of this code was provided by RTE
|
||||
|
||||
#ifndef OR_TOOLS_XPRESS_ENVIRONMENT_H
|
||||
#define OR_TOOLS_XPRESS_ENVIRONMENT_H
|
||||
#ifndef OR_TOOLS_XPRESS_ENVIRONMENT_H_
|
||||
#define OR_TOOLS_XPRESS_ENVIRONMENT_H_
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
#include "absl/status/status.h"
|
||||
#include "absl/status/statusor.h"
|
||||
#include "ortools/base/commandlineflags.h"
|
||||
#include "ortools/base/dynamic_library.h"
|
||||
#include "ortools/base/logging.h"
|
||||
|
||||
extern "C" {
|
||||
typedef struct xo_prob_struct* XPRSprob;
|
||||
@@ -33,13 +32,13 @@ void printXpressBanner(bool error);
|
||||
bool initXpressEnv(bool verbose = true, int xpress_oem_license_key = 0);
|
||||
|
||||
bool XpressIsCorrectlyInstalled();
|
||||
// clang-format off
|
||||
|
||||
// Force the loading of the xpress dynamic library. It returns true if the
|
||||
// library was successfully loaded. This method can only be called once.
|
||||
// Successive calls are no-op.
|
||||
//
|
||||
// Note that it does not check if a token license can be grabbed.
|
||||
absl::Status LoadXpressDynamicLibrary(std::string &xpresspath);
|
||||
absl::Status LoadXpressDynamicLibrary(std::string& xpresspath);
|
||||
|
||||
// The list of #define and extern std::function<> below is generated directly
|
||||
// from xprs.h via parse_header_xpress.py
|
||||
@@ -47,7 +46,8 @@ absl::Status LoadXpressDynamicLibrary(std::string &xpresspath);
|
||||
// This is the header section
|
||||
#if defined(_WIN32)
|
||||
#define XPRSint64 __int64
|
||||
#elif defined(__LP64__) || defined(_LP64) || defined(__ILP64__) || defined(_ILP64)
|
||||
#elif defined(__LP64__) || defined(_LP64) || defined(__ILP64__) || \
|
||||
defined(_ILP64)
|
||||
#define XPRSint64 long
|
||||
#else
|
||||
#define XPRSint64 long long
|
||||
@@ -58,36 +58,35 @@ absl::Status LoadXpressDynamicLibrary(std::string &xpresspath);
|
||||
#else
|
||||
#define XPRS_CC
|
||||
#endif
|
||||
/***************************************************************************\
|
||||
* values related to XPRSinterrupt *
|
||||
\***************************************************************************/
|
||||
#define XPRS_STOP_NONE 0
|
||||
#define XPRS_STOP_TIMELIMIT 1
|
||||
#define XPRS_STOP_CTRLC 2
|
||||
#define XPRS_STOP_NODELIMIT 3
|
||||
#define XPRS_STOP_ITERLIMIT 4
|
||||
#define XPRS_STOP_MIPGAP 5
|
||||
#define XPRS_STOP_SOLLIMIT 6
|
||||
#define XPRS_STOP_GENERICERROR 7
|
||||
#define XPRS_STOP_MEMORYERROR 8
|
||||
#define XPRS_STOP_USER 9
|
||||
#define XPRS_STOP_SOLVECOMPLETE 10
|
||||
#define XPRS_STOP_LICENSELOST 11
|
||||
#define XPRS_STOP_NUMERICALERROR 13
|
||||
/***************************************************************************\
|
||||
* values related to Set/GetControl/Attribinfo *
|
||||
\***************************************************************************/
|
||||
#define XPRS_TYPE_NOTDEFINED 0
|
||||
#define XPRS_TYPE_INT 1
|
||||
#define XPRS_TYPE_INT64 2
|
||||
#define XPRS_TYPE_DOUBLE 3
|
||||
#define XPRS_TYPE_STRING 4
|
||||
/***************************************************************************\
|
||||
* values related to NAMESPACES *
|
||||
\***************************************************************************/
|
||||
#define XPRS_NAMES_ROW 1
|
||||
#define XPRS_NAMES_COLUMN 2
|
||||
|
||||
// ***************************************************************************
|
||||
// * values related to XPRSinterrupt *
|
||||
// ***************************************************************************
|
||||
#define XPRS_STOP_NONE 0
|
||||
#define XPRS_STOP_TIMELIMIT 1
|
||||
#define XPRS_STOP_CTRLC 2
|
||||
#define XPRS_STOP_NODELIMIT 3
|
||||
#define XPRS_STOP_ITERLIMIT 4
|
||||
#define XPRS_STOP_MIPGAP 5
|
||||
#define XPRS_STOP_SOLLIMIT 6
|
||||
#define XPRS_STOP_GENERICERROR 7
|
||||
#define XPRS_STOP_MEMORYERROR 8
|
||||
#define XPRS_STOP_USER 9
|
||||
#define XPRS_STOP_SOLVECOMPLETE 10
|
||||
#define XPRS_STOP_LICENSELOST 11
|
||||
#define XPRS_STOP_NUMERICALERROR 13
|
||||
// ***************************************************************************
|
||||
// * values related to Set/GetControl/Attribinfo *
|
||||
// ***************************************************************************
|
||||
#define XPRS_TYPE_NOTDEFINED 0
|
||||
#define XPRS_TYPE_INT 1
|
||||
#define XPRS_TYPE_INT64 2
|
||||
#define XPRS_TYPE_DOUBLE 3
|
||||
#define XPRS_TYPE_STRING 4
|
||||
// ***************************************************************************
|
||||
// * values related to NAMESPACES *
|
||||
// ***************************************************************************
|
||||
#define XPRS_NAMES_ROW 1
|
||||
#define XPRS_NAMES_COLUMN 2
|
||||
|
||||
#define XPRS_PLUSINFINITY 1.0e+20
|
||||
#define XPRS_MINUSINFINITY -1.0e+20
|
||||
@@ -434,6 +433,9 @@ absl::Status LoadXpressDynamicLibrary(std::string &xpresspath);
|
||||
#define XPRS_MIP_UNBOUNDED 7
|
||||
#define XPRS_OBJ_MINIMIZE 1
|
||||
#define XPRS_OBJ_MAXIMIZE -1
|
||||
|
||||
// Let's not reformat for rest of the file.
|
||||
// clang-format off
|
||||
extern std::function<int(XPRSprob* p_prob)> XPRScreateprob;
|
||||
extern std::function<int(XPRSprob prob)> XPRSdestroyprob;
|
||||
extern std::function<int(const char* path)> XPRSinit;
|
||||
@@ -493,7 +495,8 @@ extern std::function<int(XPRSprob prob, void (XPRS_CC *f_intsol)(XPRSprob cbprob
|
||||
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)> XPRSlpoptimize;
|
||||
extern std::function<int(XPRSprob prob, const char* flags)> XPRSmipoptimize;
|
||||
// clang-format on
|
||||
|
||||
} // namespace operations_research
|
||||
|
||||
#endif // OR_TOOLS_XPRESS_ENVIRONMENT_H
|
||||
#endif // OR_TOOLS_XPRESS_ENVIRONMENT_H_
|
||||
|
||||
Reference in New Issue
Block a user