OR-Tools  9.3
solve_arguments.h
Go to the documentation of this file.
1// Copyright 2010-2021 Google LLC
2// Licensed under the Apache License, Version 2.0 (the "License");
3// you may not use this file except in compliance with the License.
4// You may obtain a copy of the License at
5//
6// http://www.apache.org/licenses/LICENSE-2.0
7//
8// Unless required by applicable law or agreed to in writing, software
9// distributed under the License is distributed on an "AS IS" BASIS,
10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11// See the License for the specific language governing permissions and
12// limitations under the License.
13
14#ifndef OR_TOOLS_MATH_OPT_CPP_SOLVE_ARGUMENTS_H_
15#define OR_TOOLS_MATH_OPT_CPP_SOLVE_ARGUMENTS_H_
16
17#include "ortools/math_opt/core/solve_interrupter.h" // IWYU pragma: export
18#include "ortools/math_opt/cpp/callback.h" // IWYU pragma: export
19#include "ortools/math_opt/cpp/message_callback.h" // IWYU pragma: export
20#include "ortools/math_opt/cpp/model_solve_parameters.h" // IWYU pragma: export
21#include "ortools/math_opt/cpp/parameters.h" // IWYU pragma: export
22
24
25// Arguments passed to Solve() and IncrementalSolver::Solve() to control the
26// solve.
28 // Model independent parameters, e.g. time limit.
30
31 // Model dependent parameters, e.g. solution hint.
33
34 // An optional callback for messages emitted by the solver.
35 //
36 // When set it enables the solver messages and ignores the `enable_output` in
37 // solve parameters; messages are redirected to the callback and not printed
38 // on stdout/stderr/logs anymore.
39 //
40 // See PrinterMessageCallback() for logging to stdout/stderr.
41 //
42 // Usage:
43 //
44 // // To print messages to stdout with a prefix.
45 // ASSIGN_OR_RETURN(
46 // const SolveResult result,
47 // Solve(model, SOLVER_TYPE_GLOP,
48 // { .message_callback = PrinterMessageCallback(std::cout,
49 // "logs| "); });
51
52 // Callback registration parameters. Usually `callback` should also be set
53 // when these parameters are modified.
55
56 // The optional callback for LP/MIP events.
57 //
58 // The `callback_registration` parameters have to be set, in particular
59 // `callback_registration.events`.
60 //
61 // See callback.h file comment for documentation on callbacks.
62 Callback callback = nullptr;
63
64 // An optional interrupter that the solver can use to interrupt the solve
65 // early.
66 //
67 // Usage:
68 // auto interrupter = std::make_shared<SolveInterrupter>();
69 //
70 // // Use another thread to trigger the interrupter.
71 // RunInOtherThread([interrupter](){
72 // ... wait for something that should interrupt the solve ...
73 // interrupter->Interrupt();
74 // });
75 //
76 // ASSIGN_OR_RETURN(const SolveResult result,
77 // Solve(model, SOLVER_TYPE_GLOP,
78 // { .interrupter = interrupter.get() });
79 //
81};
82
83} // namespace operations_research::math_opt
84
85#endif // OR_TOOLS_MATH_OPT_CPP_SOLVE_ARGUMENTS_H_
std::function< CallbackResult(const CallbackData &)> Callback
Definition: callback.h:89
std::function< void(const std::vector< std::string > &)> MessageCallback