22#include "absl/status/status.h"
23#include "absl/strings/str_join.h"
24#include "gtest/gtest.h"
29#include "ortools/math_opt/model.pb.h"
30#include "ortools/math_opt/model_update.pb.h"
36using ::absl::StatusCode;
37using ::testing::HasSubstr;
61 out <<
"{ solver_type: " << params.
solver_type <<
" solve_params: "
63 <<
" expected_error_substrings: [ "
72 model.set_name(
"simple_model");
73 model.mutable_variables()->add_ids(3);
74 model.mutable_variables()->add_lower_bounds(2.0);
75 model.mutable_variables()->add_upper_bounds(3.0);
76 model.mutable_variables()->add_upper_bounds(4.0);
77 model.mutable_variables()->add_integers(GetParam().use_integer_variables);
78 model.mutable_variables()->add_names(
"x3");
81 StatusIs(StatusCode::kInvalidArgument));
84TEST_P(InvalidInputTest, InvalidCommonParameters) {
86 const std::unique_ptr<Solver> solver,
91 StatusIs(StatusCode::kInvalidArgument));
96 model.set_name(
"simple_model");
97 model.mutable_variables()->add_ids(3);
98 model.mutable_variables()->add_lower_bounds(2.0);
99 model.mutable_variables()->add_upper_bounds(3.0);
100 model.mutable_variables()->add_integers(GetParam().use_integer_variables);
101 model.mutable_variables()->add_names(
"x3");
107 ModelUpdateProto update;
108 update.add_deleted_variable_ids(2);
114 SolveArguments args = {.parameters = GetParam().solve_parameters};
115 const auto result = SimpleSolve();
117 for (
const std::string& error : GetParam().expected_error_substrings) {
119 EXPECT_THAT(result.status().message(), HasSubstr(error));
static absl::StatusOr< std::unique_ptr< Solver > > New(SolverTypeProto solver_type, const ModelProto &model, const InitArgs &arguments)
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)
SolverType
The solvers supported by MathOpt.
ASSERT_THAT(solver->Update(), IsOkAndHolds(DidUpdate()))
std::ostream & operator<<(std::ostream &ostr, const IndicatorConstraint &constraint)
Enum< E >::Proto EnumToProto(std::optional< E > value)
internal::StatusIsMatcher StatusIs(CodeMatcher code_matcher, MessageMatcher message_matcher)
In SWIG mode, we don't want anything besides these top-level includes.
std::string ProtobufShortDebugString(const P &message)
internal::StatusIsMatcher StatusIs(CodeMatcher code_matcher, MessageMatcher message_matcher)
#define ASSERT_OK_AND_ASSIGN(lhs, rexpr)
Arguments used when calling Solve() to solve the problem.
SolveParametersProto parameters
InvalidParameterTestParams(SolverType solver_type, SolveParameters solve_parameters, std::vector< std::string > expected_error_substrings)
std::vector< std::string > expected_error_substrings
SolveParameters solve_parameters
SolveParametersProto Proto() const