Google OR-Tools v9.15
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
logical_constraint_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_LOGICAL_CONSTRAINT_TESTS_H_
15#define ORTOOLS_MATH_OPT_SOLVER_TESTS_LOGICAL_CONSTRAINT_TESTS_H_
16
17#include <ostream>
18
19#include "absl/status/statusor.h"
20#include "gtest/gtest.h"
22
24
34 bool supports_sos_on_expressions = true);
35
36 // The tested solver.
38
40
41 // True if the solver supports integer variables.
43
44 // True if the solver supports SOS1 constraints.
46
47 // True if the solver supports SOS2 constraints.
49
50 // True if the solver supports indicator constraints.
52
53 // True if the solver supports incremental updates that add and/or delete
54 // any of the logical constraint types it supports.
56
57 // True if the solver supports updates that delete (non-indicator) variables.
59
60 // True if the solver supports updates that delete indicator variables.
62
63 // True if the solver supports updates (changing bounds or vartype) to binary
64 // variables.
66
67 // True if the solver supports SOS constraints on expressions. False if
68 // SOS constraints are only supported on singleton variables.
70};
71
72std::ostream& operator<<(std::ostream& out,
74
75// A suite of unit tests for logical constraints.
76//
77// To use these tests, in file <solver>_test.cc, write:
78// INSTANTIATE_TEST_SUITE_P(
79// <Solver>SimpleLogicalConstraintTest, SimpleLogicalConstraint,
80// testing::Values(LogicalConstraintTestParameters(
81// SolverType::k<Solver>, parameters,
82// /*supports_integer_variables=*/false,
83// /*supports_sos1=*/false, /*supports_sos2=*/false,
84// /*supports_indicator=*/false,
85// /*supports_incremental_add_and_deletes=*/false,
86// /*supports_incremental_variable_deletions=*/false,
87// /*supports_deleting_indicator_variables=*/false,
88// /*supports_updating_binary_variables=*/false)));
90 : public testing::TestWithParam<LogicalConstraintTestParameters> {
91 protected:
92 absl::StatusOr<SolveResult> SimpleSolve(const Model& model) {
93 return Solve(model, GetParam().solver_type,
94 {.parameters = GetParam().parameters});
95 }
96};
97
98// A suite of unit tests for logical constraints.
99//
100// To use these tests, in file <solver>_test.cc, write:
101// INSTANTIATE_TEST_SUITE_P(
102// <Solver>IncrementalLogicalConstraintTest, IncrementalLogicalConstraint,
103// testing::Values(LogicalConstraintTestParameters(
104// SolverType::k<Solver>, parameters,
105// /*supports_integer_variables=*/false,
106// /*supports_sos1=*/false, /*supports_sos2=*/false,
107// /*supports_indicator=*/false,
108// /*supports_incremental_add_and_deletes=*/false,
109// /*supports_incremental_variable_deletions=*/false,
110// /*supports_deleting_indicator_variables=*/false,
111// /*supports_updating_binary_variables=*/false)));
113 : public testing::TestWithParam<LogicalConstraintTestParameters> {};
114
115} // namespace operations_research::math_opt
116
117#endif // ORTOOLS_MATH_OPT_SOLVER_TESTS_LOGICAL_CONSTRAINT_TESTS_H_
absl::StatusOr< SolveResult > SimpleSolve(const Model &model)
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 SecondOrderConeConstraint &constraint)
LogicalConstraintTestParameters(SolverType solver_type, SolveParameters parameters, bool supports_integer_variables, bool supports_sos1, bool supports_sos2, bool supports_indicator_constraints, bool supports_incremental_add_and_deletes, bool supports_incremental_variable_deletions, bool supports_deleting_indicator_variables, bool supports_updating_binary_variables, bool supports_sos_on_expressions=true)