Google OR-Tools
v9.15
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-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_SOLVER_TESTS_LP_TESTS_H_
15
#define ORTOOLS_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"
23
#include "
ortools/math_opt/cpp/math_opt.h
"
24
#include "
ortools/math_opt/solver_tests/base_solver_test.h
"
25
26
namespace
operations_research
{
27
namespace
math_opt
{
28
29
struct
SimpleLpTestParameters
{
30
// The tested solver.
31
SolverType
solver_type
;
32
SolveParameters
parameters
;
33
34
// True if a dual solution is returned.
35
bool
supports_duals
;
36
37
// True if the solver produces a basis.
38
bool
supports_basis
;
39
40
bool
ensures_primal_ray
;
41
bool
ensures_dual_ray
;
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.
46
bool
disallows_infeasible_or_unbounded
;
47
48
SimpleLpTestParameters
(
const
SolverType
solver_type
,
49
SolveParameters
parameters
,
const
bool
supports_duals
,
50
const
bool
supports_basis
,
51
const
bool
ensures_primal_ray
,
52
const
bool
ensures_dual_ray
,
53
const
bool
disallows_infeasible_or_unbounded
)
54
:
solver_type
(
solver_type
),
55
parameters
(
std
::move(
parameters
)),
56
supports_duals
(
supports_duals
),
57
supports_basis
(
supports_basis
),
58
ensures_primal_ray
(
ensures_primal_ray
),
59
ensures_dual_ray
(
ensures_dual_ray
),
60
disallows_infeasible_or_unbounded
(
disallows_infeasible_or_unbounded
) {}
61
62
friend
std::ostream&
operator<<
(std::ostream& out,
63
const
SimpleLpTestParameters
& params);
64
};
65
66
class
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
74
class
IncrementalLpTest
:
public
BaseSolverTest
{
75
protected
:
76
IncrementalLpTest
();
77
78
Model
model_
;
79
const
Variable
zero_
;
80
const
Variable
x_1_
;
81
const
Variable
y_1_
;
82
const
LinearConstraint
c_1_
;
83
const
Variable
x_2_
;
84
const
Variable
y_2_
;
85
const
LinearConstraint
c_2_
;
86
const
Variable
x_3_
;
87
const
Variable
y_3_
;
88
const
LinearConstraint
c_3_
;
89
90
std::unique_ptr<IncrementalSolver>
solver_
;
91
};
92
93
}
// namespace math_opt
94
}
// namespace operations_research
95
96
#endif
// ORTOOLS_MATH_OPT_SOLVER_TESTS_LP_TESTS_H_
base_solver_test.h
operations_research::math_opt::BaseSolverTest
Definition
base_solver_test.h:23
operations_research::math_opt::IncrementalLpTest::solver_
std::unique_ptr< IncrementalSolver > solver_
Definition
lp_tests.h:90
operations_research::math_opt::IncrementalLpTest::c_2_
const LinearConstraint c_2_
Definition
lp_tests.h:85
operations_research::math_opt::IncrementalLpTest::IncrementalLpTest
IncrementalLpTest()
operations_research::math_opt::IncrementalLpTest::c_3_
const LinearConstraint c_3_
Definition
lp_tests.h:88
operations_research::math_opt::IncrementalLpTest::c_1_
const LinearConstraint c_1_
Definition
lp_tests.h:82
operations_research::math_opt::IncrementalLpTest::y_1_
const Variable y_1_
Definition
lp_tests.h:81
operations_research::math_opt::IncrementalLpTest::x_3_
const Variable x_3_
Definition
lp_tests.h:86
operations_research::math_opt::IncrementalLpTest::y_3_
const Variable y_3_
Definition
lp_tests.h:87
operations_research::math_opt::IncrementalLpTest::x_2_
const Variable x_2_
Definition
lp_tests.h:83
operations_research::math_opt::IncrementalLpTest::zero_
const Variable zero_
Definition
lp_tests.h:79
operations_research::math_opt::IncrementalLpTest::model_
Model model_
Definition
lp_tests.h:78
operations_research::math_opt::IncrementalLpTest::y_2_
const Variable y_2_
Definition
lp_tests.h:84
operations_research::math_opt::IncrementalLpTest::x_1_
const Variable x_1_
Definition
lp_tests.h:80
operations_research::math_opt::LinearConstraint
Definition
linear_constraint.h:42
operations_research::math_opt::Model
Definition
model.h:113
operations_research::math_opt::SimpleLpTest
Definition
lp_tests.h:66
operations_research::math_opt::SimpleLpTest::SimpleSolve
absl::StatusOr< SolveResult > SimpleSolve(const Model &model)
Definition
lp_tests.h:69
operations_research::math_opt::SimpleLpTest::TestedSolver
SolverType TestedSolver() const
Definition
lp_tests.h:68
operations_research::math_opt::Variable
Definition
variable_and_expressions.h:125
math_opt.h
operations_research::math_opt
Definition
gurobi_isv.cc:28
operations_research::math_opt::SolverType
SolverType
Definition
parameters.h:41
operations_research::math_opt::Solve
absl::StatusOr< SolveResult > Solve(const Model &model, const SolverType solver_type, const SolveArguments &solve_args, const SolverInitArguments &init_args)
Definition
solve.cc:62
operations_research
OR-Tools root namespace.
Definition
binary_indexed_tree.h:21
std
STL namespace.
operations_research::math_opt::SimpleLpTestParameters
Definition
lp_tests.h:29
operations_research::math_opt::SimpleLpTestParameters::supports_basis
bool supports_basis
Definition
lp_tests.h:38
operations_research::math_opt::SimpleLpTestParameters::solver_type
SolverType solver_type
Definition
lp_tests.h:31
operations_research::math_opt::SimpleLpTestParameters::ensures_primal_ray
bool ensures_primal_ray
Definition
lp_tests.h:40
operations_research::math_opt::SimpleLpTestParameters::supports_duals
bool supports_duals
Definition
lp_tests.h:35
operations_research::math_opt::SimpleLpTestParameters::disallows_infeasible_or_unbounded
bool disallows_infeasible_or_unbounded
Definition
lp_tests.h:46
operations_research::math_opt::SimpleLpTestParameters::SimpleLpTestParameters
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
operations_research::math_opt::SimpleLpTestParameters::operator<<
friend std::ostream & operator<<(std::ostream &out, const SimpleLpTestParameters ¶ms)
Definition
lp_tests.cc:51
operations_research::math_opt::SimpleLpTestParameters::ensures_dual_ray
bool ensures_dual_ray
Definition
lp_tests.h:41
operations_research::math_opt::SimpleLpTestParameters::parameters
SolveParameters parameters
Definition
lp_tests.h:32
operations_research::math_opt::SolveParameters
Definition
parameters.h:308
ortools
math_opt
solver_tests
lp_tests.h
Generated by
1.15.0