Google OR-Tools v9.11
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-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_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
32
33 // The tested solver.
35
37
38 // True if the solver supports auxiliary objectives.
40
41 // True if the solver supports incrementally adding and deleting auxiliary
42 // objectives.
44
45 // True if the solver supports incremental, in-place modification of
46 // objectives in multi-objective models.
48};
49
50std::ostream& operator<<(std::ostream& out,
51 const MultiObjectiveTestParameters& params);
52
53// A suite of unit tests for multiple objectives. Note that a solver that does
54// not support multiple objectives should still use this fixture to ensure that
55// it is not silently ignoring one.
56//
57// To use these tests, in file <solver>_test.cc, write:
58// INSTANTIATE_TEST_SUITE_P(
59// <Solver>SimpleMultiObjectiveTest, SimpleMultiObjectiveTest,
60// testing::Values(
61// MultiObjectiveTestParameters(
62// SolverType::k<Solver>, parameters,
63// /*supports_multi_objectives=*/false,
64// /*supports_incremental_objective_add_and_delete=*/false,
65// /*supports_incremental_objective_modification=*/false)));
67 : public testing::TestWithParam<MultiObjectiveTestParameters> {
68 protected:
69 absl::StatusOr<SolveResult> SimpleSolve(const Model& model) {
70 return Solve(model, GetParam().solver_type,
71 {.parameters = GetParam().parameters});
72 }
73};
74
75// A suite of unit tests focused on incrementalism with multiple objectives.
76// Note that a solver that does not support multiple objectives should still use
77// this fixture to ensure that it is not silently ignoring one.
78//
79// To use these tests, in file <solver>_test.cc, write:
80// INSTANTIATE_TEST_SUITE_P(
81// <Solver>IncrementalMultiObjectiveTest, IncrementalMultiObjectiveTest,
82// testing::Values(
83// MultiObjectiveTestParameters(
84// SolverType::k<Solver>, parameters,
85// /*supports_multi_objectives=*/false,
86// /*supports_incremental_objective_add_and_delete=*/false,
87// /*supports_incremental_objective_modification=*/false)));
89 : public testing::TestWithParam<MultiObjectiveTestParameters> {};
90
91} // namespace operations_research::math_opt
92
93#endif // OR_TOOLS_MATH_OPT_SOLVER_TESTS_MULTI_OBJECTIVE_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_auxiliary_objectives
True if the solver supports auxiliary objectives.
MultiObjectiveTestParameters(SolverType solver_type, SolveParameters parameters, bool supports_auxiliary_objectives, bool supports_incremental_objective_add_and_delete, bool supports_incremental_objective_modification)