Google OR-Tools v9.11
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-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_SECOND_ORDER_CONE_TESTS_H_
15#define OR_TOOLS_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"
22
24
29
30 // The tested solver.
32
34
35 // True if the solver supports second-order cone constraints.
37
38 // True if the solver supports incremental updates that add and/or delete
39 // second-order cone constraints.
41};
42
43std::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)));
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)));
77 : public testing::TestWithParam<SecondOrderConeTestParameters> {};
78
79} // namespace operations_research::math_opt
80
81#endif // OR_TOOLS_MATH_OPT_SOLVER_TESTS_SECOND_ORDER_CONE_TESTS_H_
absl::StatusOr< SolveResult > SimpleSolve(const Model &model)
GRBmodel * model
An object oriented wrapper for quadratic constraints in ModelStorage.
Definition gurobi_isv.cc:28
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
std::ostream & operator<<(std::ostream &ostr, const IndicatorConstraint &constraint)
SecondOrderConeTestParameters(SolverType solver_type, SolveParameters parameters, bool supports_soc_constraints, bool supports_incremental_add_and_deletes)
bool supports_soc_constraints
True if the solver supports second-order cone constraints.