Skip to content

Commit bf51afa

Browse files
authored
Adds an "auto" solver option (#60)
Adds missing components to the auto solver option
1 parent 20c32a3 commit bf51afa

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

tests/get_info.cpp

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#include <Clarabel>
2+
#include <Eigen/Eigen>
3+
#include <cmath>
4+
#include <gtest/gtest.h>
5+
#include <iostream>
6+
#include <limits>
7+
#include <vector>
8+
9+
using namespace std;
10+
using namespace clarabel;
11+
using namespace Eigen;
12+
13+
class GetInfoTest : public ::testing::Test
14+
{
15+
protected:
16+
SparseMatrix<double> P, A;
17+
Vector<double, 2> c = { 1., 1. };
18+
Vector<double, 6> b = { -1., 0., 0., 1., 0.7, 0.7 };
19+
vector<SupportedConeT<double>> cones = {
20+
NonnegativeConeT<double>(3),
21+
NonnegativeConeT<double>(3)
22+
};
23+
DefaultSettings<double> settings = DefaultSettings<double>::default_settings();
24+
25+
GetInfoTest()
26+
{
27+
MatrixXd P_dense(2, 2);
28+
P_dense << 4., 1.,
29+
1., 2.;
30+
P = P_dense.sparseView();
31+
P.makeCompressed();
32+
33+
MatrixXd A_dense(6, 2);
34+
A_dense <<
35+
-1., -1.,
36+
-1., 0.,
37+
0., -1.,
38+
1., 1.,
39+
1., 0.,
40+
0., 1.;
41+
A = A_dense.sparseView();
42+
A.makeCompressed();
43+
}
44+
};
45+
46+
47+
TEST_F(GetInfoTest, Feasible)
48+
{
49+
DefaultSolver<double> solver(P, c, A, b, cones, settings);
50+
solver.solve();
51+
auto info = solver.info();
52+
53+
DefaultSolution<double> solution = solver.solution();
54+
ASSERT_EQ(solution.status, SolverStatus::Solved);
55+
56+
// check the linear solver reporting
57+
ASSERT_EQ(info.linsolver.name, ClarabelDirectSolveMethods::QDLDL);
58+
ASSERT_EQ(info.linsolver.threads, 1);
59+
ASSERT_EQ(info.linsolver.direct, true);
60+
ASSERT_EQ(info.linsolver.nnzA, 17);
61+
ASSERT_EQ(info.linsolver.nnzL, 9);
62+
}

0 commit comments

Comments
 (0)