Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
result.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// The result of solving a MathOpt model, both the Solution and metadata.
15
16syntax = "proto3";
17
18package operations_research.service.v1.mathopt;
19
20import "google/protobuf/duration.proto";
21import "ortools/service/v1/mathopt/solution.proto";
22
23option java_multiple_files = true;
24option java_package = "com.google.ortools.service.v1.mathopt";
25option csharp_namespace = "Google.OrTools.Service";
26
27// Problem feasibility status as claimed by the solver (solver is not required
28// to return a certificate for the claim).
29enum FeasibilityStatusProto {
30 // Guard value representing no status.
31 FEASIBILITY_STATUS_UNSPECIFIED = 0;
32
33 // Solver does not claim a status.
34 FEASIBILITY_STATUS_UNDETERMINED = 1;
35
36 // Solver claims the problem is feasible.
37 FEASIBILITY_STATUS_FEASIBLE = 2;
38
39 // Solver claims the problem is infeasible.
40 FEASIBILITY_STATUS_INFEASIBLE = 3;
41}
42
43// Feasibility status of the primal problem and its dual (or the dual of a
44// continuous relaxation) as claimed by the solver. The solver is not required
45// to return a certificate for the claim (e.g. the solver may claim primal
46// feasibility without returning a primal feasible solutuion). This combined
47// status gives a comprehensive description of a solver's claims about
48// feasibility and unboundedness of the solved problem. For instance,
49//
50// * a feasible status for primal and dual problems indicates the primal is
51// feasible and bounded and likely has an optimal solution (guaranteed for
52// problems without non-linear constraints).
53// * a primal feasible and a dual infeasible status indicates the primal
54// problem is unbounded (i.e. has arbitrarily good solutions).
55//
56// Note that a dual infeasible status by itself (i.e. accompanied by an
57// undetermined primal status) does not imply the primal problem is unbounded as
58// we could have both problems be infeasible. Also, while a primal and dual
59// feasible status may imply the existence of an optimal solution, it does not
60// guarantee the solver has actually found such optimal solution.
61message ProblemStatusProto {
62 // Status for the primal problem.
63 FeasibilityStatusProto primal_status = 1;
64
65 // Status for the dual problem (or for the dual of a continuous relaxation).
66 FeasibilityStatusProto dual_status = 2;
67
68 // If true, the solver claims the primal or dual problem is infeasible, but
69 // it does not know which (or if both are infeasible). Can be true only when
70 // primal_problem_status = dual_problem_status = kUndetermined. This extra
71 // information is often needed when preprocessing determines there is no
72 // optimal solution to the problem (but can't determine if it is due to
73 // infeasibility, unboundedness, or both).
74 bool primal_or_dual_infeasible = 3;
75}
76
77message SolveStatsProto {
78 // Elapsed wall clock time as measured by math_opt, roughly the time inside
79 // Solver::Solve(). Note: this does not include work done building the model.
80 google.protobuf.Duration solve_time = 1;
81
82 // Fields previously used for `best_primal_bound` and `best_dual_bound`.
83 reserved 2, 3;
84
85 // Feasibility statuses for primal and dual problems.
86 ProblemStatusProto problem_status = 4;
87
88 int64 simplex_iterations = 5;
89
90 int64 barrier_iterations = 6;
91
92 int64 first_order_iterations = 8;
93
94 int64 node_count = 7;
95
96 // Next id: 9
97}
98
99// The reason a call to Solve() terminates.
100enum TerminationReasonProto {
101 TERMINATION_REASON_UNSPECIFIED = 0;
102
103 // A provably optimal solution (up to numerical tolerances) has been found.
104 TERMINATION_REASON_OPTIMAL = 1;
105
106 // The primal problem has no feasible solutions.
107 TERMINATION_REASON_INFEASIBLE = 2;
108
109 // The primal problem is feasible and arbitrarily good solutions can be
110 // found along a primal ray.
111 TERMINATION_REASON_UNBOUNDED = 3;
112
113 // The primal problem is either infeasible or unbounded. More details on the
114 // problem status may be available in solve_stats.problem_status. Note that
115 // Gurobi's unbounded status may be mapped here.
116 TERMINATION_REASON_INFEASIBLE_OR_UNBOUNDED = 4;
117
118 // The problem was solved to one of the criteria above (Optimal, Infeasible,
119 // Unbounded, or InfeasibleOrUnbounded), but one or more tolerances was not
120 // met. Some primal/dual solutions/rays be present, but either they will be
121 // slightly infeasible, or (if the problem was nearly optimal) their may be
122 // a gap between the best solution objective and best objective bound.
123 //
124 // Users can still query primal/dual solutions/rays and solution stats, but
125 // they are responsible for dealing with the numerical imprecision.
126 TERMINATION_REASON_IMPRECISE = 5;
127
128 // The optimizer reached some kind of limit and a primal feasible solution
129 // is returned. See SolveResultProto.limit_detail for detailed description of
130 // the kind of limit that was reached.
131 TERMINATION_REASON_FEASIBLE = 9;
132
133 // The optimizer reached some kind of limit and it did not find a primal
134 // feasible solution. See SolveResultProto.limit_detail for detailed
135 // description of the kind of limit that was reached.
136 TERMINATION_REASON_NO_SOLUTION_FOUND = 6;
137
138 // The algorithm stopped because it encountered unrecoverable numerical
139 // error. No solution information is available.
140 TERMINATION_REASON_NUMERICAL_ERROR = 7;
141
142 // The algorithm stopped because of an error not covered by one of the
143 // statuses defined above. No solution information is available.
144 TERMINATION_REASON_OTHER_ERROR = 8;
145}
146
147// When a Solve() stops early with TerminationReasonProto FEASIBLE or
148// NO_SOLUTION_FOUND, the specific limit that was hit.
149enum LimitProto {
150 // Used as a null value when we terminated not from a limit (e.g.
151 // TERMINATION_REASON_OPTIMAL).
152 LIMIT_UNSPECIFIED = 0;
153
154 // The underlying solver does not expose which limit was reached.
155 LIMIT_UNDETERMINED = 1;
156
157 // An iterative algorithm stopped after conducting the maximum number of
158 // iterations (e.g. simplex or barrier iterations).
159 LIMIT_ITERATION = 2;
160
161 // The algorithm stopped after a user-specified computation time.
162 LIMIT_TIME = 3;
163
164 // A branch-and-bound algorithm stopped because it explored a maximum number
165 // of nodes in the branch-and-bound tree.
166 LIMIT_NODE = 4;
167
168 // The algorithm stopped because it found the required number of solutions.
169 // This is often used in MIPs to get the solver to return the first feasible
170 // solution it encounters.
171 LIMIT_SOLUTION = 5;
172
173 // The algorithm stopped because it ran out of memory.
174 LIMIT_MEMORY = 6;
175
176 // The solver was run with a cutoff (e.g. SolveParameters.cutoff_limit was
177 // set) on the objective, indicating that the user did not want any solution
178 // worse than the cutoff, and the solver concluded there were no solutions at
179 // least as good as the cutoff. Typically no further solution information is
180 // provided.
181 LIMIT_CUTOFF = 12;
182
183 // The algorithm stopped because it either found a solution or a bound better
184 // than a limit set by the user (see SolveParameters.objective_limit and
185 // SolveParameters.best_bound_limit).
186 LIMIT_OBJECTIVE = 7;
187
188 // The algorithm stopped because the norm of an iterate became too large.
189 LIMIT_NORM = 8;
190
191 // The algorithm stopped because of an interrupt signal or a user interrupt
192 // request.
193 LIMIT_INTERRUPTED = 9;
194
195 // The algorithm stopped because it was unable to continue making progress
196 // towards the solution.
197 LIMIT_SLOW_PROGRESS = 10;
198
199 // The algorithm stopped due to a limit not covered by one of the above. Note
200 // that LIMIT_UNDETERMINED is used when the reason cannot be determined, and
201 // LIMIT_OTHER is used when the reason is known but does not fit into any of
202 // the above alternatives.
203 //
204 // TerminationProto.detail may contain additional information about the limit.
205 LIMIT_OTHER = 11;
206}
207
208// Bounds on the optimal objective value.
209message ObjectiveBoundsProto {
210 // Solver claims the optimal value is equal or better (smaller for
211 // minimization and larger for maximization) than primal_bound up to the
212 // solvers primal feasibility tolerance (see warning below):
213 // * primal_bound is trivial (+inf for minimization and -inf
214 // maximization) when the solver does not claim to have such bound.
215 // * primal_bound can be closer to the optimal value than the objective
216 // of the best primal feasible solution. In particular, primal_bound
217 // may be non-trivial even when no primal feasible solutions are returned.
218 // Warning: The precise claim is that there exists a primal solution that:
219 // * is numerically feasible (i.e. feasible up to the solvers tolerance), and
220 // * has an objective value primal_bound.
221 // This numerically feasible solution could be slightly infeasible, in which
222 // case primal_bound could be strictly better than the optimal value.
223 // Translating a primal feasibility tolerance to a tolerance on
224 // primal_bound is non-trivial, specially when the feasibility tolerance
225 // is relatively large (e.g. when solving with PDLP).
226 double primal_bound = 2;
227
228 // Solver claims the optimal value is equal or worse (larger for
229 // minimization and smaller for maximization) than dual_bound up to the
230 // solvers dual feasibility tolerance (see warning below):
231 // * dual_bound is trivial (-inf for minimization and +inf
232 // maximization) when the solver does not claim to have such bound.
233 // Similarly to primal_bound, this may happen for some solvers even
234 // when returning optimal. MIP solvers will typically report a bound even
235 // if it is imprecise.
236 // * for continuous problems dual_bound can be closer to the optimal
237 // value than the objective of the best dual feasible solution. For MIP
238 // one of the first non-trivial values for dual_bound is often the
239 // optimal value of the LP relaxation of the MIP.
240 // * dual_bound should be better (smaller for minimization and larger
241 // for maximization) than primal_bound up to the solvers tolerances
242 // (see warning below).
243 // Warning:
244 // * For continuous problems, the precise claim is that there exists a
245 // dual solution that:
246 // * is numerically feasible (i.e. feasible up to the solvers tolerance),
247 // and
248 // * has an objective value dual_bound.
249 // This numerically feasible solution could be slightly infeasible, in
250 // which case dual_bound could be strictly worse than the optimal
251 // value and primal_bound. Similar to the primal case, translating a
252 // dual feasibility tolerance to a tolerance on dual_bound is
253 // non-trivial, specially when the feasibility tolerance is relatively
254 // large. However, some solvers provide a corrected version of
255 // dual_bound that can be numerically safer. This corrected version
256 // can be accessed through the solver's specific output (e.g. for PDLP,
257 // pdlp_output.convergence_information.corrected_dual_objective).
258 // * For MIP solvers, dual_bound may be associated to a dual solution
259 // for some continuous relaxation (e.g. LP relaxation), but it is often a
260 // complex consequence of the solvers execution and is typically more
261 // imprecise than the bounds reported by LP solvers.
262 double dual_bound = 3;
263}
264
265// All information regarding why a call to Solve() terminated.
266message TerminationProto {
267 // Additional information in `limit` when value is TERMINATION_REASON_FEASIBLE
268 // or TERMINATION_REASON_NO_SOLUTION_FOUND, see `limit` for details.
269 TerminationReasonProto reason = 1;
270
271 // Is LIMIT_UNSPECIFIED unless reason is TERMINATION_REASON_FEASIBLE or
272 // TERMINATION_REASON_NO_SOLUTION_FOUND. Not all solvers can always determine
273 // the limit which caused termination, LIMIT_UNDETERMINED is used when the
274 // cause cannot be determined.
275 LimitProto limit = 2;
276
277 // Additional typically solver specific information about termination.
278 string detail = 3;
279
280 // Feasibility statuses for primal and dual problems.
281 // As of July 18, 2023 this message may be missing. If missing, problem_status
282 // can be found in SolveResultProto.solve_stats.
283 ProblemStatusProto problem_status = 4;
284
285 // Bounds on the optimal objective value.
286 // As of July 18, 2023 this message may be missing. If missing,
287 // objective_bounds.primal_bound can be found in
288 // SolveResultProto.solve.stats.best_primal_bound and
289 // objective_bounds.dual_bound can be found in
290 // SolveResultProto.solve.stats.best_dual_bound
291 ObjectiveBoundsProto objective_bounds = 5;
292}
293
294// The contract of when primal/dual solutions/rays is complex, see
295// termination_reasons.md for a complete description.
296//
297// Until an exact contract is finalized, it is safest to simply check if a
298// solution/ray is present rather than relying on the termination reason.
299message SolveResultProto {
300 // The reason the solver stopped.
301 TerminationProto termination = 2;
302
303 // Basic solutions use, as of Nov 2021:
304 // * All convex optimization solvers (LP, convex QP) return only one
305 // solution as a primal dual pair.
306 // * Only MI(Q)P solvers return more than one solution. MIP solvers do not
307 // return any dual information, or primal infeasible solutions. Solutions
308 // are returned in order of best primal objective first. Gurobi solves
309 // nonconvex QP (integer or continuous) as MIQP.
310
311 // The general contract for the order of solutions that future solvers should
312 // implement is to order by:
313 // 1. The solutions with a primal feasible solution, ordered by best primal
314 // objective first.
315 // 2. The solutions with a dual feasible solution, ordered by best dual
316 // objective (unknown dual objective is worst)
317 // 3. All remaining solutions can be returned in any order.
318 repeated SolutionProto solutions = 3;
319
320 // Directions of unbounded primal improvement, or equivalently, dual
321 // infeasibility certificates. Typically provided for TerminationReasonProtos
322 // UNBOUNDED and DUAL_INFEASIBLE
323 repeated PrimalRayProto primal_rays = 4;
324
325 // Directions of unbounded dual improvement, or equivalently, primal
326 // infeasibility certificates. Typically provided for TerminationReasonProto
327 // INFEASIBLE.
328 repeated DualRayProto dual_rays = 5;
329
330 // Statistics on the solve process, e.g. running time, iterations.
331 SolveStatsProto solve_stats = 6;
332
333 reserved 7, 8, 9;
334
335 reserved 1; // Deleted fields.
336}