sync with google code

This commit is contained in:
Corentin Le Molgat
2022-01-27 16:35:42 +01:00
parent d426cef8ef
commit 683d1d12e1
15 changed files with 68 additions and 45 deletions

View File

@@ -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_;
};

View File

@@ -92,4 +92,5 @@ class CallPyDecisionBuilder : public operations_research::DecisionBuilder {
PyObject* str_func_;
};
#endif // OR_TOOLS_CONSTRAINT_SOLVER_PYTHON_PYWRAPCP_UTIL_H_

View File

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

View File

@@ -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",
],
)

View File

@@ -22,6 +22,10 @@
#include <cstdint>
#include <vector>
#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;
}

View File

@@ -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 <iomanip>
#include <numeric> // std::iota
#include <string>
#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;
}

View File

@@ -19,6 +19,7 @@
#include <sstream>
#include <vector>
#include "ortools/base/logging.h"
#include "ortools/constraint_solver/constraint_solver.h"
// [END import]

View File

@@ -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 <numeric> // 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;
}

View File

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

View File

@@ -13,6 +13,8 @@
// [START program]
// [START import]
#include <string>
#include "ortools/constraint_solver/constraint_solver.h"
// [END import]

View File

@@ -28,9 +28,8 @@
#include <vector>
#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"

View File

@@ -18,9 +18,8 @@
#include <string>
#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"

View File

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

View File

@@ -20,9 +20,9 @@
#include <vector>
#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;

View File

@@ -91,6 +91,7 @@
#ifndef OR_TOOLS_MATH_OPT_CPP_MATCHERS_H_
#define OR_TOOLS_MATH_OPT_CPP_MATCHERS_H_
#include <optional>
#include <sstream>
#include <vector>