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