23#include "Eigen/SparseCore"
24#include "gtest/gtest.h"
30using ::Eigen::VectorXd;
31using ::testing::ElementsAre;
33constexpr double kInfinity = std::numeric_limits<double>::infinity();
41 std::vector<Eigen::Triplet<double, int64_t>> triplets = {
42 {0, 0, 2}, {0, 1, 1}, {0, 2, 1}, {0, 3, 2}, {1, 0, 1},
43 {1, 2, 1}, {2, 0, 4}, {3, 2, 1.5}, {3, 3, -1}};
52 const double objective_sign = maximize ? -1 : 1;
55 ElementsAre(5.5, -2, -1, 1));
59 ElementsAre(-kInfinity, -2, -kInfinity, 2.5));
61 ElementsAre(kInfinity, kInfinity, 6, 3.5));
66 {{2, 1, 1, 2}, {1, 0, 1, 0}, {4, 0, 0, 0}, {0, 0, 1.5, -1}}));
139 std::vector<Eigen::Triplet<double, int64_t>> constraint_triplets = {
140 {0, 0, 1}, {0, 1, 1}};
142 constraint_triplets.end());
144 Eigen::DiagonalMatrix<double, Eigen::Dynamic>{{4.0, 1.0}};
156 std::vector<Eigen::Triplet<double, int64_t>> constraint_triplets = {
157 {0, 0, 1}, {0, 1, -1}};
159 constraint_triplets.end());
161 Eigen::DiagonalMatrix<double, Eigen::Dynamic>({{1.0, 1.0}});
173 std::vector<Eigen::Triplet<double, int64_t>> constraint_triplets = {
174 {0, 0, 1}, {0, 2, -1}, {1, 0, 2}};
176 constraint_triplets.end());
178 Eigen::DiagonalMatrix<double, Eigen::Dynamic>({{0.0, 1.0, 2.0}});
262 const double objective_sign = maximize ? -1 : 1;
268 EigenArrayEq<double>({4, 1}));
277 const Eigen::SparseMatrix<double, Eigen::ColMajor, int64_t>& sparse_mat) {
278 return ::Eigen::ArrayXXd(::Eigen::MatrixXd(sparse_mat));
Validation utilities for solvers.proto.
QuadraticProgram SmallPrimalDualInfeasibleLp()
QuadraticProgram TestDiagonalQp1()
QuadraticProgram CorrelationClusteringStarLp()
QuadraticProgram SmallDualInfeasibleLp()
QuadraticProgram SmallInitializationLp()
QuadraticProgram TestDiagonalQp3()
QuadraticProgram TinyLp()
void VerifyTestLp(const QuadraticProgram &qp, bool maximize)
Verifies that the given QuadraticProgram equals TestLp().
::Eigen::ArrayXXd ToDense(const Eigen::SparseMatrix< double, Eigen::ColMajor, int64_t > &sparse_mat)
QuadraticProgram TestLp()
constexpr double kInfinity
QuadraticProgram SmallInconsistentVariableBoundsLp()
QuadraticProgram LpWithoutConstraints()
QuadraticProgram TestDiagonalQp2()
QuadraticProgram SmallInvalidProblemLp()
void VerifyTestDiagonalQp1(const QuadraticProgram &qp, bool maximize)
QuadraticProgram CorrelationClusteringLp()
| /
QuadraticProgram SmallPrimalInfeasibleLp()
double objective_scaling_factor
Eigen::VectorXd variable_lower_bounds
Eigen::VectorXd constraint_lower_bounds
Eigen::VectorXd objective_vector
std::optional< Eigen::DiagonalMatrix< double, Eigen::Dynamic > > objective_matrix
Eigen::SparseMatrix< double, Eigen::ColMajor, int64_t > constraint_matrix
Eigen::VectorXd variable_upper_bounds
Eigen::VectorXd constraint_upper_bounds