Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
lp_tests.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_SOLVER_TESTS_LP_TESTS_H_
15#define OR_TOOLS_MATH_OPT_SOLVER_TESTS_LP_TESTS_H_
16
17#include <memory>
18#include <ostream>
19#include <utility>
20
21#include "absl/status/statusor.h"
22#include "gtest/gtest.h"
25
26namespace operations_research {
27namespace math_opt {
28
30 // The tested solver.
33
34 // True if a dual solution is returned.
36
37 // True if the solver produces a basis.
39
42
43 // If true, then TERMINATION_REASON_INFEASIBLE_OR_UNBOUNDED is never returned,
44 // it is always disambiguated to either TERMINATION_REASON_INFEASIBLE or
45 // TERMINATION_REASON_UNBOUNDED.
47
61
62 friend std::ostream& operator<<(std::ostream& out,
63 const SimpleLpTestParameters& params);
64};
65
66class SimpleLpTest : public ::testing::TestWithParam<SimpleLpTestParameters> {
67 protected:
68 SolverType TestedSolver() const { return GetParam().solver_type; }
69 absl::StatusOr<SolveResult> SimpleSolve(const Model& model) {
70 return Solve(model, TestedSolver(), {.parameters = GetParam().parameters});
71 }
72};
73
75 protected:
77
89
90 std::unique_ptr<IncrementalSolver> solver_;
91};
92
93} // namespace math_opt
94} // namespace operations_research
95
96#endif // OR_TOOLS_MATH_OPT_SOLVER_TESTS_LP_TESTS_H_
std::unique_ptr< IncrementalSolver > solver_
Definition lp_tests.h:90
absl::StatusOr< SolveResult > SimpleSolve(const Model &model)
Definition lp_tests.h:69
GRBmodel * model
SolverType
The solvers supported by MathOpt.
Definition parameters.h:42
absl::StatusOr< SolveResult > Solve(const Model &model, const SolverType solver_type, const SolveArguments &solve_args, const SolverInitArguments &init_args)
Definition solve.cc:62
In SWIG mode, we don't want anything besides these top-level includes.
STL namespace.
bool supports_basis
True if the solver produces a basis.
Definition lp_tests.h:38
bool supports_duals
True if a dual solution is returned.
Definition lp_tests.h:35
SimpleLpTestParameters(const SolverType solver_type, SolveParameters parameters, const bool supports_duals, const bool supports_basis, const bool ensures_primal_ray, const bool ensures_dual_ray, const bool disallows_infeasible_or_unbounded)
Definition lp_tests.h:48
friend std::ostream & operator<<(std::ostream &out, const SimpleLpTestParameters &params)
Definition lp_tests.cc:51