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
22
#include "
ortools/math_opt/core/non_streamable_solver_init_arguments.h
"
// IWYU pragma: export
23
#include "
ortools/math_opt/cpp/streamable_solver_init_arguments.h
"
// IWYU pragma: export
24
25
namespace
operations_research::math_opt
{
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
//
56
struct
SolverInitArguments
{
57
SolverInitArguments
() =
default
;
58
59
// Initializes this class with the provided streamable arguments.
60
explicit
SolverInitArguments
(
StreamableSolverInitArguments
streamable
);
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
(
69
const
NonStreamableSolverInitArguments
&
non_streamable
);
70
71
// Initializes this class with both the provided streamable arguments and a
72
// clone of the non-streamable ones.
73
SolverInitArguments
(
StreamableSolverInitArguments
streamable
,
74
const
NonStreamableSolverInitArguments
&
non_streamable
);
75
76
// Initializes this class as a copy of the provided arguments. The
77
// non_streamable field is cloned if not nullptr.
78
SolverInitArguments
(
const
SolverInitArguments
& other);
79
80
// Sets this class as a copy of the provided arguments. The non_streamable
81
// field is cloned if not nullptr.
82
SolverInitArguments
&
operator=
(
const
SolverInitArguments
& other);
83
84
SolverInitArguments
(
SolverInitArguments
&&) =
default
;
85
SolverInitArguments
&
operator=
(
SolverInitArguments
&&) =
default
;
86
87
StreamableSolverInitArguments
streamable
;
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_
operations_research::math_opt
Definition:
indicator_constraint.cc:26
non_streamable_solver_init_arguments.h
streamable_solver_init_arguments.h
operations_research::math_opt::NonStreamableSolverInitArguments
Definition:
non_streamable_solver_init_arguments.h:48
operations_research::math_opt::SolverInitArguments
Definition:
solver_init_arguments.h:56
operations_research::math_opt::SolverInitArguments::SolverInitArguments
SolverInitArguments(SolverInitArguments &&)=default
operations_research::math_opt::SolverInitArguments::SolverInitArguments
SolverInitArguments()=default
operations_research::math_opt::SolverInitArguments::operator=
SolverInitArguments & operator=(const SolverInitArguments &other)
Definition:
solver_init_arguments.cc:41
operations_research::math_opt::SolverInitArguments::non_streamable
std::unique_ptr< const NonStreamableSolverInitArguments > non_streamable
Definition:
solver_init_arguments.h:93
operations_research::math_opt::SolverInitArguments::streamable
StreamableSolverInitArguments streamable
Definition:
solver_init_arguments.h:87
operations_research::math_opt::SolverInitArguments::operator=
SolverInitArguments & operator=(SolverInitArguments &&)=default
operations_research::math_opt::StreamableSolverInitArguments
Definition:
streamable_solver_init_arguments.h:86
ortools
math_opt
cpp
solver_init_arguments.h
Generated by
1.9.1