Google OR-Tools v9.15
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
gscip_testing.h
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#ifndef ORTOOLS_MATH_OPT_SOLVERS_GSCIP_GSCIP_TESTING_H_
15#define ORTOOLS_MATH_OPT_SOLVERS_GSCIP_GSCIP_TESTING_H_
16
17#include <string>
18
19#include "gtest/gtest.h"
20#include "ortools/base/gmock.h"
23
24namespace operations_research {
25
26// Non-default behavior: don't print search logs to standard out.
28
29// These are provided to make writing good unit tests easier.
30std::string SolutionToString(const GScipSolution& solution);
31
32// The tolerance is term-wise (LInf norm).
33bool SolutionsAlmostEqual(const GScipSolution& left, const GScipSolution& right,
34 double tolerance = 1e-5);
35
36testing::Matcher<GScipSolution> GScipSolutionEquals(const GScipSolution& rhs);
37
38// The tolerance is term-wise (LInf norm).
39testing::Matcher<GScipSolution> GScipSolutionAlmostEquals(
40 const GScipSolution& rhs, double tolerance = 1e-5);
41
42// ASSERTs that actual_result has the expected objective value and first best
43// solution, to within tolerance.
44void AssertOptimalWithBestSolution(const GScipResult& actual_result,
45 double expected_objective_value,
46 const GScipSolution& expected_solution,
47 double tolerance = 1e-5);
48
49// Like above, but not all variable values must be set in expected_solution.
51 const GScipResult& actual_result, double expected_objective_value,
52 const GScipSolution& expected_solution, double tolerance = 1e-5);
53
54} // namespace operations_research
55
56#endif // ORTOOLS_MATH_OPT_SOLVERS_GSCIP_GSCIP_TESTING_H_
OR-Tools root namespace.
void AssertOptimalWithBestSolution(const GScipResult &actual_result, const double expected_objective_value, const GScipSolution &expected_solution, const double tolerance)
Select next search node to expand Select next item_i to add this new search node to the search Generate a new search node where item_i is not in the knapsack Check validity of this new partial solution(using propagators) - If valid
bool SolutionsAlmostEqual(const GScipSolution &left, const GScipSolution &right, const double tolerance)
std::string SolutionToString(const GScipSolution &solution)
void AssertOptimalWithPartialBestSolution(const GScipResult &actual_result, const double expected_objective_value, const GScipSolution &expected_solution, const double tolerance)
GScipParameters TestGScipParameters()
absl::flat_hash_map< SCIP_VAR *, double > GScipSolution
Definition gscip.h:89
testing::Matcher< GScipSolution > GScipSolutionEquals(const GScipSolution &rhs)
testing::Matcher< GScipSolution > GScipSolutionAlmostEquals(const GScipSolution &rhs, double tolerance)