OR-Tools  9.3
termination.h
Go to the documentation of this file.
1// Copyright 2010-2021 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#ifndef PDLP_TERMINATION_H_
15#define PDLP_TERMINATION_H_
16
17#include "absl/types/optional.h"
18#include "ortools/pdlp/solve_log.pb.h"
19#include "ortools/pdlp/solvers.pb.h"
20
22
25 PointType type;
26};
27
28// Information about the quadratic program's primal and dual bounds that are
29// needed to evaluate relative convergence criteria.
35};
36
37// Checks if any termination criteria are satisfied by the solution state
38// described by the IterationStats instance stats (see definitions of
39// termination criteria in solvers.proto). bound_norms provides the instance-
40// dependent data required for the relative convergence criteria. Returns a
41// termination reason and a point type if so (if multiple are satisfied, the
42// optimality and infeasibility conditions are checked first). If
43// force_numerical_termination is true, returns NUMERICAL_ERROR if no other
44// criteria are satisfied. The return value is empty in any other case. If the
45// output is not empty, the PointType indicates which entry prompted
46// termination. If no entry prompted termination, e.g. NUMERICAL_ERROR or
47// ITERATION_LIMIT is returned, then the PointType is set to POINT_TYPE_NONE.
48// NOTE: This function assumes that the solution used to compute the stats
49// satisfies the primal and dual variable bounds; see
50// https://developers.google.com/optimization/lp/pdlp_math#dual_variable_bounds.
51absl::optional<TerminationReasonAndPointType> CheckTerminationCriteria(
52 const TerminationCriteria& criteria, const IterationStats& stats,
53 const QuadraticProgramBoundNorms& bound_norms,
54 bool force_numerical_termination = false);
55
56// Extracts the norms needed for the termination criteria from the full problem
57// statistics.
59 const QuadraticProgramStats& stats);
60
61// Metrics for tracking progress when relative convergence criteria are used.
62// These depend on the ConvergenceInformation, the problem data, and the
63// convergence tolerances.
65 // Relative versions of the residuals, defined as
66 // relative_residual = residual / (eps_ratio + norm),
67 // where
68 // eps_ratio = eps_optimal_absolute / eps_optimal_relative
69 // residual = one of the residuals (l{2,_inf}_{primal,dual}_residual)
70 // norm = the relative norm (l{2,_inf} norm of
71 // {constraint_bounds,primal_linear_objective} respectively).
72 // If eps_optimal_relative = 0.0, these will all be 0.0.
73 //
74 // If eps_optimal_relative > 0.0, the absolute and relative termination
75 // criteria translate to relative_residual <= eps_optimal_relative.
80
81 // Relative optimality gap:
82 // (primal_objective - dual_objective) /
83 // (eps_ratio + |primal_objective| + |dual_objective|)
85};
86
88 double eps_optimal_absolute, double eps_optimal_relative,
89 const QuadraticProgramBoundNorms& norms,
90 const ConvergenceInformation& stats);
91
92} // namespace operations_research::pdlp
93
94#endif // PDLP_TERMINATION_H_
absl::optional< TerminationReasonAndPointType > CheckTerminationCriteria(const TerminationCriteria &criteria, const IterationStats &stats, const QuadraticProgramBoundNorms &bound_norms, const bool force_numerical_termination)
Definition: termination.cc:90
RelativeConvergenceInformation ComputeRelativeResiduals(const double eps_optimal_absolute, const double eps_optimal_relative, const QuadraticProgramBoundNorms &norms, const ConvergenceInformation &stats)
Definition: termination.cc:147
QuadraticProgramBoundNorms BoundNormsFromProblemStats(const QuadraticProgramStats &stats)
Definition: termination.cc:138