From a4a4ac9eb1de0b8f7f92ad65e46ce398ff96e74b Mon Sep 17 00:00:00 2001 From: Andrea Sgattoni Date: Fri, 27 Oct 2023 10:59:22 +0200 Subject: [PATCH] fix test_xpress_interface.cc --- examples/xpress_tests/test_xpress_interface.cc | 12 ++++++------ ortools/linear_solver/xpress_interface.cc | 2 -- ortools/xpress/environment.h | 6 ++++++ ortools/xpress/parse_header_xpress.py | 2 +- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/examples/xpress_tests/test_xpress_interface.cc b/examples/xpress_tests/test_xpress_interface.cc index 870ea99b0d..4590b1ae80 100644 --- a/examples/xpress_tests/test_xpress_interface.cc +++ b/examples/xpress_tests/test_xpress_interface.cc @@ -1,10 +1,10 @@ -#include "ortools/linear_solver/xpress_interface.cc" - #include #include #include "gtest/gtest.h" #include "ortools/base/init_google.h" +#include "ortools/linear_solver/linear_solver.h" +#include "ortools/xpress/environment.h" #define XPRS_NAMELENGTH 1028 namespace operations_research { @@ -239,13 +239,13 @@ namespace operations_research { if (should_throw_) { throw std::runtime_error("This is a mocked exception in MyMPCallback"); } - XpressMPCallbackContext* context_ = static_cast(callback_context); + //XpressMPCallbackContext* context_ = static_cast(callback_context); ++nSolutions_; - EXPECT_TRUE(context_->CanQueryVariableValues()); - EXPECT_EQ(context_->Event(), MPCallbackEvent::kMipSolution); + EXPECT_TRUE(callback_context->CanQueryVariableValues()); + EXPECT_EQ(callback_context->Event(), MPCallbackEvent::kMipSolution); last_variable_values_.resize(mpSolver_->NumVariables(), 0.0); for (int i = 0 ; i < mpSolver_->NumVariables(); i++) { - last_variable_values_[i] = context_->VariableValue(mpSolver_->variable(i)); + last_variable_values_[i] = callback_context->VariableValue(mpSolver_->variable(i)); } }; diff --git a/ortools/linear_solver/xpress_interface.cc b/ortools/linear_solver/xpress_interface.cc index db8bd9a713..514e5e546f 100644 --- a/ortools/linear_solver/xpress_interface.cc +++ b/ortools/linear_solver/xpress_interface.cc @@ -32,8 +32,6 @@ #define XPRS_INTEGER 'I' #define XPRS_CONTINUOUS 'C' -#define XPRS_NAMES_ROW 1 -#define XPRS_NAMES_COLUMN 2 // The argument to this macro is the invocation of a XPRS function that // returns a status. If the function returns non-zero the macro aborts diff --git a/ortools/xpress/environment.h b/ortools/xpress/environment.h index 3ac9e74fb8..faee0a7e52 100644 --- a/ortools/xpress/environment.h +++ b/ortools/xpress/environment.h @@ -82,6 +82,12 @@ absl::Status LoadXpressDynamicLibrary(std::string &xpresspath); #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 diff --git a/ortools/xpress/parse_header_xpress.py b/ortools/xpress/parse_header_xpress.py index 67898761d8..8994acb494 100644 --- a/ortools/xpress/parse_header_xpress.py +++ b/ortools/xpress/parse_header_xpress.py @@ -93,7 +93,7 @@ class XpressHeaderParser(object): "XPRS_ROWS", "XPRS_SIMPLEXITER", "XPRS_LPSTATUS", "XPRS_MIPSTATUS", "XPRS_NODES", "XPRS_COLS", "XPRS_LP_OPTIMAL", "XPRS_LP_INFEAS", "XPRS_LP_UNBOUNDED", "XPRS_MIP_SOLUTION", "XPRS_MIP_INFEAS", "XPRS_MIP_OPTIMAL", "XPRS_MIP_UNBOUNDED", - "XPRS_OBJ_MINIMIZE", "XPRS_OBJ_MAXIMIZE"} + "XPRS_OBJ_MINIMIZE", "XPRS_OBJ_MAXIMIZE", "XPRS_NAMES_ROW", "XPRS_NAMES_COLUMN"} self.__missing_required_defines = self.__required_defines # These enum will detect control parameters that will all be imported self.__doc_section = XprsDocumentSection.OTHER