Google OR-Tools v9.12
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
multi_objective_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 OR_TOOLS_MATH_OPT_SOLVER_TESTS_MULTI_OBJECTIVE_TESTS_H_
15#define OR_TOOLS_MATH_OPT_SOLVER_TESTS_MULTI_OBJECTIVE_TESTS_H_
16
17#include <iosfwd>
18#include <ostream>
19
20#include "absl/status/statusor.h"
21#include "gtest/gtest.h"
23
25
33
34 // The tested solver.
36
38
39 // True if the solver supports auxiliary objectives.
41
42 // True if the solver supports incrementally adding and deleting auxiliary
43 // objectives.
45
46 // True if the solver supports incremental, in-place modification of
47 // objectives in multi-objective models.
49
50 // True if the solver supports integer variables.
52};
53
54std::ostream& operator<<(std::ostream& out,
55 const MultiObjectiveTestParameters& params);
56
57// A suite of unit tests for multiple objectives. Note that a solver that does
58// not support multiple objectives should still use this fixture to ensure that
59// it is not silently ignoring one.
60//
61// To use these tests, in file <solver>_test.cc, write:
62// INSTANTIATE_TEST_SUITE_P(
63// <Solver>SimpleMultiObjectiveTest, SimpleMultiObjectiveTest,
64// testing::Values(
65// MultiObjectiveTestParameters(
66// SolverType::k<Solver>, parameters,
67// /*supports_multi_objectives=*/false,
68// /*supports_incremental_objective_add_and_delete=*/false,
69// /*supports_incremental_objective_modification=*/false)));
71 : public testing::TestWithParam<MultiObjectiveTestParameters> {
72 protected:
73 absl::StatusOr<SolveResult> SimpleSolve(const Model& model) {
74 return Solve(model, GetParam().solver_type,
75 {.parameters = GetParam().parameters});
76 }
77};
78
79// A suite of unit tests focused on incrementalism with multiple objectives.
80// Note that a solver that does not support multiple objectives should still use
81// this fixture to ensure that it is not silently ignoring one.
82//
83// To use these tests, in file <solver>_test.cc, write:
84// INSTANTIATE_TEST_SUITE_P(
85// <Solver>IncrementalMultiObjectiveTest, IncrementalMultiObjectiveTest,
86// testing::Values(
87// MultiObjectiveTestParameters(
88// SolverType::k<Solver>, parameters,
89// /*supports_multi_objectives=*/false,
90// /*supports_incremental_objective_add_and_delete=*/false,
91// /*supports_incremental_objective_modification=*/false)));
93 : public testing::TestWithParam<MultiObjectiveTestParameters> {};
94
95} // namespace operations_research::math_opt
96
97#endif // OR_TOOLS_MATH_OPT_SOLVER_TESTS_MULTI_OBJECTIVE_TESTS_H_
absl::StatusOr< SolveResult > SimpleSolve(const Model &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_integer_variables
True if the solver supports integer variables.
MultiObjectiveTestParameters(SolverType solver_type, SolveParameters parameters, bool supports_auxiliary_objectives, bool supports_incremental_objective_add_and_delete, bool supports_incremental_objective_modification, bool supports_integer_variables)
bool supports_auxiliary_objectives
True if the solver supports auxiliary objectives.