Google OR-Tools
v9.15
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
second_order_cone_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_SECOND_ORDER_CONE_TESTS_H_
15
#define ORTOOLS_MATH_OPT_SOLVER_TESTS_SECOND_ORDER_CONE_TESTS_H_
16
17
#include <ostream>
18
19
#include "absl/status/statusor.h"
20
#include "gtest/gtest.h"
21
#include "
ortools/math_opt/cpp/math_opt.h
"
22
23
namespace
operations_research::math_opt
{
24
25
struct
SecondOrderConeTestParameters
{
26
explicit
SecondOrderConeTestParameters
(
27
SolverType
solver_type
,
SolveParameters
parameters
,
28
bool
supports_soc_constraints
,
bool
supports_incremental_add_and_deletes
);
29
30
// The tested solver.
31
SolverType
solver_type
;
32
33
SolveParameters
parameters
;
34
35
// True if the solver supports second-order cone constraints.
36
bool
supports_soc_constraints
;
37
38
// True if the solver supports incremental updates that add and/or delete
39
// second-order cone constraints.
40
bool
supports_incremental_add_and_deletes
;
41
};
42
43
std::ostream&
operator<<
(std::ostream& out,
44
const
SecondOrderConeTestParameters
& params);
45
46
// A suite of unit tests for second-order cone constraints.
47
//
48
// To use these tests, in file <solver>_test.cc, write:
49
// INSTANTIATE_TEST_SUITE_P(
50
// <Solver>SimpleSecondOrderConeTest, SimpleSecondOrderConeTest,
51
// testing::Values(SecondOrderConeTestParameters(
52
// SolverType::k<Solver>, parameters,
53
// /*supports_soc_constraints=*/false,
54
// /*supports_incremental_add_and_deletes=*/false)));
55
class
SimpleSecondOrderConeTest
56
:
public
testing::TestWithParam<SecondOrderConeTestParameters> {
57
protected
:
58
absl::StatusOr<SolveResult>
SimpleSolve
(
const
Model
& model) {
59
return
Solve
(model, GetParam().solver_type,
60
{.parameters = GetParam().parameters});
61
}
62
};
63
64
// A suite of unit tests focused on incrementalism with second-order cone
65
// constraints. Note that a solver that does not support second-order cone
66
// constraints should still use this fixture to ensure that it is not silently
67
// ignoring one.
68
//
69
// To use these tests, in file <solver>_test.cc, write:
70
// INSTANTIATE_TEST_SUITE_P(
71
// <Solver>IncrementalSecondOrderConeTest, IncrementalSecondOrderConeTest,
72
// testing::Values(SecondOrderConeTestParameters(
73
// SolverType::k<Solver>, parameters,
74
// /*supports_soc_constraints=*/false,
75
// /*supports_incremental_add_and_deletes=*/false)));
76
class
IncrementalSecondOrderConeTest
77
:
public
testing::TestWithParam<SecondOrderConeTestParameters> {};
78
79
}
// namespace operations_research::math_opt
80
81
#endif
// ORTOOLS_MATH_OPT_SOLVER_TESTS_SECOND_ORDER_CONE_TESTS_H_
operations_research::math_opt::IncrementalSecondOrderConeTest
Definition
second_order_cone_tests.h:77
operations_research::math_opt::Model
Definition
model.h:113
operations_research::math_opt::SimpleSecondOrderConeTest
Definition
second_order_cone_tests.h:56
operations_research::math_opt::SimpleSecondOrderConeTest::SimpleSolve
absl::StatusOr< SolveResult > SimpleSolve(const Model &model)
Definition
second_order_cone_tests.h:58
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::math_opt::operator<<
std::ostream & operator<<(std::ostream &ostr, const SecondOrderConeConstraint &constraint)
Definition
second_order_cone_constraint.h:125
operations_research::math_opt::SecondOrderConeTestParameters
Definition
second_order_cone_tests.h:25
operations_research::math_opt::SecondOrderConeTestParameters::solver_type
SolverType solver_type
Definition
second_order_cone_tests.h:31
operations_research::math_opt::SecondOrderConeTestParameters::supports_incremental_add_and_deletes
bool supports_incremental_add_and_deletes
Definition
second_order_cone_tests.h:40
operations_research::math_opt::SecondOrderConeTestParameters::SecondOrderConeTestParameters
SecondOrderConeTestParameters(SolverType solver_type, SolveParameters parameters, bool supports_soc_constraints, bool supports_incremental_add_and_deletes)
Definition
second_order_cone_tests.cc:31
operations_research::math_opt::SecondOrderConeTestParameters::parameters
SolveParameters parameters
Definition
second_order_cone_tests.h:33
operations_research::math_opt::SecondOrderConeTestParameters::supports_soc_constraints
bool supports_soc_constraints
Definition
second_order_cone_tests.h:36
operations_research::math_opt::SolveParameters
Definition
parameters.h:308
ortools
math_opt
solver_tests
second_order_cone_tests.h
Generated by
1.15.0