OR-Tools  9.6
streamable_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 // This headers defines C++ wrappers of solver specific initialization
18 // parameters that can be streamed to be exchanged with another process.
19 //
20 // Parameters that can't be streamed (for example instances of C/C++ types that
21 // only exist in the process memory) are dealt with implementations of
22 // the NonStreamableSolverInitArguments.
23 #ifndef OR_TOOLS_MATH_OPT_CPP_STREAMABLE_SOLVER_INIT_ARGUMENTS_H_
24 #define OR_TOOLS_MATH_OPT_CPP_STREAMABLE_SOLVER_INIT_ARGUMENTS_H_
25 
26 #include <cstdint>
27 #include <optional>
28 #include <string>
29 
30 #include "absl/status/statusor.h"
31 #include "ortools/math_opt/parameters.pb.h"
32 #include "ortools/math_opt/solvers/gurobi.pb.h"
33 
34 namespace operations_research {
35 namespace math_opt {
36 
37 // Streamable Pdlp specific parameters for solver instantiation.
39 
40 // Streamable CpSat specific parameters for solver instantiation.
42 
43 // Streamable GScip specific parameters for solver instantiation.
45 
46 // Streamable Glop specific parameters for solver instantiation.
48 
49 // Streamable Glpk specific parameters for solver instantiation.
51 
52 // An ISV key for the Gurobi solver.
53 //
54 // See http://www.gurobi.com/products/licensing-pricing/isv-program.
55 struct GurobiISVKey {
56  std::string name;
57  std::string application_name;
58  int32_t expiration = 0;
59  std::string key;
60 
61  GurobiInitializerProto::ISVKey Proto() const;
62  static GurobiISVKey FromProto(
63  const GurobiInitializerProto::ISVKey& key_proto);
64 };
65 
66 // Streamable Gurobi specific parameters for solver instantiation.
68  // An optional ISV key to use to instantiate the solver. This is ignored if a
69  // `primary_env` is provided in `NonStreamableGurobiInitArguments`.
70  std::optional<GurobiISVKey> isv_key;
71 
72  // Returns the proto corresponding to these parameters.
73  GurobiInitializerProto Proto() const;
74 
75  // Parses the proto corresponding to these parameters.
77  const GurobiInitializerProto& args_proto);
78 };
79 
80 // Solver initialization parameters that can be streamed to be exchanged with
81 // another process.
82 //
83 // Parameters that can't be streamed (for example instances of C/C++ types that
84 // only exist in the process memory) are dealt with implementations of
85 // the NonStreamableSolverInitArguments.
87  std::optional<StreamableCpSatInitArguments> cp_sat;
88  std::optional<StreamableGScipInitArguments> gscip;
89  std::optional<StreamableGlopInitArguments> glop;
90  std::optional<StreamableGlpkInitArguments> glpk;
91  std::optional<StreamableGurobiInitArguments> gurobi;
92 
93  // Returns the proto corresponding to these parameters.
94  SolverInitializerProto Proto() const;
95 
96  // Parses the proto corresponding to these parameters.
97  static absl::StatusOr<StreamableSolverInitArguments> FromProto(
98  const SolverInitializerProto& args_proto);
99 };
100 
101 } // namespace math_opt
102 } // namespace operations_research
103 
104 #endif // OR_TOOLS_MATH_OPT_CPP_STREAMABLE_SOLVER_INIT_ARGUMENTS_H_
Collection of objects used to extend the Constraint Solver library.
static GurobiISVKey FromProto(const GurobiInitializerProto::ISVKey &key_proto)
static StreamableGurobiInitArguments FromProto(const GurobiInitializerProto &args_proto)
static absl::StatusOr< StreamableSolverInitArguments > FromProto(const SolverInitializerProto &args_proto)