Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
parameters.proto
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// Configures the behavior of a MathOpt solver.
15syntax = "proto3";
16
17package operations_research.math_opt;
18
19import "google/protobuf/duration.proto";
20import "ortools/pdlp/solvers.proto";
21import "ortools/glop/parameters.proto";
22import "ortools/gscip/gscip.proto";
23import "ortools/math_opt/solvers/glpk.proto";
24import "ortools/math_opt/solvers/gurobi.proto";
25import "ortools/math_opt/solvers/highs.proto";
26import "ortools/math_opt/solvers/osqp.proto";
27import "ortools/sat/sat_parameters.proto";
28
29option java_package = "com.google.ortools.mathopt";
30option java_multiple_files = true;
31
32// The solvers supported by MathOpt.
33enum SolverTypeProto {
34 SOLVER_TYPE_UNSPECIFIED = 0;
35
36 // Solving Constraint Integer Programs (SCIP) solver (third party).
37 //
38 // Supports LP, MIP, and nonconvex integer quadratic problems. No dual data
39 // for LPs is returned though. Prefer GLOP for LPs.
40 SOLVER_TYPE_GSCIP = 1;
41
42 // Gurobi solver (third party).
43 //
44 // Supports LP, MIP, and nonconvex integer quadratic problems. Generally the
45 // fastest option, but has special licensing.
46 SOLVER_TYPE_GUROBI = 2;
47
48 // Google's Glop solver.
49 //
50 // Supports LP with primal and dual simplex methods.
51 SOLVER_TYPE_GLOP = 3;
52
53 // Google's CP-SAT solver.
54 //
55 // Supports problems where all variables are integer and bounded (or implied
56 // to be after presolve). Experimental support to rescale and discretize
57 // problems with continuous variables.
58 SOLVER_TYPE_CP_SAT = 4;
59
60 // Google's PDLP solver.
61 //
62 // Supports LP and convex diagonal quadratic objectives. Uses first order
63 // methods rather than simplex. Can solve very large problems.
64 SOLVER_TYPE_PDLP = 5;
65
66 // GNU Linear Programming Kit (GLPK) (third party).
67 //
68 // Supports MIP and LP.
69 //
70 // Thread-safety: GLPK use thread-local storage for memory allocations. As a
71 // consequence Solver instances must be destroyed on the same thread as they
72 // are created or GLPK will crash. It seems OK to call Solver::Solve() from
73 // another thread than the one used to create the Solver but it is not
74 // documented by GLPK and should be avoided.
75 //
76 // When solving a LP with the presolver, a solution (and the unbound rays) are
77 // only returned if an optimal solution has been found. Else nothing is
78 // returned. See glpk-5.0/doc/glpk.pdf page #40 available from glpk-5.0.tar.gz
79 // for details.
80 SOLVER_TYPE_GLPK = 6;
81
82 // The Operator Splitting Quadratic Program (OSQP) solver (third party).
83 //
84 // Supports continuous problems with linear constraints and linear or convex
85 // quadratic objectives. Uses a first-order method.
86 SOLVER_TYPE_OSQP = 7;
87
88 // The Embedded Conic Solver (ECOS) (third party).
89 //
90 // Supports LP and SOCP problems. Uses interior point methods (barrier).
91 SOLVER_TYPE_ECOS = 8;
92
93 // The Splitting Conic Solver (SCS) (third party).
94 //
95 // Supports LP and SOCP problems. Uses a first-order method.
96 SOLVER_TYPE_SCS = 9;
97
98 // The HiGHS Solver (third party).
99 //
100 // Supports LP and MIP problems (convex QPs are unimplemented).
101 SOLVER_TYPE_HIGHS = 10;
102
103 // MathOpt's reference implementation of a MIP solver.
104 //
105 // Slow/not recommended for production. Not an LP solver (no dual information
106 // returned).
107 SOLVER_TYPE_SANTORINI = 11;
108}
109
110// Selects an algorithm for solving linear programs.
111enum LPAlgorithmProto {
112 LP_ALGORITHM_UNSPECIFIED = 0;
113
114 // The (primal) simplex method. Typically can provide primal and dual
115 // solutions, primal/dual rays on primal/dual unbounded problems, and a basis.
116 LP_ALGORITHM_PRIMAL_SIMPLEX = 1;
117
118 // The dual simplex method. Typically can provide primal and dual
119 // solutions, primal/dual rays on primal/dual unbounded problems, and a basis.
120 LP_ALGORITHM_DUAL_SIMPLEX = 2;
121
122 // The barrier method, also commonly called an interior point method (IPM).
123 // Can typically give both primal and dual solutions. Some implementations can
124 // also produce rays on unbounded/infeasible problems. A basis is not given
125 // unless the underlying solver does "crossover" and finishes with simplex.
126 LP_ALGORITHM_BARRIER = 3;
127
128 // An algorithm based around a first-order method. These will typically
129 // produce both primal and dual solutions, and potentially also certificates
130 // of primal and/or dual infeasibility. First-order methods typically will
131 // provide solutions with lower accuracy, so users should take care to set
132 // solution quality parameters (e.g., tolerances) and to validate solutions.
133 LP_ALGORITHM_FIRST_ORDER = 4;
134}
135
136// Effort level applied to an optional task while solving (see
137// SolveParametersProto for use).
138//
139// Emphasis is used to configure a solver feature as follows:
140// * If a solver doesn't support the feature, only UNSPECIFIED will always be
141// valid, any other setting will typically an invalid argument error (some
142// solvers may also accept OFF).
143// * If the solver supports the feature:
144// - When set to UNSPECIFIED, the underlying default is used.
145// - When the feature cannot be turned off, OFF will return an error.
146// - If the feature is enabled by default, the solver default is typically
147// mapped to MEDIUM.
148// - If the feature is supported, LOW, MEDIUM, HIGH, and VERY HIGH will never
149// give an error, and will map onto their best match.
150enum EmphasisProto {
151 EMPHASIS_UNSPECIFIED = 0;
152 EMPHASIS_OFF = 1;
153 EMPHASIS_LOW = 2;
154 EMPHASIS_MEDIUM = 3;
155 EMPHASIS_HIGH = 4;
156 EMPHASIS_VERY_HIGH = 5;
157}
158
159// Configures if potentially bad solver input is a warning or an error.
160//
161// TODO(b/196132970): implement this feature.
162message StrictnessProto {
163 bool bad_parameter = 1;
164}
165
166// This message contains solver specific data that are used when the solver is
167// instantiated.
168message SolverInitializerProto {
169 GurobiInitializerProto gurobi = 1;
170}
171
172// Parameters to control a single solve.
173//
174// Contains both parameters common to all solvers e.g. time_limit, and
175// parameters for a specific solver, e.g. gscip. If a value is set in both
176// common and solver specific field, the solver specific setting is used.
177//
178// The common parameters that are optional and unset or an enum with value
179// unspecified indicate that the solver default is used.
180//
181// Solver specific parameters for solvers other than the one in use are ignored.
182//
183// Parameters that depends on the model (e.g. branching priority is set for
184// each variable) are passed in ModelSolveParametersProto.
185message SolveParametersProto {
186 //////////////////////////////////////////////////////////////////////////////
187 // Parameters common to all solvers.
188 //////////////////////////////////////////////////////////////////////////////
189
190 // Maximum time a solver should spend on the problem (or infinite if not set).
191 //
192 // This value is not a hard limit, solve time may slightly exceed this value.
193 // This parameter is always passed to the underlying solver, the solver
194 // default is not used.
195 google.protobuf.Duration time_limit = 1;
196
197 // Limit on the iterations of the underlying algorithm (e.g. simplex pivots).
198 // The specific behavior is dependent on the solver and algorithm used, but
199 // often can give a deterministic solve limit (further configuration may be
200 // needed, e.g. one thread).
201 //
202 // Typically supported by LP, QP, and MIP solvers, but for MIP solvers see
203 // also node_limit.
204 optional int64 iteration_limit = 2;
205
206 // Limit on the number of subproblems solved in enumerative search (e.g.
207 // branch and bound). For many solvers this can be used to deterministically
208 // limit computation (further configuration may be needed, e.g. one thread).
209 //
210 // Typically for MIP solvers, see also iteration_limit.
211 optional int64 node_limit = 24;
212
213 // The solver stops early if it can prove there are no primal solutions at
214 // least as good as cutoff.
215 //
216 // On an early stop, the solver returns termination reason NO_SOLUTION_FOUND
217 // and with limit CUTOFF and is not required to give any extra solution
218 // information. Has no effect on the return value if there is no early stop.
219 //
220 // It is recommended that you use a tolerance if you want solutions with
221 // objective exactly equal to cutoff to be returned.
222 //
223 // See the user guide for more details and a comparison with best_bound_limit.
224 optional double cutoff_limit = 20;
225
226 // The solver stops early as soon as it finds a solution at least this good,
227 // with termination reason FEASIBLE and limit OBJECTIVE.
228 optional double objective_limit = 21;
229
230 // The solver stops early as soon as it proves the best bound is at least this
231 // good, with termination reason FEASIBLE or NO_SOLUTION_FOUND and limit
232 // OBJECTIVE.
233 //
234 // See the user guide for more details and a comparison with cutoff_limit.
235 optional double best_bound_limit = 22;
236
237 // The solver stops early after finding this many feasible solutions, with
238 // termination reason FEASIBLE and limit SOLUTION. Must be greater than zero
239 // if set. It is often used get the solver to stop on the first feasible
240 // solution found. Note that there is no guarantee on the objective value for
241 // any of the returned solutions.
242 //
243 // Solvers will typically not return more solutions than the solution limit,
244 // but this is not enforced by MathOpt, see also b/214041169.
245 //
246 // Currently supported for Gurobi and SCIP, and for CP-SAT only with value 1.
247 optional int32 solution_limit = 23;
248
249 // Enables printing the solver implementation traces. The location of those
250 // traces depend on the solver. For SCIP and Gurobi this will be the standard
251 // output streams. For Glop and CP-SAT this will LOG(INFO).
252 //
253 // Note that if the solver supports message callback and the user registers a
254 // callback for it, then this parameter value is ignored and no traces are
255 // printed.
256 bool enable_output = 3;
257
258 // If set, it must be >= 1.
259 optional int32 threads = 4;
260
261 // Seed for the pseudo-random number generator in the underlying
262 // solver. Note that all solvers use pseudo-random numbers to select things
263 // such as perturbation in the LP algorithm, for tie-break-up rules, and for
264 // heuristic fixings. Varying this can have a noticeable impact on solver
265 // behavior.
266 //
267 // Although all solvers have a concept of seeds, note that valid values
268 // depend on the actual solver.
269 // - Gurobi: [0:GRB_MAXINT] (which as of Gurobi 9.0 is 2x10^9).
270 // - GSCIP: [0:2147483647] (which is MAX_INT or kint32max or 2^31-1).
271 // - GLOP: [0:2147483647] (same as above)
272 // In all cases, the solver will receive a value equal to:
273 // MAX(0, MIN(MAX_VALID_VALUE_FOR_SOLVER, random_seed)).
274 optional int32 random_seed = 5;
275
276 // An absolute optimality tolerance (primarily) for MIP solvers.
277 //
278 // The absolute GAP is the absolute value of the difference between:
279 // * the objective value of the best feasible solution found,
280 // * the dual bound produced by the search.
281 // The solver can stop once the absolute GAP is at most absolute_gap_tolerance
282 // (when set), and return TERMINATION_REASON_OPTIMAL.
283 //
284 // Must be >= 0 if set.
285 //
286 // See also relative_gap_tolerance.
287 optional double absolute_gap_tolerance = 18;
288
289 // A relative optimality tolerance (primarily) for MIP solvers.
290 //
291 // The relative GAP is a normalized version of the absolute GAP (defined on
292 // absolute_gap_tolerance), where the normalization is solver-dependent, e.g.
293 // the absolute GAP divided by the objective value of the best feasible
294 // solution found.
295 //
296 // The solver can stop once the relative GAP is at most relative_gap_tolerance
297 // (when set), and return TERMINATION_REASON_OPTIMAL.
298 //
299 // Must be >= 0 if set.
300 //
301 // See also absolute_gap_tolerance.
302 optional double relative_gap_tolerance = 17;
303
304 // Maintain up to `solution_pool_size` solutions while searching. The solution
305 // pool generally has two functions:
306 // (1) For solvers that can return more than one solution, this limits how
307 // many solutions will be returned.
308 // (2) Some solvers may run heuristics using solutions from the solution
309 // pool, so changing this value may affect the algorithm's path.
310 // To force the solver to fill the solution pool, e.g. with the n best
311 // solutions, requires further, solver specific configuration.
312 optional int32 solution_pool_size = 25;
313
314 // The algorithm for solving a linear program. If LP_ALGORITHM_UNSPECIFIED,
315 // use the solver default algorithm.
316 //
317 // For problems that are not linear programs but where linear programming is
318 // a subroutine, solvers may use this value. E.g. MIP solvers will typically
319 // use this for the root LP solve only (and use dual simplex otherwise).
320 LPAlgorithmProto lp_algorithm = 6;
321
322 // Effort on simplifying the problem before starting the main algorithm, or
323 // the solver default effort level if EMPHASIS_UNSPECIFIED.
324 EmphasisProto presolve = 7;
325
326 // Effort on getting a stronger LP relaxation (MIP only), or the solver
327 // default effort level if EMPHASIS_UNSPECIFIED.
328 //
329 // NOTE: disabling cuts may prevent callbacks from having a chance to add cuts
330 // at MIP_NODE, this behavior is solver specific.
331 EmphasisProto cuts = 8;
332
333 // Effort in finding feasible solutions beyond those encountered in the
334 // complete search procedure (MIP only), or the solver default effort level if
335 // EMPHASIS_UNSPECIFIED.
336 EmphasisProto heuristics = 9;
337
338 // Effort in rescaling the problem to improve numerical stability, or the
339 // solver default effort level if EMPHASIS_UNSPECIFIED.
340 EmphasisProto scaling = 10;
341
342 //////////////////////////////////////////////////////////////////////////////
343 // Solver specific parameters
344 //////////////////////////////////////////////////////////////////////////////
345
346 GScipParameters gscip = 12;
347
348 GurobiParametersProto gurobi = 13;
349
350 glop.GlopParameters glop = 14;
351
352 sat.SatParameters cp_sat = 15;
353
354 pdlp.PrimalDualHybridGradientParams pdlp = 16;
355
356 // Users should prefer the generic MathOpt parameters over OSQP-level
357 // parameters, when available:
358 // * Prefer SolveParametersProto.enable_output to OsqpSettingsProto.verbose.
359 // * Prefer SolveParametersProto.time_limit to OsqpSettingsProto.time_limit.
360 // * Prefer SolveParametersProto.iteration_limit to
361 // OsqpSettingsProto.iteration_limit.
362 // * If a less granular configuration is acceptable, prefer
363 // SolveParametersProto.scaling to OsqpSettingsProto.
364 OsqpSettingsProto osqp = 19;
365
366 GlpkParametersProto glpk = 26;
367
368 HighsOptionsProto highs = 27;
369
370 reserved 11; // Deleted
371}