Add version string to sat/glop; export MPSolver::SolverVersion() in python/java/C#

This commit is contained in:
Laurent Perron
2022-12-20 11:54:29 +01:00
parent 068df24bec
commit 1f8a0a7770
17 changed files with 271 additions and 148 deletions

View File

@@ -40,9 +40,9 @@ cc_library(
"version.h",
],
copts = [
"-DOR_TOOLS_MAJOR=9999",
"-DOR_TOOLS_MINOR=0",
"-DOR_TOOLS_PATCH=0",
"-DOR_TOOLS_MAJOR=9",
"-DOR_TOOLS_MINOR=5",
"-DOR_TOOLS_PATCH=9999",
],
deps = [
":basictypes",

View File

@@ -385,7 +385,7 @@ cc_library(
copts = SAFE_FP_CODE,
deps = [
":parameters_cc_proto",
":preprocessor",
":revised_simplex",
":status",
"//ortools/base",
"//ortools/lp_data",

View File

@@ -20,13 +20,11 @@
#include <string>
#include <vector>
#include "absl/memory/memory.h"
#include "absl/strings/match.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h"
#include "absl/strings/str_join.h"
#include "ortools/base/commandlineflags.h"
#include "ortools/base/integral_types.h"
#include "ortools/base/timer.h"
#include "ortools/base/version.h"
#include "ortools/glop/preprocessor.h"
#include "ortools/glop/status.h"
#include "ortools/lp_data/lp_types.h"
@@ -113,6 +111,10 @@ void DumpLinearProgramIfRequiredByFlags(const LinearProgram& linear_program,
LPSolver::LPSolver() : num_solves_(0) {}
std::string LPSolver::GlopVersion() {
return absl::StrCat("Glop ", OrToolsVersionString());
}
void LPSolver::SetParameters(const GlopParameters& parameters) {
parameters_ = parameters;
#ifndef __PORTABLE_PLATFORM__

View File

@@ -15,9 +15,10 @@
#define OR_TOOLS_GLOP_LP_SOLVER_H_
#include <memory>
#include <string>
#include "ortools/glop/parameters.pb.h"
#include "ortools/glop/preprocessor.h"
#include "ortools/glop/revised_simplex.h"
#include "ortools/lp_data/lp_data.h"
#include "ortools/lp_data/lp_types.h"
#include "ortools/util/logging.h"
@@ -37,6 +38,9 @@ class LPSolver {
const GlopParameters& GetParameters() const;
GlopParameters* GetMutableParameters();
// Returns a string that describes the version of the solver.
static std::string GlopVersion();
// Solves the given linear program and returns the solve status. See the
// ProblemStatus documentation for a description of the different values.
//
@@ -61,7 +65,7 @@ class LPSolver {
// Puts the solver in a clean state.
//
// Calling Solve() for the first time, or calling Clear() then Solve() on the
// same problem is guaranted to be deterministic and to always give the same
// same problem is guaranteed to be deterministic and to always give the same
// result, assuming that no time limit was specified.
void Clear();

View File

@@ -373,7 +373,7 @@ message GlopParameters {
// That is, the variable values are unchanged for the primal simplex or the
// reduced cost are unchanged for the dual simplex. However, instead of doing
// a step of length zero, it seems to be better on degenerate problems to do a
// small positive step. This is what is recommanded in the EXPAND procedure
// small positive step. This is what is recommended in the EXPAND procedure
// described in:
// P. E. Gill, W. Murray, M. A. Saunders, and M. H. Wright. "A practical anti-
// cycling procedure for linearly constrained optimization".

View File

@@ -20,9 +20,19 @@
namespace operations_research::glop {
#define TEST_NOT_NAN(name) \
if (std::isnan(params.name())) { \
return absl::StrCat("parameter '", #name, "' is NaN"); \
#define TEST_FINITE_AND_NON_NEGATIVE(name) \
if (!std::isfinite(params.name())) { \
return absl::StrCat("parameter '", #name, "' is NaN or not finite"); \
} \
if (params.name() < 0) { \
return absl::StrCat("Parameters '", #name, "' must be non-negative"); \
}
// We need an integer version of the test as std::isnan can fail to compile
// on windows platforms when passed integer values.
#define TEST_INTEGER_NON_NEGATIVE(name) \
if (params.name() < 0) { \
return absl::StrCat("Parameters '", #name, "' must be non-negative"); \
}
#define TEST_NON_NEGATIVE(name) \
@@ -33,17 +43,9 @@ namespace operations_research::glop {
return absl::StrCat("Parameters '", #name, "' must be non-negative"); \
}
#define TEST_INTEGER_NON_NEGATIVE(name) \
if (params.name() < 0) { \
return absl::StrCat("Parameters '", #name, "' must be non-negative"); \
}
#define TEST_FINITE_AND_NON_NEGATIVE(name) \
if (!std::isfinite(params.name())) { \
return absl::StrCat("parameter '", #name, "' is NaN or not finite"); \
} \
if (params.name() < 0) { \
return absl::StrCat("Parameters '", #name, "' must be non-negative"); \
#define TEST_NOT_NAN(name) \
if (std::isnan(params.name())) { \
return absl::StrCat("parameter '", #name, "' is NaN"); \
}
std::string ValidateParameters(const GlopParameters& params) {
@@ -89,10 +91,9 @@ std::string ValidateParameters(const GlopParameters& params) {
return "";
}
#undef TEST_FINITE_AND_NON_NEGATIVE
#undef TEST_NOT_NAN
#undef TEST_INTEGER_NON_NEGATIVE
#undef TEST_NON_NEGATIVE
#undef TEST_NOT_NAN
#undef TEST_FINITE_AND_NON_NEGATIVE
} // namespace operations_research::glop

View File

@@ -44,78 +44,175 @@ bool GurobiIsCorrectlyInstalled() {
// See the comment at the top of the script.
// This is the 'define' section.
std::function<int(GRBenv**, const char*, const char*, const char*, int, const char*)> GRBisqp = nullptr;
std::function<int(GRBmodel *model, const char *attrname)> GRBisattravailable = nullptr;
std::function<int(GRBmodel *model, const char *attrname, int *valueP)> GRBgetintattr = nullptr;
std::function<int(GRBmodel *model, const char *attrname, int newvalue)> GRBsetintattr = nullptr;
std::function<int(GRBmodel *model, const char *attrname,int element, int *valueP)> GRBgetintattrelement = nullptr;
std::function<int(GRBmodel *model, const char *attrname,int element, int newvalue)> GRBsetintattrelement = nullptr;
std::function<int(GRBmodel *model, const char *attrname,int first, int len, int *values)> GRBgetintattrarray = nullptr;
std::function<int(GRBmodel *model, const char *attrname,int first, int len, int *newvalues)> GRBsetintattrarray = nullptr;
std::function<int(GRBmodel *model, const char *attrname,int len, int *ind, int *newvalues)> GRBsetintattrlist = nullptr;
std::function<int(GRBmodel *model, const char *attrname,int element, char *valueP)> GRBgetcharattrelement = nullptr;
std::function<int(GRBmodel *model, const char *attrname,int element, char newvalue)> GRBsetcharattrelement = nullptr;
std::function<int(GRBmodel *model, const char *attrname,int first, int len, char *values)> GRBgetcharattrarray = nullptr;
std::function<int(GRBmodel *model, const char *attrname,int first, int len, char *newvalues)> GRBsetcharattrarray = nullptr;
std::function<int(GRBmodel *model, const char *attrname,int len, int *ind, char *newvalues)> GRBsetcharattrlist = nullptr;
std::function<int(GRBmodel *model, const char *attrname, double *valueP)> GRBgetdblattr = nullptr;
std::function<int(GRBmodel *model, const char *attrname, double newvalue)> GRBsetdblattr = nullptr;
std::function<int(GRBmodel *model, const char *attrname,int element, double *valueP)> GRBgetdblattrelement = nullptr;
std::function<int(GRBmodel *model, const char *attrname,int element, double newvalue)> GRBsetdblattrelement = nullptr;
std::function<int(GRBmodel *model, const char *attrname,int first, int len, double *values)> GRBgetdblattrarray = nullptr;
std::function<int(GRBmodel *model, const char *attrname,int first, int len, double *newvalues)> GRBsetdblattrarray = nullptr;
std::function<int(GRBmodel *model, const char *attrname,int len, int *ind, double *newvalues)> GRBsetdblattrlist = nullptr;
std::function<int(GRBmodel *model, const char *attrname, char **valueP)> GRBgetstrattr = nullptr;
std::function<int(GRBmodel *model, const char *attrname, const char *newvalue)> GRBsetstrattr = nullptr;
std::function<int(GRBmodel *model,int (GUROBI_STDCALL *cb)(CB_ARGS),void *usrdata)> GRBsetcallbackfunc = nullptr;
std::function<int(void *cbdata, int where, int what, void *resultP)> GRBcbget = nullptr;
std::function<int(void *cbdata, const double *solution, double *objvalP)> GRBcbsolution = nullptr;
std::function<int(void *cbdata, int cutlen, const int *cutind, const double *cutval,char cutsense, double cutrhs)> GRBcbcut = nullptr;
std::function<int(void *cbdata, int lazylen, const int *lazyind,const double *lazyval, char lazysense, double lazyrhs)> GRBcblazy = nullptr;
std::function<int(GRBmodel *model, int *numnzP, int *vbeg, int *vind,double *vval, int start, int len)> GRBgetvars = nullptr;
std::function<int(GRBmodel *model)> GRBoptimize = nullptr;
std::function<int(GRBmodel *model, const char *filename)> GRBwrite = nullptr;
std::function<int(GRBenv *env, GRBmodel **modelP, const char *Pname, int numvars,double *obj, double *lb, double *ub, char *vtype,char **varnames)> GRBnewmodel = nullptr;
std::function<int(GRBmodel *model, int numnz, int *vind, double *vval,double obj, double lb, double ub, char vtype,const char *varname)> GRBaddvar = nullptr;
std::function<int(GRBmodel *model, int numvars, int numnz,int *vbeg, int *vind, double *vval,double *obj, double *lb, double *ub, char *vtype,char **varnames)> GRBaddvars = nullptr;
std::function<int(GRBmodel *model, int numnz, int *cind, double *cval,char sense, double rhs, const char *constrname)> GRBaddconstr = nullptr;
std::function<int(GRBmodel *model, int numconstrs, int numnz,int *cbeg, int *cind, double *cval,char *sense, double *rhs, char **constrnames)> GRBaddconstrs = nullptr;
std::function<int(GRBmodel *model, int numnz, int *cind, double *cval,double lower, double upper, const char *constrname)> GRBaddrangeconstr = nullptr;
std::function<int(GRBmodel *model, int numsos, int nummembers, int *types,int *beg, int *ind, double *weight)> GRBaddsos = nullptr;
std::function<int(GRBmodel *model, const char *name,int resvar, int nvars, const int *vars,double constant)> GRBaddgenconstrMax = nullptr;
std::function<int(GRBmodel *model, const char *name,int resvar, int nvars, const int *vars,double constant)> GRBaddgenconstrMin = nullptr;
std::function<int(GRBmodel *model, const char *name,int resvar, int argvar)> GRBaddgenconstrAbs = nullptr;
std::function<int(GRBmodel *model, const char *name,int resvar, int nvars, const int *vars)> GRBaddgenconstrAnd = nullptr;
std::function<int(GRBmodel *model, const char *name,int resvar, int nvars, const int *vars)> GRBaddgenconstrOr = nullptr;
std::function<int(GRBmodel *model, const char *name,int binvar, int binval, int nvars, const int *vars,const double *vals, char sense, double rhs)> GRBaddgenconstrIndicator = nullptr;
std::function<int(GRBmodel *model, int numlnz, int *lind, double *lval,int numqnz, int *qrow, int *qcol, double *qval,char sense, double rhs, const char *QCname)> GRBaddqconstr = nullptr;
std::function<int(GRBmodel *model, int numqnz, int *qrow, int *qcol,double *qval)> GRBaddqpterms = nullptr;
std::function<int(GRBmodel *model, int len, int *ind)> GRBdelvars = nullptr;
std::function<int(GRBmodel *model, int len, int *ind)> GRBdelconstrs = nullptr;
std::function<int(GRBmodel *model, int len, int *ind)> GRBdelsos = nullptr;
std::function<int(GRBmodel *model, int len, int *ind)> GRBdelgenconstrs = nullptr;
std::function<int(GRBmodel *model, int len, int *ind)> GRBdelqconstrs = nullptr;
std::function<int(GRBmodel *model)> GRBdelq = nullptr;
std::function<int(GRBmodel *model, int cnt, int *cind, int *vind, double *val)> GRBchgcoeffs = nullptr;
std::function<int(GRBmodel *model)> GRBupdatemodel = nullptr;
std::function<int(GRBmodel *model)> GRBfreemodel = nullptr;
std::function<void(GRBmodel *model)> GRBterminate = nullptr;
std::function<int(GRBmodel *model, int index, int priority, double weight,double abstol, double reltol, const char *name,double constant, int lnz, int *lind, double *lval)> GRBsetobjectiven = nullptr;
std::function<int(GRBenv *env, const char *paramname, int *valueP)> GRBgetintparam = nullptr;
std::function<int(GRBenv *env, const char *paramname, double *valueP)> GRBgetdblparam = nullptr;
std::function<int(GRBenv *env, const char *paramname, char *valueP)> GRBgetstrparam = nullptr;
std::function<int(GRBenv *env, const char *paramname, const char *value)> GRBsetparam = nullptr;
std::function<int(GRBenv *env, const char *paramname, int value)> GRBsetintparam = nullptr;
std::function<int(GRBenv *env, const char *paramname, double value)> GRBsetdblparam = nullptr;
std::function<int(GRBenv *env, const char *paramname, const char *value)> GRBsetstrparam = nullptr;
std::function<int(GRBenv *env)> GRBresetparams = nullptr;
std::function<int(GRBenv *dest, GRBenv *src)> GRBcopyparams = nullptr;
std::function<int(GRBenv **envP, const char *logfilename)> GRBloadenv = nullptr;
std::function<GRBenv *(GRBmodel *model)> GRBgetenv = nullptr;
std::function<void(GRBenv *env)> GRBfreeenv = nullptr;
std::function<const char *(GRBenv *env)> GRBgeterrormsg = nullptr;
std::function<void(int *majorP, int *minorP, int *technicalP)> GRBversion = nullptr;
std::function<char *(void)> GRBplatform = nullptr;
std::function<int(GRBenv**, const char*, const char*, const char*, int,
const char*)>
GRBisqp = nullptr;
std::function<int(GRBmodel* model, const char* attrname)> GRBisattravailable =
nullptr;
std::function<int(GRBmodel* model, const char* attrname, int* valueP)>
GRBgetintattr = nullptr;
std::function<int(GRBmodel* model, const char* attrname, int newvalue)>
GRBsetintattr = nullptr;
std::function<int(GRBmodel* model, const char* attrname, int element,
int* valueP)>
GRBgetintattrelement = nullptr;
std::function<int(GRBmodel* model, const char* attrname, int element,
int newvalue)>
GRBsetintattrelement = nullptr;
std::function<int(GRBmodel* model, const char* attrname, int first, int len,
int* values)>
GRBgetintattrarray = nullptr;
std::function<int(GRBmodel* model, const char* attrname, int first, int len,
int* newvalues)>
GRBsetintattrarray = nullptr;
std::function<int(GRBmodel* model, const char* attrname, int len, int* ind,
int* newvalues)>
GRBsetintattrlist = nullptr;
std::function<int(GRBmodel* model, const char* attrname, int element,
char* valueP)>
GRBgetcharattrelement = nullptr;
std::function<int(GRBmodel* model, const char* attrname, int element,
char newvalue)>
GRBsetcharattrelement = nullptr;
std::function<int(GRBmodel* model, const char* attrname, int first, int len,
char* values)>
GRBgetcharattrarray = nullptr;
std::function<int(GRBmodel* model, const char* attrname, int first, int len,
char* newvalues)>
GRBsetcharattrarray = nullptr;
std::function<int(GRBmodel* model, const char* attrname, int len, int* ind,
char* newvalues)>
GRBsetcharattrlist = nullptr;
std::function<int(GRBmodel* model, const char* attrname, double* valueP)>
GRBgetdblattr = nullptr;
std::function<int(GRBmodel* model, const char* attrname, double newvalue)>
GRBsetdblattr = nullptr;
std::function<int(GRBmodel* model, const char* attrname, int element,
double* valueP)>
GRBgetdblattrelement = nullptr;
std::function<int(GRBmodel* model, const char* attrname, int element,
double newvalue)>
GRBsetdblattrelement = nullptr;
std::function<int(GRBmodel* model, const char* attrname, int first, int len,
double* values)>
GRBgetdblattrarray = nullptr;
std::function<int(GRBmodel* model, const char* attrname, int first, int len,
double* newvalues)>
GRBsetdblattrarray = nullptr;
std::function<int(GRBmodel* model, const char* attrname, int len, int* ind,
double* newvalues)>
GRBsetdblattrlist = nullptr;
std::function<int(GRBmodel* model, const char* attrname, char** valueP)>
GRBgetstrattr = nullptr;
std::function<int(GRBmodel* model, const char* attrname, const char* newvalue)>
GRBsetstrattr = nullptr;
std::function<int(GRBmodel* model, int(GUROBI_STDCALL* cb)(CB_ARGS),
void* usrdata)>
GRBsetcallbackfunc = nullptr;
std::function<int(void* cbdata, int where, int what, void* resultP)> GRBcbget =
nullptr;
std::function<int(void* cbdata, const double* solution, double* objvalP)>
GRBcbsolution = nullptr;
std::function<int(void* cbdata, int cutlen, const int* cutind,
const double* cutval, char cutsense, double cutrhs)>
GRBcbcut = nullptr;
std::function<int(void* cbdata, int lazylen, const int* lazyind,
const double* lazyval, char lazysense, double lazyrhs)>
GRBcblazy = nullptr;
std::function<int(GRBmodel* model, int* numnzP, int* vbeg, int* vind,
double* vval, int start, int len)>
GRBgetvars = nullptr;
std::function<int(GRBmodel* model)> GRBoptimize = nullptr;
std::function<int(GRBmodel* model, const char* filename)> GRBwrite = nullptr;
std::function<int(GRBenv* env, GRBmodel** modelP, const char* Pname,
int numvars, double* obj, double* lb, double* ub, char* vtype,
char** varnames)>
GRBnewmodel = nullptr;
std::function<int(GRBmodel* model, int numnz, int* vind, double* vval,
double obj, double lb, double ub, char vtype,
const char* varname)>
GRBaddvar = nullptr;
std::function<int(GRBmodel* model, int numvars, int numnz, int* vbeg, int* vind,
double* vval, double* obj, double* lb, double* ub,
char* vtype, char** varnames)>
GRBaddvars = nullptr;
std::function<int(GRBmodel* model, int numnz, int* cind, double* cval,
char sense, double rhs, const char* constrname)>
GRBaddconstr = nullptr;
std::function<int(GRBmodel* model, int numconstrs, int numnz, int* cbeg,
int* cind, double* cval, char* sense, double* rhs,
char** constrnames)>
GRBaddconstrs = nullptr;
std::function<int(GRBmodel* model, int numnz, int* cind, double* cval,
double lower, double upper, const char* constrname)>
GRBaddrangeconstr = nullptr;
std::function<int(GRBmodel* model, int numsos, int nummembers, int* types,
int* beg, int* ind, double* weight)>
GRBaddsos = nullptr;
std::function<int(GRBmodel* model, const char* name, int resvar, int nvars,
const int* vars, double constant)>
GRBaddgenconstrMax = nullptr;
std::function<int(GRBmodel* model, const char* name, int resvar, int nvars,
const int* vars, double constant)>
GRBaddgenconstrMin = nullptr;
std::function<int(GRBmodel* model, const char* name, int resvar, int argvar)>
GRBaddgenconstrAbs = nullptr;
std::function<int(GRBmodel* model, const char* name, int resvar, int nvars,
const int* vars)>
GRBaddgenconstrAnd = nullptr;
std::function<int(GRBmodel* model, const char* name, int resvar, int nvars,
const int* vars)>
GRBaddgenconstrOr = nullptr;
std::function<int(GRBmodel* model, const char* name, int binvar, int binval,
int nvars, const int* vars, const double* vals, char sense,
double rhs)>
GRBaddgenconstrIndicator = nullptr;
std::function<int(GRBmodel* model, int numlnz, int* lind, double* lval,
int numqnz, int* qrow, int* qcol, double* qval, char sense,
double rhs, const char* QCname)>
GRBaddqconstr = nullptr;
std::function<int(GRBmodel* model, int numqnz, int* qrow, int* qcol,
double* qval)>
GRBaddqpterms = nullptr;
std::function<int(GRBmodel* model, int len, int* ind)> GRBdelvars = nullptr;
std::function<int(GRBmodel* model, int len, int* ind)> GRBdelconstrs = nullptr;
std::function<int(GRBmodel* model, int len, int* ind)> GRBdelsos = nullptr;
std::function<int(GRBmodel* model, int len, int* ind)> GRBdelgenconstrs =
nullptr;
std::function<int(GRBmodel* model, int len, int* ind)> GRBdelqconstrs = nullptr;
std::function<int(GRBmodel* model)> GRBdelq = nullptr;
std::function<int(GRBmodel* model, int cnt, int* cind, int* vind, double* val)>
GRBchgcoeffs = nullptr;
std::function<int(GRBmodel* model)> GRBupdatemodel = nullptr;
std::function<int(GRBmodel* model)> GRBfreemodel = nullptr;
std::function<void(GRBmodel* model)> GRBterminate = nullptr;
std::function<int(GRBmodel* model, int index, int priority, double weight,
double abstol, double reltol, const char* name,
double constant, int lnz, int* lind, double* lval)>
GRBsetobjectiven = nullptr;
std::function<int(GRBenv* env, const char* paramname, int* valueP)>
GRBgetintparam = nullptr;
std::function<int(GRBenv* env, const char* paramname, double* valueP)>
GRBgetdblparam = nullptr;
std::function<int(GRBenv* env, const char* paramname, char* valueP)>
GRBgetstrparam = nullptr;
std::function<int(GRBenv* env, const char* paramname, const char* value)>
GRBsetparam = nullptr;
std::function<int(GRBenv* env, const char* paramname, int value)>
GRBsetintparam = nullptr;
std::function<int(GRBenv* env, const char* paramname, double value)>
GRBsetdblparam = nullptr;
std::function<int(GRBenv* env, const char* paramname, const char* value)>
GRBsetstrparam = nullptr;
std::function<int(GRBenv* env)> GRBresetparams = nullptr;
std::function<int(GRBenv* dest, GRBenv* src)> GRBcopyparams = nullptr;
std::function<int(GRBenv** envP, const char* logfilename)> GRBloadenv = nullptr;
std::function<GRBenv*(GRBmodel* model)> GRBgetenv = nullptr;
std::function<void(GRBenv* env)> GRBfreeenv = nullptr;
std::function<const char*(GRBenv* env)> GRBgeterrormsg = nullptr;
std::function<void(int* majorP, int* minorP, int* technicalP)> GRBversion =
nullptr;
std::function<char*(void)> GRBplatform = nullptr;
void LoadGurobiFunctions(DynamicLibrary* gurobi_dynamic_library) {
// This was generated with the parse_header.py script.
@@ -123,29 +220,44 @@ void LoadGurobiFunctions(DynamicLibrary* gurobi_dynamic_library) {
// This is the 'assign' section.
gurobi_dynamic_library->GetFunction(&GRBisqp, "GRBisqp");
gurobi_dynamic_library->GetFunction(&GRBisattravailable, "GRBisattravailable");
gurobi_dynamic_library->GetFunction(&GRBisattravailable,
"GRBisattravailable");
gurobi_dynamic_library->GetFunction(&GRBgetintattr, "GRBgetintattr");
gurobi_dynamic_library->GetFunction(&GRBsetintattr, "GRBsetintattr");
gurobi_dynamic_library->GetFunction(&GRBgetintattrelement, "GRBgetintattrelement");
gurobi_dynamic_library->GetFunction(&GRBsetintattrelement, "GRBsetintattrelement");
gurobi_dynamic_library->GetFunction(&GRBgetintattrarray, "GRBgetintattrarray");
gurobi_dynamic_library->GetFunction(&GRBsetintattrarray, "GRBsetintattrarray");
gurobi_dynamic_library->GetFunction(&GRBgetintattrelement,
"GRBgetintattrelement");
gurobi_dynamic_library->GetFunction(&GRBsetintattrelement,
"GRBsetintattrelement");
gurobi_dynamic_library->GetFunction(&GRBgetintattrarray,
"GRBgetintattrarray");
gurobi_dynamic_library->GetFunction(&GRBsetintattrarray,
"GRBsetintattrarray");
gurobi_dynamic_library->GetFunction(&GRBsetintattrlist, "GRBsetintattrlist");
gurobi_dynamic_library->GetFunction(&GRBgetcharattrelement, "GRBgetcharattrelement");
gurobi_dynamic_library->GetFunction(&GRBsetcharattrelement, "GRBsetcharattrelement");
gurobi_dynamic_library->GetFunction(&GRBgetcharattrarray, "GRBgetcharattrarray");
gurobi_dynamic_library->GetFunction(&GRBsetcharattrarray, "GRBsetcharattrarray");
gurobi_dynamic_library->GetFunction(&GRBsetcharattrlist, "GRBsetcharattrlist");
gurobi_dynamic_library->GetFunction(&GRBgetcharattrelement,
"GRBgetcharattrelement");
gurobi_dynamic_library->GetFunction(&GRBsetcharattrelement,
"GRBsetcharattrelement");
gurobi_dynamic_library->GetFunction(&GRBgetcharattrarray,
"GRBgetcharattrarray");
gurobi_dynamic_library->GetFunction(&GRBsetcharattrarray,
"GRBsetcharattrarray");
gurobi_dynamic_library->GetFunction(&GRBsetcharattrlist,
"GRBsetcharattrlist");
gurobi_dynamic_library->GetFunction(&GRBgetdblattr, "GRBgetdblattr");
gurobi_dynamic_library->GetFunction(&GRBsetdblattr, "GRBsetdblattr");
gurobi_dynamic_library->GetFunction(&GRBgetdblattrelement, "GRBgetdblattrelement");
gurobi_dynamic_library->GetFunction(&GRBsetdblattrelement, "GRBsetdblattrelement");
gurobi_dynamic_library->GetFunction(&GRBgetdblattrarray, "GRBgetdblattrarray");
gurobi_dynamic_library->GetFunction(&GRBsetdblattrarray, "GRBsetdblattrarray");
gurobi_dynamic_library->GetFunction(&GRBgetdblattrelement,
"GRBgetdblattrelement");
gurobi_dynamic_library->GetFunction(&GRBsetdblattrelement,
"GRBsetdblattrelement");
gurobi_dynamic_library->GetFunction(&GRBgetdblattrarray,
"GRBgetdblattrarray");
gurobi_dynamic_library->GetFunction(&GRBsetdblattrarray,
"GRBsetdblattrarray");
gurobi_dynamic_library->GetFunction(&GRBsetdblattrlist, "GRBsetdblattrlist");
gurobi_dynamic_library->GetFunction(&GRBgetstrattr, "GRBgetstrattr");
gurobi_dynamic_library->GetFunction(&GRBsetstrattr, "GRBsetstrattr");
gurobi_dynamic_library->GetFunction(&GRBsetcallbackfunc, "GRBsetcallbackfunc");
gurobi_dynamic_library->GetFunction(&GRBsetcallbackfunc,
"GRBsetcallbackfunc");
gurobi_dynamic_library->GetFunction(&GRBcbget, "GRBcbget");
gurobi_dynamic_library->GetFunction(&GRBcbsolution, "GRBcbsolution");
gurobi_dynamic_library->GetFunction(&GRBcbcut, "GRBcbcut");
@@ -160,12 +272,17 @@ void LoadGurobiFunctions(DynamicLibrary* gurobi_dynamic_library) {
gurobi_dynamic_library->GetFunction(&GRBaddconstrs, "GRBaddconstrs");
gurobi_dynamic_library->GetFunction(&GRBaddrangeconstr, "GRBaddrangeconstr");
gurobi_dynamic_library->GetFunction(&GRBaddsos, "GRBaddsos");
gurobi_dynamic_library->GetFunction(&GRBaddgenconstrMax, "GRBaddgenconstrMax");
gurobi_dynamic_library->GetFunction(&GRBaddgenconstrMin, "GRBaddgenconstrMin");
gurobi_dynamic_library->GetFunction(&GRBaddgenconstrAbs, "GRBaddgenconstrAbs");
gurobi_dynamic_library->GetFunction(&GRBaddgenconstrAnd, "GRBaddgenconstrAnd");
gurobi_dynamic_library->GetFunction(&GRBaddgenconstrMax,
"GRBaddgenconstrMax");
gurobi_dynamic_library->GetFunction(&GRBaddgenconstrMin,
"GRBaddgenconstrMin");
gurobi_dynamic_library->GetFunction(&GRBaddgenconstrAbs,
"GRBaddgenconstrAbs");
gurobi_dynamic_library->GetFunction(&GRBaddgenconstrAnd,
"GRBaddgenconstrAnd");
gurobi_dynamic_library->GetFunction(&GRBaddgenconstrOr, "GRBaddgenconstrOr");
gurobi_dynamic_library->GetFunction(&GRBaddgenconstrIndicator, "GRBaddgenconstrIndicator");
gurobi_dynamic_library->GetFunction(&GRBaddgenconstrIndicator,
"GRBaddgenconstrIndicator");
gurobi_dynamic_library->GetFunction(&GRBaddqconstr, "GRBaddqconstr");
gurobi_dynamic_library->GetFunction(&GRBaddqpterms, "GRBaddqpterms");
gurobi_dynamic_library->GetFunction(&GRBdelvars, "GRBdelvars");

View File

@@ -21,6 +21,12 @@
#include "ortools/base/dynamic_library.h"
#include "ortools/base/logging.h"
#if defined(_MSC_VER)
#define GUROBI_STDCALL __stdcall
#else
#define GUROBI_STDCALL
#endif
extern "C" {
typedef struct _GRBmodel GRBmodel;
typedef struct _GRBenv GRBenv;
@@ -29,13 +35,7 @@ typedef struct _GRBsvec {
int* ind;
double* val;
} GRBsvec;
}
#if defined(_MSC_VER)
#define GUROBI_STDCALL __stdcall
#else
#define GUROBI_STDCALL
#endif
}
namespace operations_research {

View File

@@ -18,7 +18,6 @@
#include <vector>
#include "absl/base/attributes.h"
#include "ortools/base/hash.h"
#include "ortools/base/integral_types.h"
#include "ortools/base/logging.h"
#include "ortools/glop/lp_solver.h"
@@ -29,7 +28,6 @@
#include "ortools/lp_data/lp_types.h"
#include "ortools/port/proto_utils.h"
#include "ortools/util/time_limit.h"
namespace operations_research {
namespace {} // Anonymous namespace
@@ -262,8 +260,7 @@ bool GLOPInterface::IsLP() const { return true; }
bool GLOPInterface::IsMIP() const { return false; }
std::string GLOPInterface::SolverVersion() const {
// TODO(user): Decide how to version glop. Add a GetVersion() to LPSolver.
return "Glop-0.0";
return glop::LPSolver::GlopVersion();
}
void* GLOPInterface::underlying_solver() { return &lp_solver_; }

View File

@@ -435,4 +435,6 @@ std::string EncodeSatParametersAsString(const sat::SatParameters& parameters) {
return ProtobufShortDebugString(parameters);
}
std::string SatSolverVersion() { return sat::CpSatSolverVersion(); }
} // namespace operations_research

View File

@@ -70,6 +70,9 @@ absl::StatusOr<MPSolutionResponse> SatSolveProto(
// you should always use this function to set the specific parameters.
std::string EncodeSatParametersAsString(const sat::SatParameters& parameters);
// Returns a string that describes the version of the CP-SAT solver.
std::string SatSolverVersion();
} // namespace operations_research
#endif // OR_TOOLS_LINEAR_SOLVER_PROTO_SOLVER_SAT_PROTO_SOLVER_H_

View File

@@ -258,6 +258,7 @@ PY_CONVERT(MPVariable);
// Strip the "MP" prefix from the exposed classes.
%rename (Solver) operations_research::MPSolver;
%rename (Solver) operations_research::MPSolver::MPSolver;
%unignore operations_research::MPSolver::SolverVersion;
%rename (Constraint) operations_research::MPConstraint;
%rename (Variable) operations_research::MPVariable;
%rename (Objective) operations_research::MPObjective;

View File

@@ -51,6 +51,7 @@ def main():
# [END objective]
# [START solve]
print(f'Solving with {solver.SolverVersion()}')
status = solver.Solve()
# [END solve]

View File

@@ -21,7 +21,7 @@ from ortools.linear_solver import pywraplp
def main():
# [START solver]
# Create the mip solver with the SCIP backend.
solver = pywraplp.Solver.CreateSolver('SCIP')
solver = pywraplp.Solver.CreateSolver('SAT')
if not solver:
return
# [END solver]
@@ -51,6 +51,7 @@ def main():
# [END objective]
# [START solve]
print(f'Solving with {solver.SolverVersion()}')
status = solver.Solve()
# [END solve]

View File

@@ -21,7 +21,6 @@
#include "absl/base/attributes.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "ortools/base/hash.h"
#include "ortools/base/integral_types.h"
#include "ortools/base/logging.h"
#include "ortools/linear_solver/linear_solver.h"
@@ -29,19 +28,9 @@
#include "ortools/linear_solver/proto_solver/sat_proto_solver.h"
#include "ortools/port/proto_utils.h"
#include "ortools/sat/cp_model.pb.h"
#include "ortools/sat/cp_model_solver.h"
#include "ortools/sat/lp_utils.h"
#include "ortools/sat/model.h"
#include "ortools/util/time_limit.h"
namespace operations_research {
#if defined(PROTOBUF_INTERNAL_IMPL)
using google::protobuf::Message;
#else
using google::protobuf::Message;
#endif
class SatInterface : public MPSolverInterface {
public:
explicit SatInterface(MPSolver* const solver);
@@ -254,9 +243,7 @@ bool SatInterface::IsContinuous() const { return false; }
bool SatInterface::IsLP() const { return false; }
bool SatInterface::IsMIP() const { return true; }
std::string SatInterface::SolverVersion() const {
return "SAT Based MIP Solver";
}
std::string SatInterface::SolverVersion() const { return SatSolverVersion(); }
void* SatInterface::underlying_solver() { return nullptr; }

View File

@@ -169,6 +169,11 @@ ABSL_FLAG(bool, cp_model_fingerprint_model, true, "Fingerprint the model.");
namespace operations_research {
namespace sat {
std::string CpSatSolverVersion() {
return absl::StrCat("CP-SAT solver v", OrToolsMajorVersion(), ".",
OrToolsMinorVersion(), ".", OrToolsPatchVersion());
}
namespace {
// Makes the string fit in one line by cutting it in the middle if necessary.
@@ -3440,8 +3445,7 @@ CpSolverResponse SolveCpModel(const CpModelProto& model_proto, Model* model) {
#endif // __PORTABLE_PLATFORM__
SOLVER_LOG(logger, "");
SOLVER_LOG(logger, "Starting CP-SAT solver v", OrToolsMajorVersion(), ".",
OrToolsMinorVersion(), ".", OrToolsPatchVersion());
SOLVER_LOG(logger, "Starting ", CpSatSolverVersion());
SOLVER_LOG(logger, "Parameters: ", params.ShortDebugString());
// Update params.num_workers() if the old field was used.

View File

@@ -26,6 +26,9 @@
namespace operations_research {
namespace sat {
/// Returns a string that describes the version of the solver.
std::string CpSatSolverVersion();
/// Solves the given CpModelProto and returns an instance of CpSolverResponse.
CpSolverResponse Solve(const CpModelProto& model_proto);