20#include "absl/strings/str_cat.h"
21#include "gtest/gtest.h"
31 out <<
"{ solver_type: " << params.
solver_type <<
" ensure_hint_in_pool: "
41 Model model(
"Solution Hint MIP");
43 Variable x1 = model.AddBinaryVariable(
"x1");
44 Variable x2 = model.AddBinaryVariable(
"x2");
45 model.AddLinearConstraint(x1 + x2 == 1);
46 model.Maximize(x1 + 3 * x2);
56 .objective_value = 3.0,
62 .objective_value = 1.0,
65 for (int32_t solution_pool_size : {1, 2}) {
66 SCOPED_TRACE(absl::StrCat(
"Solution pool size: ", solution_pool_size));
67 SolveArguments args = {.parameters = GetParam().ensure_hint_in_pool,
68 .model_parameters = model_parameters};
71 Solve(model, GetParam().solver_type, args));
73 if (solution_pool_size == 1) {
79 ElementsAre(
IsNear(expected1),
80 IsNear(expected2, {.allow_undetermined =
true})));
An object oriented wrapper for quadratic constraints in ModelStorage.
EXPECT_THAT(ComputeInfeasibleSubsystem(model, GetParam().solver_type), IsOkAndHolds(IsInfeasible(true, ModelSubset{ .variable_bounds={{x, ModelSubset::Bounds{.lower=false,.upper=true}}},.linear_constraints={ {c, ModelSubset::Bounds{.lower=true,.upper=false}}}})))
TEST_P(InfeasibleSubsystemTest, CanComputeInfeasibleSubsystem)
absl::StatusOr< SolveResult > Solve(const Model &model, const SolverType solver_type, const SolveArguments &solve_args, const SolverInitArguments &init_args)
std::ostream & operator<<(std::ostream &ostr, const IndicatorConstraint &constraint)
@ kFeasible
Solver claims the solution is feasible.
Matcher< VariableMap< double > > IsNear(VariableMap< double > expected, const double tolerance)
Matcher< SolveResult > IsOptimal(const std::optional< double > expected_primal_objective, const double tolerance)
std::string ProtobufShortDebugString(const P &message)
#define ASSERT_OK_AND_ASSIGN(lhs, rexpr)
SolveParameters ensure_hint_in_pool
IpMultipleSolutionsTestParams(const SolverType solver_type, SolveParameters ensure_hint_in_pool)
SolverType solver_type
The tested solver.
VariableMap< double > variable_values
std::vector< SolutionHint > solution_hints
SolveParameters parameters
Model independent parameters, e.g. time limit.
std::optional< int32_t > solution_pool_size
SolveParametersProto Proto() const