diff --git a/ortools/constraint_solver/local_search.cc b/ortools/constraint_solver/local_search.cc index 088205cfa6..3dace2fbc9 100644 --- a/ortools/constraint_solver/local_search.cc +++ b/ortools/constraint_solver/local_search.cc @@ -2162,7 +2162,9 @@ class MultiArmedBanditCompoundOperator : public LocalSearchOperator { // Sets how often we explore rarely used and unsuccessful in the past // operators. Operators are sorted by // avg_improvement_[i] + exploration_coefficient_ * - // sqrt(2 * log(1 + num_neighbors_) / (1 + num_neighbors_per_operator_[i])); + // sqrt(2 * log(1 + num_neighbors_) / (1 + num_neighbors_per_operator_[i])). + // This definition uses the UCB1 exploration bonus for unstructured + // multi-armed bandits. const double exploration_coefficient_; }; diff --git a/ortools/constraint_solver/python/pywrapcp_util.h b/ortools/constraint_solver/python/pywrapcp_util.h index 46d64b4ec2..c792581396 100644 --- a/ortools/constraint_solver/python/pywrapcp_util.h +++ b/ortools/constraint_solver/python/pywrapcp_util.h @@ -92,4 +92,5 @@ class CallPyDecisionBuilder : public operations_research::DecisionBuilder { PyObject* str_func_; }; + #endif // OR_TOOLS_CONSTRAINT_SOLVER_PYTHON_PYWRAPCP_UTIL_H_ diff --git a/ortools/constraint_solver/samples/BUILD.bazel b/ortools/constraint_solver/samples/BUILD.bazel index 1f940e1706..75440f8d58 100644 --- a/ortools/constraint_solver/samples/BUILD.bazel +++ b/ortools/constraint_solver/samples/BUILD.bazel @@ -2,6 +2,8 @@ load(":code_samples.bzl", "code_sample_cc") code_sample_cc(name = "minimal_jobshop_cp") +code_sample_cc(name = "nqueens_cp") + code_sample_cc(name = "nurses_cp") code_sample_cc(name = "rabbits_and_pheasants_cp") @@ -20,12 +22,12 @@ code_sample_cc(name = "tsp_cities") code_sample_cc(name = "tsp_distance_matrix") +code_sample_cc(name = "vrp") + code_sample_cc(name = "vrp_breaks") code_sample_cc(name = "vrp_capacity") -code_sample_cc(name = "vrp") - code_sample_cc(name = "vrp_drop_nodes") code_sample_cc(name = "vrp_global_span") diff --git a/ortools/constraint_solver/samples/code_samples.bzl b/ortools/constraint_solver/samples/code_samples.bzl index 7a7240df59..6f838b54b0 100644 --- a/ortools/constraint_solver/samples/code_samples.bzl +++ b/ortools/constraint_solver/samples/code_samples.bzl @@ -1,28 +1,29 @@ """Helper macro to compile and test code samples.""" def code_sample_cc(name): - native.cc_binary( - name = name, - srcs = [name + ".cc"], - deps = [ - "//ortools/base", - "//ortools/constraint_solver:cp", - "//ortools/constraint_solver:routing", - "//ortools/constraint_solver:routing_enums_cc_proto", - "//ortools/constraint_solver:routing_flags", - ], - ) + native.cc_binary( + name = name, + srcs = [name + ".cc"], + deps = [ + "//ortools/base", + "//ortools/constraint_solver:cp", + "//ortools/constraint_solver:routing", + "//ortools/constraint_solver:routing_enums_cc_proto", + "//ortools/constraint_solver:routing_flags", + ], + ) + + native.cc_test( + name = name+"_test", + size = "small", + srcs = [name + ".cc"], + deps = [ + ":"+name, + "//ortools/base", + "//ortools/constraint_solver:cp", + "//ortools/constraint_solver:routing", + "//ortools/constraint_solver:routing_enums_cc_proto", + "//ortools/constraint_solver:routing_flags", + ], + ) - native.cc_test( - name = name + "_test", - size = "small", - srcs = [name + ".cc"], - deps = [ - ":" + name, - "//ortools/base", - "//ortools/constraint_solver:cp", - "//ortools/constraint_solver:routing", - "//ortools/constraint_solver:routing_enums_cc_proto", - "//ortools/constraint_solver:routing_flags", - ], - ) diff --git a/ortools/constraint_solver/samples/cp_is_fun_cp.cc b/ortools/constraint_solver/samples/cp_is_fun_cp.cc index e089a0eefb..746951b7a2 100644 --- a/ortools/constraint_solver/samples/cp_is_fun_cp.cc +++ b/ortools/constraint_solver/samples/cp_is_fun_cp.cc @@ -22,6 +22,10 @@ #include #include +#include "absl/flags/flag.h" +#include "ortools/base/init_google.h" +#include "ortools/base/logging.h" +#include "ortools/base/logging_flags.h" #include "ortools/constraint_solver/constraint_solver.h" // [END import] @@ -153,6 +157,8 @@ void CPIsFunCp() { } // namespace operations_research int main(int argc, char** argv) { + InitGoogle(argv[0], &argc, &argv, true); + absl::SetFlag(&FLAGS_logtostderr, true); operations_research::CPIsFunCp(); return EXIT_SUCCESS; } diff --git a/ortools/constraint_solver/samples/minimal_jobshop_cp.cc b/ortools/constraint_solver/samples/minimal_jobshop_cp.cc index b1de44a1d8..6469cdacf9 100644 --- a/ortools/constraint_solver/samples/minimal_jobshop_cp.cc +++ b/ortools/constraint_solver/samples/minimal_jobshop_cp.cc @@ -1,4 +1,4 @@ -// Copyright 2018 Google LLC +// Copyright 2010-2021 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 @@ -13,8 +13,12 @@ #include #include // std::iota +#include +#include "absl/flags/flag.h" +#include "ortools/base/init_google.h" #include "ortools/base/logging.h" +#include "ortools/base/logging_flags.h" #include "ortools/constraint_solver/constraint_solver.h" // Solve a job shop problem: @@ -187,8 +191,8 @@ void SolveJobShopExample() { } // namespace operations_research int main(int argc, char** argv) { - google::InitGoogleLogging(argv[0]); - absl::SetFlag(&FLAGS_logtostderr, 1); + InitGoogle(argv[0], &argc, &argv, true); + absl::SetFlag(&FLAGS_logtostderr, true); operations_research::SolveJobShopExample(); return EXIT_SUCCESS; } diff --git a/ortools/constraint_solver/samples/nqueens_cp.cc b/ortools/constraint_solver/samples/nqueens_cp.cc index e75b44e3bb..62f3dc3c21 100644 --- a/ortools/constraint_solver/samples/nqueens_cp.cc +++ b/ortools/constraint_solver/samples/nqueens_cp.cc @@ -19,6 +19,7 @@ #include #include +#include "ortools/base/logging.h" #include "ortools/constraint_solver/constraint_solver.h" // [END import] diff --git a/ortools/constraint_solver/samples/nurses_cp.cc b/ortools/constraint_solver/samples/nurses_cp.cc index 790be18211..8d2242e749 100644 --- a/ortools/constraint_solver/samples/nurses_cp.cc +++ b/ortools/constraint_solver/samples/nurses_cp.cc @@ -1,4 +1,4 @@ -// Copyright 2018 Google LLC +// Copyright 2010-2021 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 @@ -13,7 +13,10 @@ #include // std::iota +#include "absl/flags/flag.h" +#include "ortools/base/init_google.h" #include "ortools/base/logging.h" +#include "ortools/base/logging_flags.h" #include "ortools/constraint_solver/constraint_solver.h" namespace operations_research { @@ -197,8 +200,8 @@ void SolveNursesExample() { } // namespace operations_research int main(int argc, char** argv) { - google::InitGoogleLogging(argv[0]); - absl::SetFlag(&FLAGS_logtostderr, 1); + InitGoogle(argv[0], &argc, &argv, true); + absl::SetFlag(&FLAGS_logtostderr, true); operations_research::SolveNursesExample(); return EXIT_SUCCESS; } diff --git a/ortools/constraint_solver/samples/rabbits_and_pheasants_cp.cc b/ortools/constraint_solver/samples/rabbits_and_pheasants_cp.cc index e559b9e555..49d41ba3b6 100644 --- a/ortools/constraint_solver/samples/rabbits_and_pheasants_cp.cc +++ b/ortools/constraint_solver/samples/rabbits_and_pheasants_cp.cc @@ -1,4 +1,4 @@ -// Copyright 2018 Google LLC +// Copyright 2010-2021 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 @@ -13,8 +13,10 @@ // Knowing that we see 20 heads and 56 legs, // how many pheasants and rabbits are we looking at ? - +#include "absl/flags/flag.h" +#include "ortools/base/init_google.h" #include "ortools/base/logging.h" +#include "ortools/base/logging_flags.h" #include "ortools/constraint_solver/constraint_solver.h" namespace operations_research { @@ -57,8 +59,8 @@ void RunConstraintProgrammingExample() { } // namespace operations_research int main(int argc, char** argv) { - google::InitGoogleLogging(argv[0]); - absl::SetFlag(&FLAGS_logtostderr, 1); + InitGoogle(argv[0], &argc, &argv, true); + absl::SetFlag(&FLAGS_logtostderr, true); operations_research::RunConstraintProgrammingExample(); return EXIT_SUCCESS; } diff --git a/ortools/constraint_solver/samples/simple_cp_program.cc b/ortools/constraint_solver/samples/simple_cp_program.cc index 7c0d88475e..09785929ee 100644 --- a/ortools/constraint_solver/samples/simple_cp_program.cc +++ b/ortools/constraint_solver/samples/simple_cp_program.cc @@ -13,6 +13,8 @@ // [START program] // [START import] +#include + #include "ortools/constraint_solver/constraint_solver.h" // [END import] diff --git a/ortools/flatzinc/fz.cc b/ortools/flatzinc/fz.cc index ecfce327a3..84b5d25671 100644 --- a/ortools/flatzinc/fz.cc +++ b/ortools/flatzinc/fz.cc @@ -28,9 +28,8 @@ #include #include "absl/flags/flag.h" -#include "absl/flags/parse.h" -#include "absl/flags/usage.h" #include "ortools/base/commandlineflags.h" +#include "ortools/base/init_google.h" #include "ortools/base/integral_types.h" #include "ortools/base/logging.h" #include "ortools/base/threadpool.h" diff --git a/ortools/flatzinc/parser_main.cc b/ortools/flatzinc/parser_main.cc index a4435742ae..48439e6eca 100644 --- a/ortools/flatzinc/parser_main.cc +++ b/ortools/flatzinc/parser_main.cc @@ -18,9 +18,8 @@ #include #include "absl/flags/flag.h" -#include "absl/flags/parse.h" -#include "absl/flags/usage.h" #include "ortools/base/commandlineflags.h" +#include "ortools/base/init_google.h" #include "ortools/base/timer.h" #include "ortools/flatzinc/model.h" #include "ortools/flatzinc/parser.h" diff --git a/ortools/linear_solver/linear_solver.proto b/ortools/linear_solver/linear_solver.proto index 2c47324bc3..89bb49d019 100644 --- a/ortools/linear_solver/linear_solver.proto +++ b/ortools/linear_solver/linear_solver.proto @@ -34,6 +34,7 @@ option java_multiple_files = true; import "ortools/util/optional_boolean.proto"; + package operations_research; // A variable is always constrained in the form: diff --git a/ortools/linear_solver/samples/stigler_diet.cc b/ortools/linear_solver/samples/stigler_diet.cc index 52a7dd6480..22841440e1 100644 --- a/ortools/linear_solver/samples/stigler_diet.cc +++ b/ortools/linear_solver/samples/stigler_diet.cc @@ -20,9 +20,9 @@ #include #include "absl/flags/flag.h" -#include "absl/flags/parse.h" -#include "absl/flags/usage.h" +#include "ortools/base/init_google.h" #include "ortools/base/logging.h" +#include "ortools/base/logging_flags.h" #include "ortools/linear_solver/linear_solver.h" // [END import] @@ -318,8 +318,7 @@ void StiglerDiet() { } // namespace operations_research int main(int argc, char** argv) { - google::InitGoogleLogging(argv[0]); - absl::ParseCommandLine(argc, argv); + InitGoogle(argv[0], &argc, &argv, true); absl::SetFlag(&FLAGS_logtostderr, true); operations_research::StiglerDiet(); return EXIT_SUCCESS; diff --git a/ortools/math_opt/cpp/matchers.h b/ortools/math_opt/cpp/matchers.h index 1b13e11dd7..4c4d95cf21 100644 --- a/ortools/math_opt/cpp/matchers.h +++ b/ortools/math_opt/cpp/matchers.h @@ -91,6 +91,7 @@ #ifndef OR_TOOLS_MATH_OPT_CPP_MATCHERS_H_ #define OR_TOOLS_MATH_OPT_CPP_MATCHERS_H_ +#include #include #include