OR-Tools  9.3
solver_init_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_SOLVER_INIT_ARGUMENTS_H_
15#define OR_TOOLS_MATH_OPT_CPP_SOLVER_INIT_ARGUMENTS_H_
16
17#include <memory>
18
20#include "ortools/math_opt/cpp/streamable_solver_init_arguments.h" // IWYU pragma: export
21
23
24// Arguments passed to Solve() and IncrementalSolver::New() to control the
25// instantiation of the solver.
26//
27// For convenience, constructors with streamable or/and non-streamable arguments
28// are provided. The non-streamable arguments are cloned so any change made
29// after passing them to this class are ignored.
30//
31// Usage with streamable arguments:
32//
33// Solve(model, SOLVER_TYPE_GUROBI, /*solver_args=*/{},
34// SolverInitArguments({
35// .gurobi = StreamableGurobiInitArguments{
36// .isv_key = GurobiISVKey{
37// .name = "some name",
38// .application_name = "some app name",
39// .expiration = -1,
40// .key = "random",
41// }
42// }
43// });
44//
45// Usage with non-streamable arguments:
46//
47// NonStreamableGurobiInitArguments gurobi_args;
48// gurobi_args.master_env = master_env.get();
49//
50// Solve(model, SOLVER_TYPE_GUROBI, /*solver_args=*/{},
51// SolverInitArguments(gurobi_args));
52//
55
56 // Initializes this class with the provided streamable arguments.
58
59 // Initializes this class with a clone of the provided non-streamable
60 // arguments.
61 //
62 // Note that since this constructors calls Clone() to initialize the
63 // non_streamable_solver_init_arguments field, changes made after calling it
64 // to the input non_streamable are ignored.
65 explicit SolverInitArguments(
67
68 // Initializes this class with both the provided streamable arguments and a
69 // clone of the non-streamable ones.
72
73 // Initializes this class as a copy of the provided arguments. The
74 // non_streamable field is cloned if not nullptr.
76
77 // Sets this class as a copy of the provided arguments. The non_streamable
78 // field is cloned if not nullptr.
80
83
85
86 // This should either be the solver specific class or nullptr.
87 //
88 // Solvers will fail (by returning an absl::Status) if called with arguments
89 // for another solver.
90 std::unique_ptr<const NonStreamableSolverInitArguments> non_streamable;
91};
92
93} // namespace operations_research::math_opt
94
95#endif // OR_TOOLS_MATH_OPT_CPP_SOLVER_INIT_ARGUMENTS_H_
SolverInitArguments(SolverInitArguments &&)=default
SolverInitArguments & operator=(const SolverInitArguments &other)
SolverInitArguments & operator=(SolverInitArguments &&)=default
std::unique_ptr< const NonStreamableSolverInitArguments > non_streamable