Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
#include <cstdio>
#include <iostream>
#include <optional>
#include <string>
#include <utility>
#include "absl/flags/declare.h"
#include "absl/flags/flag.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/match.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h"
#include "absl/time/time.h"
#include "ortools/base/file.h"
#include "ortools/base/helpers.h"
#include "ortools/base/init_google.h"
#include "ortools/base/logging.h"
#include "ortools/base/options.h"
#include "ortools/linear_solver/linear_solver.h"
#include "ortools/linear_solver/linear_solver.pb.h"
#include "ortools/linear_solver/model_exporter.h"
#include "ortools/lp_data/lp_parser.h"
#include "ortools/lp_data/mps_reader.h"
#include "ortools/lp_data/sol_reader.h"
#include "ortools/sat/cp_model.pb.h"
#include "ortools/sat/cp_model_solver.h"
#include "ortools/util/file_util.h"
#include "ortools/util/sigint.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. | |
Functions | |
ABSL_FLAG (std::string, sol_hint, "", "Input file name with solution in .sol format.") | |
ABSL_FLAG (std::optional< std::string >, solver, std::nullopt, "The solver to use: bop, cbc, clp, glop, glpk_lp, glpk_mip, " "gurobi_lp, gurobi_mip, pdlp, scip, knapsack, sat. If unspecified " "either use MPModelRequest.solver_type if the --input is an " "MPModelRequest and the field is set or use glop.") | |
ABSL_FLAG (int, num_threads, 1, "Number of threads to use by the underlying solver.") | |
ABSL_FLAG (std::string, params_file, "", "Solver specific parameters file. " "If this flag is set, the --params flag is ignored.") | |
ABSL_FLAG (std::string, params, "", "Solver specific parameters") | |
ABSL_FLAG (absl::Duration, time_limit, absl::InfiniteDuration(), "It specifies a limit on the solving time. The duration must be must " "be positive. It default to an infinite duration meaning that no " "time limit will be imposed.") | |
ABSL_FLAG (std::string, output_csv, "", "If non-empty, write the returned solution in csv format with " "each line formed by a variable name and its value.") | |
ABSL_FLAG (std::string, dump_format, "text", "Format in which to dump protos (if flags --dump_model, " "--dump_request, or --dump_response are used). Possible values: " "'text', 'binary', 'json' which correspond to text proto format " "binary proto format, and json. If 'binary' or 'json' are used, " "we append '.bin' and '.json' to file names.") | |
ABSL_FLAG (bool, dump_gzip, false, "Whether to gzip dumped protos. Appends .gz to their name.") | |
ABSL_FLAG (std::string, dump_model, "", "If non-empty, dumps MPModelProto there.") | |
ABSL_FLAG (std::string, dump_request, "", "If non-empty, dumps MPModelRequest there.") | |
ABSL_FLAG (std::string, dump_response, "", "If non-empty, dumps MPSolutionResponse there.") | |
ABSL_FLAG (std::string, sol_file, "", "If non-empty, output the best solution in Miplib .sol format.") | |
ABSL_FLAG (std::string, dump_mps, "", "If non-empty, dumps the model in mps format there.") | |
ABSL_DECLARE_FLAG (bool, verify_solution) | |
ABSL_DECLARE_FLAG (bool, log_verification_errors) | |
ABSL_DECLARE_FLAG (bool, linear_solver_enable_verbose_output) | |
int | main (int argc, char **argv) |
Variables | |
time_limit | |
static const char | kUsageStr [] |
ABSL_DECLARE_FLAG | ( | bool | , |
linear_solver_enable_verbose_output | ) |
ABSL_DECLARE_FLAG | ( | bool | , |
log_verification_errors | ) |
ABSL_DECLARE_FLAG | ( | bool | , |
verify_solution | ) |
ABSL_FLAG | ( | absl::Duration | , |
time_limit | , | ||
absl::InfiniteDuration() | , | ||
"It specifies a limit on the solving time. The duration must be must " "be positive. It default to an infinite duration meaning that no " "time limit will be imposed." | ) |
ABSL_FLAG | ( | bool | , |
dump_gzip | , | ||
false | , | ||
"Whether to gzip dumped protos. Appends .gz to their name." | ) |
ABSL_FLAG | ( | int | , |
num_threads | , | ||
1 | , | ||
"Number of threads to use by the underlying solver." | ) |
ABSL_FLAG | ( | std::optional< std::string > | , |
solver | , | ||
std::nullopt | , | ||
"The solver to use: | bop, | ||
cbc | , | ||
clp | , | ||
glop | , | ||
glpk_lp | , | ||
glpk_mip | , | ||
" " | gurobi_lp, | ||
gurobi_mip | , | ||
pdlp | , | ||
scip | , | ||
knapsack | , | ||
sat. If unspecified " "either use MPModelRequest.solver_type if the --input is an " "MPModelRequest and the field is set or use glop." | ) |
ABSL_FLAG | ( | std::string | , |
dump_format | , | ||
"text" | , | ||
"Format in which to dump protos (if flags --dump_model, " "--dump_request, or --dump_response are used). Possible values: " "'text' | , | ||
'binary' | , | ||
'json' which correspond to text proto format " "binary proto | format, | ||
and json. If 'binary' or 'json' are | used, | ||
" "we append '.bin' and '.json' to file names." | ) |
ABSL_FLAG | ( | std::string | , |
dump_model | , | ||
"" | , | ||
"If non- | empty, | ||
dumps MPModelProto there." | ) |
ABSL_FLAG | ( | std::string | , |
dump_mps | , | ||
"" | , | ||
"If non- | empty, | ||
dumps the model in mps format there." | ) |
ABSL_FLAG | ( | std::string | , |
dump_request | , | ||
"" | , | ||
"If non- | empty, | ||
dumps MPModelRequest there." | ) |
ABSL_FLAG | ( | std::string | , |
dump_response | , | ||
"" | , | ||
"If non- | empty, | ||
dumps MPSolutionResponse there." | ) |
ABSL_FLAG | ( | std::string | , |
output_csv | , | ||
"" | , | ||
"If non- | empty, | ||
write the returned solution in csv format with " "each line formed by a variable name and its value." | ) |
ABSL_FLAG | ( | std::string | , |
params | , | ||
"" | , | ||
"Solver specific parameters" | ) |
ABSL_FLAG | ( | std::string | , |
params_file | , | ||
"" | , | ||
"Solver specific parameters file. " "If this flag is | set, | ||
the --params flag is ignored." | ) |
ABSL_FLAG | ( | std::string | , |
sol_file | , | ||
"" | , | ||
"If non- | empty, | ||
output the best solution in Miplib .sol format." | ) |
|
static |
time_limit |
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
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Command line interface to the MPSolver class. See linear_solver.h and kUsageStr below.
Examples.
solve –solver=scip \