Google OR-Tools v9.15
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
solve.cc File Reference
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <optional>
#include <string>
#include <utility>
#include "absl/flags/flag.h"
#include "absl/log/flags.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/clock.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
 OR-Tools root namespace.

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.")
int main (int argc, char **argv)

Variables

 stderrthreshold
static const char kUsageStr []

Function Documentation

◆ ABSL_FLAG() [1/14]

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() [2/14]

ABSL_FLAG ( bool ,
dump_gzip ,
false ,
"Whether to gzip dumped protos. Appends .gz to their name."  )

◆ ABSL_FLAG() [3/14]

ABSL_FLAG ( int ,
num_threads ,
1 ,
"Number of threads to use by the underlying solver."  )

◆ ABSL_FLAG() [4/14]

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() [5/14]

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() [6/14]

ABSL_FLAG ( std::string ,
dump_model ,
"" ,
"If non- empty,
dumps MPModelProto there."  )

◆ ABSL_FLAG() [7/14]

ABSL_FLAG ( std::string ,
dump_mps ,
"" ,
"If non- empty,
dumps the model in mps format there."  )

◆ ABSL_FLAG() [8/14]

ABSL_FLAG ( std::string ,
dump_request ,
"" ,
"If non- empty,
dumps MPModelRequest there."  )

◆ ABSL_FLAG() [9/14]

ABSL_FLAG ( std::string ,
dump_response ,
"" ,
"If non- empty,
dumps MPSolutionResponse there."  )

◆ ABSL_FLAG() [10/14]

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() [11/14]

ABSL_FLAG ( std::string ,
params ,
"" ,
"Solver specific parameters"  )

◆ ABSL_FLAG() [12/14]

ABSL_FLAG ( std::string ,
params_file ,
"" ,
"Solver specific parameters file. " "If this flag is set,
the --params flag is ignored."  )

◆ ABSL_FLAG() [13/14]

ABSL_FLAG ( std::string ,
sol_file ,
"" ,
"If non- empty,
output the best solution in Miplib .sol format."  )

◆ ABSL_FLAG() [14/14]

ABSL_FLAG ( std::string ,
sol_hint ,
"" ,
"Input file name with solution in .sol format."  )

◆ main()

int main ( int argc,
char ** argv )

Definition at line 411 of file solve.cc.

Variable Documentation

◆ kUsageStr

const char kUsageStr[]
static
Initial value:
=
"Run MPSolver on the given input file. Many formats are supported: \n"
" - a .mps or .mps.gz file,\n"
" - an MPModelProto (binary or text, possibly gzipped),\n"
" - an MPModelRequest (binary or text, possibly gzipped)."

Definition at line 125 of file solve.cc.

◆ stderrthreshold

stderrthreshold

Definition at line 23 of file solve.cc.