Google OR-Tools v9.14
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
elemental_matcher.cc
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
15
16#include <ostream>
17
20
22
24 const ElementalDifferenceOptions& options)
25 : expected_(&expected), options_(options) {}
26
28 std::ostream* os) const {
29 const ElementalDifference diff =
30 ElementalDifference::Create(actual, *expected_, options_);
31 if (diff.Empty()) {
32 return true;
33 }
34 if (os != nullptr) {
35 *os << "\nWith differences:\n"
36 << ElementalDifference::Describe(actual, *expected_, diff);
37 }
38 return false;
39}
40
41void ElementalMatcher::DescribeTo(std::ostream* os) const {
42 *os << "Is equal to model: " << expected_->DebugString(/*print_diffs=*/false);
43}
44
45void ElementalMatcher::DescribeNegationTo(std::ostream* os) const {
46 *os << "Is not equal to model: "
47 << expected_->DebugString(/*print_diffs=*/false);
48}
49
50} // namespace operations_research::math_opt
static ElementalDifference Create(const Elemental &first, const Elemental &second, const ElementalDifferenceOptions &options={})
Returns the difference between two Elementals.
static std::string Describe(const Elemental &first, const Elemental &second, const ElementalDifference &difference)
ElementalMatcher(const Elemental &expected ABSL_ATTRIBUTE_LIFETIME_BOUND, const ElementalDifferenceOptions &options)
bool MatchAndExplain(const Elemental &actual, std::ostream *os) const
An object oriented wrapper for quadratic constraints in ModelStorage.
Definition gurobi_isv.cc:28