OR-Tools  9.0
init.h
Go to the documentation of this file.
1 #include <string>
2 #include <vector>
3 
4 #include "absl/flags/flag.h"
5 #include "ortools/base/logging.h"
8 
9 ABSL_DECLARE_FLAG(std::string, cp_model_dump_prefix);
10 ABSL_DECLARE_FLAG(bool, cp_model_dump_models);
11 ABSL_DECLARE_FLAG(bool, cp_model_dump_lns);
12 ABSL_DECLARE_FLAG(bool, cp_model_dump_response);
13 
14 
15 namespace operations_research {
16 
20 struct CppFlags {
24  bool logtostderr = false;
25 
29  bool log_prefix = false;
30 
34  std::string cp_model_dump_prefix;
42  bool cp_model_dump_models = false;
43 
51 
59 };
60 
66 class CppBridge {
67  public:
73  static void InitLogging(const std::string& program_name) {
74  google::InitGoogleLogging(program_name.c_str());
75  }
76 
83  static void ShutdownLogging() {
85  }
86 
90  static void SetFlags(const CppFlags& flags) {
91  absl::SetFlag(&FLAGS_logtostderr, flags.logtostderr);
92  absl::SetFlag(&FLAGS_log_prefix, flags.log_prefix);
93  if (!flags.cp_model_dump_prefix.empty()) {
94  absl::SetFlag(&FLAGS_cp_model_dump_prefix, flags.cp_model_dump_prefix);
95  }
96  absl::SetFlag(&FLAGS_cp_model_dump_models, flags.cp_model_dump_models);
97  absl::SetFlag(&FLAGS_cp_model_dump_lns, flags.cp_model_dump_lns);
98  absl::SetFlag(&FLAGS_cp_model_dump_response, flags.cp_model_dump_response);
99  }
100 
109  static bool LoadGurobiSharedLibrary(const std::string& full_library_path) {
110  return LoadGurobiDynamicLibrary({full_library_path}).ok();
111  }
112 };
113 
114 } // namespace operations_research
This class performs various C++ initialization.
Definition: init.h:66
static void InitLogging(const std::string &program_name)
Initialize the C++ logging layer.
Definition: init.h:73
static bool LoadGurobiSharedLibrary(const std::string &full_library_path)
Load the gurobi shared library.
Definition: init.h:109
static void ShutdownLogging()
Shutdown the C++ logging layer.
Definition: init.h:83
static void SetFlags(const CppFlags &flags)
Sets all the C++ flags contained in the CppFlags structure.
Definition: init.h:90
ABSL_DECLARE_FLAG(std::string, cp_model_dump_prefix)
void InitGoogleLogging(const char *argv0)
void ShutdownGoogleLogging()
Collection of objects used to extend the Constraint Solver library.
absl::Status LoadGurobiDynamicLibrary(std::vector< std::string > potential_paths)
Definition: environment.cc:721
Simple structure that holds useful C++ flags to setup from non-C++ languages.
Definition: init.h:20
bool cp_model_dump_lns
DEBUG ONLY: Dump CP-SAT LNS models during solve.
Definition: init.h:50
bool cp_model_dump_response
DEBUG ONLY: Dump the CP-SAT final response found during solve.
Definition: init.h:58
bool cp_model_dump_models
DEBUG ONLY: Dump CP-SAT models during solve.
Definition: init.h:42
bool log_prefix
Controls is time and source code info are used to prefix logging messages.
Definition: init.h:29
bool logtostderr
If true, all logging message will be sent to stderr.
Definition: init.h:24
std::string cp_model_dump_prefix
Prefix filename for all dumped files (models, solutions, lns sub-models).
Definition: init.h:34