Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
#include <iostream>
#include <memory>
#include <optional>
#include <ostream>
#include <string>
#include <utility>
#include <vector>
#include "absl/base/no_destructor.h"
#include "absl/flags/flag.h"
#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_join.h"
#include "absl/strings/string_view.h"
#include "absl/time/clock.h"
#include "absl/time/time.h"
#include "ortools/base/helpers.h"
#include "ortools/base/init_google.h"
#include "ortools/base/logging.h"
#include "ortools/base/options.h"
#include "ortools/base/status_macros.h"
#include "ortools/math_opt/core/solver_interface.h"
#include "ortools/math_opt/cpp/math_opt.h"
#include "ortools/math_opt/cpp/statistics.h"
#include "ortools/math_opt/io/names_removal.h"
#include "ortools/math_opt/labs/solution_feasibility_checker.h"
#include "ortools/math_opt/parameters.pb.h"
#include "ortools/math_opt/tools/file_format_flags.h"
#include "ortools/util/sigint.h"
#include "ortools/util/status_macros.h"
Go to the source code of this file.
Namespaces | |
namespace | operations_research |
In SWIG mode, we don't want anything besides these top-level includes. | |
namespace | operations_research::math_opt |
An object oriented wrapper for quadratic constraints in ModelStorage. | |
Functions | |
ABSL_FLAG (std::string, input_file, "", "the file containing the model to solve; use --format to specify the " "file format") | |
ABSL_FLAG (std::optional< operations_research::math_opt::FileFormat >, format, std::nullopt, absl::StrCat("the format of the --input_file; possible values:", operations_research::math_opt::OptionalFormatFlagPossibleValuesList())) | |
ABSL_FLAG (std::vector< std::string >, update_files, {}, absl::StrCat("the file containing ModelUpdateProto to apply to the --input_file; " "when this flag is used, the --format must be either ", AbslUnparseFlag(operations_research::math_opt::FileFormat::kMathOptBinary), " or ", AbslUnparseFlag(operations_research::math_opt::FileFormat::kMathOptText))) | |
ABSL_FLAG (operations_research::math_opt::SolverType, solver_type, operations_research::math_opt::SolverType::kGscip, absl::StrCat("the solver to use, possible values: ", absl::StrJoin(operations_research::math_opt::AllSolversRegistry::Instance() ->RegisteredSolvers(), ", ", SolverTypeProtoFormatter()))) | |
ABSL_FLAG (bool, remote, false, "solve by RPC instead of locally, using ~twice the time limit as the " "RPC deadline, requires a time limit is set, see --time_limit") | |
ABSL_FLAG (operations_research::math_opt::SolveParameters, solve_parameters, {}, "SolveParameters in text-proto format. Note that the time limit is " "overridden by the --time_limit flag.") | |
ABSL_FLAG (bool, solver_logs, false, "use a message callback to print the solver convergence logs") | |
ABSL_FLAG (absl::Duration, time_limit, absl::InfiniteDuration(), "the time limit to use for the solve") | |
ABSL_FLAG (bool, sigint_interrupt, true, "interrupts the solve on the first SIGINT; kill the process on the " "third one") | |
ABSL_FLAG (bool, names, true, "use the names in the input models; ignoring names is useful when " "the input contains duplicates") | |
ABSL_FLAG (bool, ranges, false, "prints statistics about the ranges of the model values") | |
ABSL_FLAG (bool, print_model, false, "prints the model to stdout") | |
ABSL_FLAG (bool, lp_relaxation, false, "relax all integer variables to continuous") | |
ABSL_FLAG (bool, check_solutions, false, "check the solutions feasibility; use --absolute_constraint_tolerance, " "--integrality_tolerance, and --nonzero_tolerance values for tolerances") | |
ABSL_FLAG (double, absolute_constraint_tolerance, operations_research::math_opt::FeasibilityCheckerOptions{} .absolute_constraint_tolerance, "feasibility tolerance for constraints and variables bounds") | |
ABSL_FLAG (double, integrality_tolerance, operations_research::math_opt::FeasibilityCheckerOptions{} .integrality_tolerance, "feasibility tolerance for variables' integrality") | |
ABSL_FLAG (double, nonzero_tolerance, operations_research::math_opt::FeasibilityCheckerOptions{} .nonzero_tolerance, "tolerance for checking if a value is nonzero (e.g., in SOS constraints)") | |
int | main (int argc, char *argv[]) |
ABSL_FLAG | ( | absl::Duration | , |
time_limit | , | ||
absl::InfiniteDuration() | , | ||
"the time limit to use for the solve" | ) |
ABSL_FLAG | ( | bool | , |
check_solutions | , | ||
false | , | ||
"check the solutions feasibility; use -- | absolute_constraint_tolerance, | ||
" "-- | integrality_tolerance, | ||
and --nonzero_tolerance values for tolerances" | ) |
ABSL_FLAG | ( | bool | , |
lp_relaxation | , | ||
false | , | ||
"relax all integer variables to continuous" | ) |
ABSL_FLAG | ( | bool | , |
names | , | ||
true | , | ||
"use the names in the input models; ignoring names is useful when " "the input contains duplicates" | ) |
ABSL_FLAG | ( | bool | , |
ranges | , | ||
false | , | ||
"prints statistics about the ranges of the model values" | ) |
ABSL_FLAG | ( | bool | , |
remote | , | ||
false | , | ||
"solve by RPC instead of | locally, | ||
using ~twice the time limit as the " "RPC | deadline, | ||
requires a time limit is | set, | ||
see --time_limit" | ) |
ABSL_FLAG | ( | bool | , |
sigint_interrupt | , | ||
true | , | ||
"interrupts the solve on the first SIGINT; kill the process on the " "third one" | ) |
ABSL_FLAG | ( | bool | , |
solver_logs | , | ||
false | , | ||
"use a message callback to print the solver convergence logs" | ) |
ABSL_FLAG | ( | double | , |
absolute_constraint_tolerance | , | ||
operations_research::math_opt::FeasibilityCheckerOptions{} . | absolute_constraint_tolerance, | ||
"feasibility tolerance for constraints and variables bounds" | ) |
ABSL_FLAG | ( | double | , |
integrality_tolerance | , | ||
operations_research::math_opt::FeasibilityCheckerOptions{} . | integrality_tolerance, | ||
"feasibility tolerance for variables' integrality" | ) |
ABSL_FLAG | ( | double | , |
nonzero_tolerance | , | ||
operations_research::math_opt::FeasibilityCheckerOptions{} . | nonzero_tolerance, | ||
"tolerance for checking if a value is nonzero (e.g., in SOS constraints)" | ) |
ABSL_FLAG | ( | operations_research::math_opt::SolveParameters | , |
solve_parameters | , | ||
{} | , | ||
"SolveParameters in text-proto format. Note that the time limit is " "overridden by the --time_limit flag." | ) |
ABSL_FLAG | ( | operations_research::math_opt::SolverType | , |
solver_type | , | ||
operations_research::math_opt::SolverType::kGscip | , | ||
absl::StrCat("the solver to use, possible values: ", absl::StrJoin(operations_research::math_opt::AllSolversRegistry::Instance() ->RegisteredSolvers(), ", ", SolverTypeProtoFormatter())) | ) |
ABSL_FLAG | ( | std::optional< operations_research::math_opt::FileFormat > | , |
format | , | ||
std::nullopt | , | ||
absl::StrCat("the format of the --input_file; possible values:", operations_research::math_opt::OptionalFormatFlagPossibleValuesList()) | ) |
ABSL_FLAG | ( | std::string | , |
input_file | , | ||
"" | , | ||
"the file containing the model to solve; use --format to specify the " "file format" | ) |
ABSL_FLAG | ( | std::vector< std::string > | , |
update_files | , | ||
{} | , | ||
absl::StrCat("the file containing ModelUpdateProto to apply to the --input_file; " "when this flag is used, the --format must be either ", AbslUnparseFlag(operations_research::math_opt::FileFormat::kMathOptBinary), " or ", AbslUnparseFlag(operations_research::math_opt::FileFormat::kMathOptText)) | ) |
int main | ( | int | argc, |
char * | argv[] ) |
We don't use QCHECK_OK() here since the logged message contains more than the failing status.
Definition at line 366 of file mathopt_solve.cc.
std::optional<ModelSolveParameters::SolutionHint> hint |
Definition at line 160 of file mathopt_solve.cc.
std::unique_ptr<Model> model |
Definition at line 159 of file mathopt_solve.cc.