Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
bounds_and_status_validator.h
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#ifndef OR_TOOLS_MATH_OPT_VALIDATORS_BOUNDS_AND_STATUS_VALIDATOR_H_
15#define OR_TOOLS_MATH_OPT_VALIDATORS_BOUNDS_AND_STATUS_VALIDATOR_H_
16
17#include "absl/status/status.h"
18#include "ortools/math_opt/result.pb.h"
19
21
23// Problem status validators and utilities.
25
26absl::Status ValidateFeasibilityStatus(const FeasibilityStatusProto& status);
27absl::Status ValidateProblemStatus(const ProblemStatusProto& status);
28
29// Returns absl::Ok only if status.primal_status = required_status. Assumes
30// validateProblemStatus(status) returns absl::Ok.
31absl::Status CheckPrimalStatusIs(const ProblemStatusProto& status,
32 FeasibilityStatusProto required_status);
33
34// Returns absl::Ok only if status.primal_status != forbidden_status. Assumes
35// validateProblemStatus(status) returns absl::Ok.
36absl::Status CheckPrimalStatusIsNot(const ProblemStatusProto& status,
37 FeasibilityStatusProto forbidden_status);
38
39// If primal_or_dual_infeasible_also_ok is false, returns absl::Ok only if
40// status.dual_status = required_status. If primal_or_dual_infeasible_also_ok
41// is true, it returns absl::Ok when status.dual_status = required_status and
42// when primal_or_dual_infeasible is true. Assumes validateProblemStatus(status)
43// returns absl::Ok.
44absl::Status CheckDualStatusIs(const ProblemStatusProto& status,
45 FeasibilityStatusProto required_status,
46 bool primal_or_dual_infeasible_also_ok = false);
47
48// Returns absl::Ok only if status.dual_status != forbidden_status. Assumes
49// validateProblemStatus(status) returns absl::Ok.
50absl::Status CheckDualStatusIsNot(const ProblemStatusProto& status,
51 FeasibilityStatusProto forbidden_status);
52
54// Objective bounds validators and utilities.
56
57absl::Status ValidateObjectiveBounds(const ObjectiveBoundsProto& bounds);
58
59absl::Status CheckFinitePrimalBound(const ObjectiveBoundsProto& bounds);
60
62// Status-Bounds consistency validators.
64
65// Checks both bound-status compatibility rules.
66// That is:
67// * If primal bound:
68// * is primal-unbounded (primal_bound = +infinity for max and
69// primal_bound = -infinity for min), then
70// * primal status is feasible,
71// * dual status is infeasible, and
72// * dual bound is equal to primal bound.
73// * is finite, then
74// * primal status is feasible.
75// * is finite or trivial (primal_bound = -infinity for max and
76// primal_bound = +infinity for min), then
77// * primal status feasible and dual status infeasible cannot hold at
78// the same time.
79// * If dual bound:
80// * is dual-unbounded (dual_bound = -infinity for max and
81// dual_bound = +infinity for min), then
82// * dual status is feasible,
83// * primal status is infeasible, and
84// * primal bound is equal to dual bound.
85// * is finite, then
86// * dual status is feasible.
87// * is finite or trivial (dual_bound = +infinity for max and
88// dual_bound = -infinity for min), then
89// * dual status feasible and primal status infeasible cannot hold at
90// the same time.
91// Note that the rules for primal and dual bounds are symmetric.
93 const ObjectiveBoundsProto& objective_bounds,
94 const ProblemStatusProto& status, bool is_maximize);
95
96} // namespace operations_research::math_opt
97
98#endif // OR_TOOLS_MATH_OPT_VALIDATORS_BOUNDS_AND_STATUS_VALIDATOR_H_
absl::Status status
Definition g_gurobi.cc:44
An object oriented wrapper for quadratic constraints in ModelStorage.
Definition gurobi_isv.cc:28
absl::Status ValidateFeasibilityStatus(const FeasibilityStatusProto &status)
absl::Status CheckDualStatusIsNot(const ProblemStatusProto &status, const FeasibilityStatusProto forbidden_status)
Assumes ValidateProblemStatus(status) is ok.
absl::Status CheckPrimalStatusIs(const ProblemStatusProto &status, const FeasibilityStatusProto required_status)
Assumes ValidateProblemStatus(status) is ok.
absl::Status ValidateProblemStatus(const ProblemStatusProto &status)
absl::Status CheckDualStatusIs(const ProblemStatusProto &status, const FeasibilityStatusProto required_status, const bool primal_or_dual_infeasible_also_ok)
Assumes ValidateProblemStatus(status) is ok.
absl::Status CheckFinitePrimalBound(const ObjectiveBoundsProto &bounds)
absl::Status ValidateObjectiveBounds(const ObjectiveBoundsProto &bounds)
absl::Status ValidateBoundStatusConsistency(const ObjectiveBoundsProto &objective_bounds, const ProblemStatusProto &status, bool is_maximize)
absl::Status CheckPrimalStatusIsNot(const ProblemStatusProto &status, const FeasibilityStatusProto forbidden_status)
Assumes ValidateProblemStatus(status) is ok.