Google OR-Tools v9.12
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-2025 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 // Fico XPRESS solver (third party).
110 //
111 // Supports LP, MIP, and nonconvex integer quadratic problems.
112 // A fast option, but has special licensing.
113 SOLVER_TYPE_XPRESS = 12;
114}
115
116// Selects an algorithm for solving linear programs.
117enum LPAlgorithmProto {
118 LP_ALGORITHM_UNSPECIFIED = 0;
119
120 // The (primal) simplex method. Typically can provide primal and dual
121 // solutions, primal/dual rays on primal/dual unbounded problems, and a basis.
122 LP_ALGORITHM_PRIMAL_SIMPLEX = 1;
123
124 // The dual simplex method. Typically can provide primal and dual
125 // solutions, primal/dual rays on primal/dual unbounded problems, and a basis.
126 LP_ALGORITHM_DUAL_SIMPLEX = 2;
127
128 // The barrier method, also commonly called an interior point method (IPM).
129 // Can typically give both primal and dual solutions. Some implementations can
130 // also produce rays on unbounded/infeasible problems. A basis is not given
131 // unless the underlying solver does "crossover" and finishes with simplex.
132 LP_ALGORITHM_BARRIER = 3;
133
134 // An algorithm based around a first-order method. These will typically
135 // produce both primal and dual solutions, and potentially also certificates
136 // of primal and/or dual infeasibility. First-order methods typically will
137 // provide solutions with lower accuracy, so users should take care to set
138 // solution quality parameters (e.g., tolerances) and to validate solutions.
139 LP_ALGORITHM_FIRST_ORDER = 4;
140}
141
142// Effort level applied to an optional task while solving (see
143// SolveParametersProto for use).
144//
145// Emphasis is used to configure a solver feature as follows:
146// * If a solver doesn't support the feature, only UNSPECIFIED will always be
147// valid, any other setting will typically an invalid argument error (some
148// solvers may also accept OFF).
149// * If the solver supports the feature:
150// - When set to UNSPECIFIED, the underlying default is used.
151// - When the feature cannot be turned off, OFF will return an error.
152// - If the feature is enabled by default, the solver default is typically
153// mapped to MEDIUM.
154// - If the feature is supported, LOW, MEDIUM, HIGH, and VERY HIGH will never
155// give an error, and will map onto their best match.
156enum EmphasisProto {
157 EMPHASIS_UNSPECIFIED = 0;
158 EMPHASIS_OFF = 1;
159 EMPHASIS_LOW = 2;
160 EMPHASIS_MEDIUM = 3;
161 EMPHASIS_HIGH = 4;
162 EMPHASIS_VERY_HIGH = 5;
163}
164
165// Configures if potentially bad solver input is a warning or an error.
166//
167// TODO(b/196132970): implement this feature.
168message StrictnessProto {
169 bool bad_parameter = 1;
170}
171
172// This message contains solver specific data that are used when the solver is
173// instantiated.
174message SolverInitializerProto {
175 GurobiInitializerProto gurobi = 1;
176}
177
178// Parameters to control a single solve.
179//
180// Contains both parameters common to all solvers e.g. time_limit, and
181// parameters for a specific solver, e.g. gscip. If a value is set in both
182// common and solver specific field, the solver specific setting is used.
183//
184// The common parameters that are optional and unset or an enum with value
185// unspecified indicate that the solver default is used.
186//
187// Solver specific parameters for solvers other than the one in use are ignored.
188//
189// Parameters that depends on the model (e.g. branching priority is set for
190// each variable) are passed in ModelSolveParametersProto.
191message SolveParametersProto {
192 //////////////////////////////////////////////////////////////////////////////
193 // Parameters common to all solvers.
194 //////////////////////////////////////////////////////////////////////////////
195
196 // Maximum time a solver should spend on the problem (or infinite if not set).
197 //
198 // This value is not a hard limit, solve time may slightly exceed this value.
199 // This parameter is always passed to the underlying solver, the solver
200 // default is not used.
201 google.protobuf.Duration time_limit = 1;
202
203 // Limit on the iterations of the underlying algorithm (e.g. simplex pivots).
204 // The specific behavior is dependent on the solver and algorithm used, but
205 // often can give a deterministic solve limit (further configuration may be
206 // needed, e.g. one thread).
207 //
208 // Typically supported by LP, QP, and MIP solvers, but for MIP solvers see
209 // also node_limit.
210 optional int64 iteration_limit = 2;
211
212 // Limit on the number of subproblems solved in enumerative search (e.g.
213 // branch and bound). For many solvers this can be used to deterministically
214 // limit computation (further configuration may be needed, e.g. one thread).
215 //
216 // Typically for MIP solvers, see also iteration_limit.
217 optional int64 node_limit = 24;
218
219 // The solver stops early if it can prove there are no primal solutions at
220 // least as good as cutoff.
221 //
222 // On an early stop, the solver returns termination reason NO_SOLUTION_FOUND
223 // and with limit CUTOFF and is not required to give any extra solution
224 // information. Has no effect on the return value if there is no early stop.
225 //
226 // It is recommended that you use a tolerance if you want solutions with
227 // objective exactly equal to cutoff to be returned.
228 //
229 // See the user guide for more details and a comparison with best_bound_limit.
230 optional double cutoff_limit = 20;
231
232 // The solver stops early as soon as it finds a solution at least this good,
233 // with termination reason FEASIBLE and limit OBJECTIVE.
234 optional double objective_limit = 21;
235
236 // The solver stops early as soon as it proves the best bound is at least this
237 // good, with termination reason FEASIBLE or NO_SOLUTION_FOUND and limit
238 // OBJECTIVE.
239 //
240 // See the user guide for more details and a comparison with cutoff_limit.
241 optional double best_bound_limit = 22;
242
243 // The solver stops early after finding this many feasible solutions, with
244 // termination reason FEASIBLE and limit SOLUTION. Must be greater than zero
245 // if set. It is often used get the solver to stop on the first feasible
246 // solution found. Note that there is no guarantee on the objective value for
247 // any of the returned solutions.
248 //
249 // Solvers will typically not return more solutions than the solution limit,
250 // but this is not enforced by MathOpt, see also b/214041169.
251 //
252 // Currently supported for Gurobi and SCIP, and for CP-SAT only with value 1.
253 optional int32 solution_limit = 23;
254
255 // Enables printing the solver implementation traces. The location of those
256 // traces depend on the solver. For SCIP and Gurobi this will be the standard
257 // output streams. For Glop and CP-SAT this will LOG(INFO).
258 //
259 // Note that if the solver supports message callback and the user registers a
260 // callback for it, then this parameter value is ignored and no traces are
261 // printed.
262 bool enable_output = 3;
263
264 // If set, it must be >= 1.
265 optional int32 threads = 4;
266
267 // Seed for the pseudo-random number generator in the underlying
268 // solver. Note that all solvers use pseudo-random numbers to select things
269 // such as perturbation in the LP algorithm, for tie-break-up rules, and for
270 // heuristic fixings. Varying this can have a noticeable impact on solver
271 // behavior.
272 //
273 // Although all solvers have a concept of seeds, note that valid values
274 // depend on the actual solver.
275 // - Gurobi: [0:GRB_MAXINT] (which as of Gurobi 9.0 is 2x10^9).
276 // - GSCIP: [0:2147483647] (which is MAX_INT or kint32max or 2^31-1).
277 // - GLOP: [0:2147483647] (same as above)
278 // In all cases, the solver will receive a value equal to:
279 // MAX(0, MIN(MAX_VALID_VALUE_FOR_SOLVER, random_seed)).
280 optional int32 random_seed = 5;
281
282 // An absolute optimality tolerance (primarily) for MIP solvers.
283 //
284 // The absolute GAP is the absolute value of the difference between:
285 // * the objective value of the best feasible solution found,
286 // * the dual bound produced by the search.
287 // The solver can stop once the absolute GAP is at most absolute_gap_tolerance
288 // (when set), and return TERMINATION_REASON_OPTIMAL.
289 //
290 // Must be >= 0 if set.
291 //
292 // See also relative_gap_tolerance.
293 optional double absolute_gap_tolerance = 18;
294
295 // A relative optimality tolerance (primarily) for MIP solvers.
296 //
297 // The relative GAP is a normalized version of the absolute GAP (defined on
298 // absolute_gap_tolerance), where the normalization is solver-dependent, e.g.
299 // the absolute GAP divided by the objective value of the best feasible
300 // solution found.
301 //
302 // The solver can stop once the relative GAP is at most relative_gap_tolerance
303 // (when set), and return TERMINATION_REASON_OPTIMAL.
304 //
305 // Must be >= 0 if set.
306 //
307 // See also absolute_gap_tolerance.
308 optional double relative_gap_tolerance = 17;
309
310 // Maintain up to `solution_pool_size` solutions while searching. The solution
311 // pool generally has two functions:
312 // (1) For solvers that can return more than one solution, this limits how
313 // many solutions will be returned.
314 // (2) Some solvers may run heuristics using solutions from the solution
315 // pool, so changing this value may affect the algorithm's path.
316 // To force the solver to fill the solution pool, e.g. with the n best
317 // solutions, requires further, solver specific configuration.
318 optional int32 solution_pool_size = 25;
319
320 // The algorithm for solving a linear program. If LP_ALGORITHM_UNSPECIFIED,
321 // use the solver default algorithm.
322 //
323 // For problems that are not linear programs but where linear programming is
324 // a subroutine, solvers may use this value. E.g. MIP solvers will typically
325 // use this for the root LP solve only (and use dual simplex otherwise).
326 LPAlgorithmProto lp_algorithm = 6;
327
328 // Effort on simplifying the problem before starting the main algorithm, or
329 // the solver default effort level if EMPHASIS_UNSPECIFIED.
330 EmphasisProto presolve = 7;
331
332 // Effort on getting a stronger LP relaxation (MIP only), or the solver
333 // default effort level if EMPHASIS_UNSPECIFIED.
334 //
335 // NOTE: disabling cuts may prevent callbacks from having a chance to add cuts
336 // at MIP_NODE, this behavior is solver specific.
337 EmphasisProto cuts = 8;
338
339 // Effort in finding feasible solutions beyond those encountered in the
340 // complete search procedure (MIP only), or the solver default effort level if
341 // EMPHASIS_UNSPECIFIED.
342 EmphasisProto heuristics = 9;
343
344 // Effort in rescaling the problem to improve numerical stability, or the
345 // solver default effort level if EMPHASIS_UNSPECIFIED.
346 EmphasisProto scaling = 10;
347
348 //////////////////////////////////////////////////////////////////////////////
349 // Solver specific parameters
350 //////////////////////////////////////////////////////////////////////////////
351
352 GScipParameters gscip = 12;
353
354 GurobiParametersProto gurobi = 13;
355
356 glop.GlopParameters glop = 14;
357
358 sat.SatParameters cp_sat = 15;
359
360 pdlp.PrimalDualHybridGradientParams pdlp = 16;
361
362 // Users should prefer the generic MathOpt parameters over OSQP-level
363 // parameters, when available:
364 // * Prefer SolveParametersProto.enable_output to OsqpSettingsProto.verbose.
365 // * Prefer SolveParametersProto.time_limit to OsqpSettingsProto.time_limit.
366 // * Prefer SolveParametersProto.iteration_limit to
367 // OsqpSettingsProto.iteration_limit.
368 // * If a less granular configuration is acceptable, prefer
369 // SolveParametersProto.scaling to OsqpSettingsProto.
370 OsqpSettingsProto osqp = 19;
371
372 GlpkParametersProto glpk = 26;
373
374 HighsOptionsProto highs = 27;
375
376 reserved 11; // Deleted
377}