rework ortools samples (#4590)

This commit is contained in:
Corentin Le Molgat
2025-05-16 14:34:40 +02:00
parent 17498776bf
commit fdfc6af03e
62 changed files with 343 additions and 93 deletions

View File

@@ -148,8 +148,8 @@ void CPIsFunCp() {
} // namespace operations_research
int main(int argc, char** argv) {
absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo);
InitGoogle(argv[0], &argc, &argv, true);
absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo);
operations_research::CPIsFunCp();
return EXIT_SUCCESS;
}

View File

@@ -198,8 +198,8 @@ void SolveJobShopExample() {
} // namespace operations_research
int main(int argc, char** argv) {
absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo);
InitGoogle(argv[0], &argc, &argv, true);
absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo);
operations_research::SolveJobShopExample();
return EXIT_SUCCESS;
}

View File

@@ -19,6 +19,9 @@
#include <sstream>
#include <vector>
#include "absl/base/log_severity.h"
#include "absl/log/globals.h"
#include "ortools/base/init_google.h"
#include "ortools/base/logging.h"
#include "ortools/constraint_solver/constraint_solver.h"
// [END import]
@@ -102,7 +105,9 @@ void NQueensCp(const int board_size) {
} // namespace operations_research
int main(int argc, char** argv) {
int main(int argc, char* argv[]) {
InitGoogle(argv[0], &argc, &argv, true);
absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo);
int board_size = 8;
if (argc > 1) {
board_size = std::atoi(argv[1]);

View File

@@ -205,8 +205,8 @@ void SolveNursesExample() {
} // namespace operations_research
int main(int argc, char** argv) {
absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo);
InitGoogle(argv[0], &argc, &argv, true);
absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo);
operations_research::SolveNursesExample();
return EXIT_SUCCESS;
}

View File

@@ -61,8 +61,8 @@ void RunConstraintProgrammingExample() {
} // namespace operations_research
int main(int argc, char** argv) {
absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo);
InitGoogle(argv[0], &argc, &argv, true);
absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo);
operations_research::RunConstraintProgrammingExample();
return EXIT_SUCCESS;
}

View File

@@ -16,6 +16,9 @@
#include <ostream>
#include <string>
#include "absl/base/log_severity.h"
#include "absl/log/globals.h"
#include "ortools/base/init_google.h"
#include "ortools/constraint_solver/constraint_solver.h"
// [END import]
@@ -73,7 +76,9 @@ void SimpleCpProgram() {
} // namespace operations_research
int main(int /*argc*/, char* /*argv*/[]) {
int main(int argc, char* argv[]) {
InitGoogle(argv[0], &argc, &argv, true);
absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo);
operations_research::SimpleCpProgram();
return EXIT_SUCCESS;
}

View File

@@ -202,8 +202,8 @@ void SolveProblem(SolveType solve_type) {
} // namespace operations_research
int main(int argc, char** argv) {
absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo);
InitGoogle(argv[0], &argc, &argv, true);
absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo);
operations_research::SolveProblem(operations_research::LNS);
operations_research::SolveProblem(operations_research::LS);
operations_research::SolveProblem(operations_research::LS_WITH_FILTER);