Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
solve_arguments.h
Go to the documentation of this file.
1// Copyright 2010-2024 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// IWYU pragma: private, include "ortools/math_opt/cpp/math_opt.h"
15// IWYU pragma: friend "ortools/math_opt/cpp/.*"
16
17#ifndef OR_TOOLS_MATH_OPT_CPP_SOLVE_ARGUMENTS_H_
18#define OR_TOOLS_MATH_OPT_CPP_SOLVE_ARGUMENTS_H_
19
20#include "absl/status/status.h"
21#include "ortools/math_opt/cpp/callback.h" // IWYU pragma: export
22#include "ortools/math_opt/cpp/message_callback.h" // IWYU pragma: export
23#include "ortools/math_opt/cpp/model_solve_parameters.h" // IWYU pragma: export
24#include "ortools/math_opt/cpp/parameters.h" // IWYU pragma: export
26#include "ortools/util/solve_interrupter.h" // IWYU pragma: export
27
29
30// Arguments passed to Solve() and IncrementalSolver::Solve() to control the
31// solve.
33 // Model independent parameters, e.g. time limit.
35
36 // Model dependent parameters, e.g. solution hint.
38
39 // An optional callback for messages emitted by the solver.
40 //
41 // When set it enables the solver messages and ignores the `enable_output` in
42 // solve parameters; messages are redirected to the callback and not printed
43 // on stdout/stderr/logs anymore.
44 //
45 // See PrinterMessageCallback() for logging to stdout/stderr.
46 //
47 // Usage:
48 //
49 // // To print messages to stdout with a prefix.
50 // ASSIGN_OR_RETURN(
51 // const SolveResult result,
52 // Solve(model, SolverType::kGlop,
53 // { .message_callback = PrinterMessageCallback(std::cout,
54 // "logs| "); });
56
57 // Callback registration parameters. Usually `callback` should also be set
58 // when these parameters are modified.
60
61 // The optional callback for LP/MIP events.
62 //
63 // The `callback_registration` parameters have to be set, in particular
64 // `callback_registration.events`.
65 //
66 // See callback.h file comment for documentation on callbacks.
67 Callback callback = nullptr;
68
69 // An optional interrupter that the solver can use to interrupt the solve
70 // early.
71 //
72 // Usage:
73 // auto interrupter = std::make_shared<SolveInterrupter>();
74 //
75 // // Use another thread to trigger the interrupter.
76 // RunInOtherThread([interrupter](){
77 // ... wait for something that should interrupt the solve ...
78 // interrupter->Interrupt();
79 // });
80 //
81 // ASSIGN_OR_RETURN(const SolveResult result,
82 // Solve(model, SolverType::kGlop,
83 // { .interrupter = interrupter.get() });
84 //
85 const SolveInterrupter* interrupter = nullptr;
86
87 // Returns a failure if the referenced variables and constraints don't belong
88 // to the input expected_storage (which must not be nullptr). Also returns a
89 // failure if callback events are registered but no callback is provided.
91 const ModelStorage* expected_storage) const;
92};
93
94} // namespace operations_research::math_opt
95
96#endif // OR_TOOLS_MATH_OPT_CPP_SOLVE_ARGUMENTS_H_
An object oriented wrapper for quadratic constraints in ModelStorage.
Definition gurobi_isv.cc:28
std::function< CallbackResult(const CallbackData &)> Callback
Definition callback.h:93
std::function< void(const std::vector< std::string > &)> MessageCallback
absl::Status CheckModelStorageAndCallback(const ModelStorage *expected_storage) const
ModelSolveParameters model_parameters
Model dependent parameters, e.g. solution hint.
SolveParameters parameters
Model independent parameters, e.g. time limit.