Google OR-Tools
v9.15
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
14
#include "
ortools/math_opt/elemental/elemental_matcher.h
"
15
16
#include <ostream>
17
18
#include "
ortools/math_opt/elemental/elemental.h
"
19
#include "
ortools/math_opt/elemental/elemental_differencer.h
"
20
21
namespace
operations_research::math_opt
{
22
23
ElementalMatcher::ElementalMatcher
(
const
Elemental
& expected,
24
const
ElementalDifferenceOptions
& options)
25
: expected_(&expected), options_(options) {}
26
27
bool
ElementalMatcher::MatchAndExplain
(
const
Elemental
& actual,
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
41
void
ElementalMatcher::DescribeTo
(std::ostream* os)
const
{
42
*os <<
"Is equal to model: "
<< expected_->DebugString(
/*print_diffs=*/
false
);
43
}
44
45
void
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
operations_research::math_opt::ElementalDifference
Definition
elemental_differencer.h:67
operations_research::math_opt::ElementalDifference::Create
static ElementalDifference Create(const Elemental &first, const Elemental &second, const ElementalDifferenceOptions &options={})
Definition
elemental_differencer.cc:68
operations_research::math_opt::ElementalDifference::Describe
static std::string Describe(const Elemental &first, const Elemental &second, const ElementalDifference &difference)
Definition
elemental_differencer.cc:155
operations_research::math_opt::ElementalDifference::Empty
bool Empty() const
Definition
elemental_differencer.cc:52
operations_research::math_opt::ElementalMatcher::ElementalMatcher
ElementalMatcher(const Elemental &expected ABSL_ATTRIBUTE_LIFETIME_BOUND, const ElementalDifferenceOptions &options)
Definition
elemental_matcher.cc:23
operations_research::math_opt::ElementalMatcher::DescribeTo
void DescribeTo(std::ostream *os) const
Definition
elemental_matcher.cc:41
operations_research::math_opt::ElementalMatcher::MatchAndExplain
bool MatchAndExplain(const Elemental &actual, std::ostream *os) const
Definition
elemental_matcher.cc:27
operations_research::math_opt::ElementalMatcher::DescribeNegationTo
void DescribeNegationTo(std::ostream *os) const
Definition
elemental_matcher.cc:45
operations_research::math_opt::Elemental
Definition
elemental.h:49
elemental.h
elemental_differencer.h
elemental_matcher.h
operations_research::math_opt
Definition
gurobi_isv.cc:28
operations_research::math_opt::ElementalDifferenceOptions
Definition
elemental_differencer.h:52
ortools
math_opt
elemental
elemental_matcher.cc
Generated by
1.15.0