Google OR-Tools v9.11
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-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_LOGICAL_CONSTRAINT_TESTS_H_
15#define OR_TOOLS_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
35 // The tested solver.
37
39
40 // True if the solver supports integer variables.
42
43 // True if the solver supports SOS1 constraints.
45
46 // True if the solver supports SOS2 constraints.
48
49 // True if the solver supports indicator constraints.
51
52 // True if the solver supports incremental updates that add and/or delete
53 // any of the logical constraint types it supports.
55
56 // True if the solver supports updates that delete (non-indicator) variables.
58
59 // True if the solver supports updates that delete indicator variables.
61
62 // True if the solver supports updates (changing bounds or vartype) to binary
63 // variables.
65};
66
67std::ostream& operator<<(std::ostream& out,
69
70// A suite of unit tests for logical constraints.
71//
72// To use these tests, in file <solver>_test.cc, write:
73// INSTANTIATE_TEST_SUITE_P(
74// <Solver>SimpleLogicalConstraintTest, SimpleLogicalConstraint,
75// testing::Values(LogicalConstraintTestParameters(
76// SolverType::k<Solver>, parameters,
77// /*supports_integer_variables=*/false,
78// /*supports_sos1=*/false, /*supports_sos2=*/false,
79// /*supports_indicator=*/false,
80// /*supports_incremental_add_and_deletes=*/false,
81// /*supports_incremental_variable_deletions=*/false,
82// /*supports_deleting_indicator_variables=*/false,
83// /*supports_updating_binary_variables=*/false)));
85 : public testing::TestWithParam<LogicalConstraintTestParameters> {
86 protected:
87 absl::StatusOr<SolveResult> SimpleSolve(const Model& model) {
88 return Solve(model, GetParam().solver_type,
89 {.parameters = GetParam().parameters});
90 }
91};
92
93// A suite of unit tests for logical constraints.
94//
95// To use these tests, in file <solver>_test.cc, write:
96// INSTANTIATE_TEST_SUITE_P(
97// <Solver>IncrementalLogicalConstraintTest, IncrementalLogicalConstraint,
98// testing::Values(LogicalConstraintTestParameters(
99// SolverType::k<Solver>, parameters,
100// /*supports_integer_variables=*/false,
101// /*supports_sos1=*/false, /*supports_sos2=*/false,
102// /*supports_indicator=*/false,
103// /*supports_incremental_add_and_deletes=*/false,
104// /*supports_incremental_variable_deletions=*/false,
105// /*supports_deleting_indicator_variables=*/false,
106// /*supports_updating_binary_variables=*/false)));
108 : public testing::TestWithParam<LogicalConstraintTestParameters> {};
109
110} // namespace operations_research::math_opt
111
112#endif // OR_TOOLS_MATH_OPT_SOLVER_TESTS_LOGICAL_CONSTRAINT_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)
bool supports_indicator_constraints
True if the solver supports indicator constraints.
bool supports_sos2
True if the solver supports SOS2 constraints.
bool supports_deleting_indicator_variables
True if the solver supports updates that delete indicator variables.
bool supports_integer_variables
True if the solver supports integer variables.
bool supports_incremental_variable_deletions
True if the solver supports updates that delete (non-indicator) variables.
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_sos1
True if the solver supports SOS1 constraints.