fix test_xpress_interface.cc

This commit is contained in:
Andrea Sgattoni
2023-10-27 10:59:22 +02:00
parent b4ead5a8ce
commit a4a4ac9eb1
4 changed files with 13 additions and 9 deletions

View File

@@ -1,10 +1,10 @@
#include "ortools/linear_solver/xpress_interface.cc"
#include <fstream>
#include <locale>
#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<XpressMPCallbackContext*>(callback_context);
//XpressMPCallbackContext* context_ = static_cast<XpressMPCallbackContext*>(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));
}
};

View File

@@ -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

View File

@@ -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

View File

@@ -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