Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
solve.cc File Reference
#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 []
 

Function Documentation

◆ ABSL_DECLARE_FLAG() [1/3]

ABSL_DECLARE_FLAG ( bool ,
linear_solver_enable_verbose_output  )

◆ ABSL_DECLARE_FLAG() [2/3]

ABSL_DECLARE_FLAG ( bool ,
log_verification_errors  )

◆ ABSL_DECLARE_FLAG() [3/3]

ABSL_DECLARE_FLAG ( bool ,
verify_solution  )

◆ 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 420 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 130 of file solve.cc.

◆ time_limit

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

http://www.apache.org/licenses/LICENSE-2.0

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.

  1. To run SCIP for 90 seconds, dumping available information use:

solve –solver=scip \

Definition at line 22 of file solve.cc.