-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathQLDSolver.cpp
More file actions
105 lines (91 loc) · 2.71 KB
/
Copy pathQLDSolver.cpp
File metadata and controls
105 lines (91 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// This file is part of mpc.
// mpc is free software: you can redistribute it and/or
// modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// mpc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with mpc. If not, see
// <http://www.gnu.org/licenses/>.
// header
#include "QLDSolver.h"
// stl
#include <iostream>
namespace mpc {
/*
* QLD
*/
QLDSolver::QLDSolver()
: solver_(new Eigen::QLD())
, eps_(1e-8)
{
}
int QLDSolver::SI_fail() const
{
return solver_->fail();
}
void QLDSolver::SI_inform() const
{
switch (solver_->fail()) {
case 0:
std::cout << "The optimality conditions are satisfied." << std::endl;
break;
case 1:
std::cout << "The algorithm has been stopped after too many "
"MAXIT iterations (40*(N+M))."
<< std::endl;
break;
case 2:
std::cout << "Termination accuracy insufficient to satisfy "
"convergence criterion."
<< std::endl;
break;
case 3:
std::cout << "Internal inconsistency of QL, division by zero." << std::endl;
break;
case 4:
std::cout << "Numerical instability prevents successful termination. "
"Use tolerance specified in WAR(1) for a restart."
<< std::endl;
break;
case 5:
std::cout << "Length of a working array is too short." << std::endl;
break;
default:
std::cout << "Constraints are inconsistent and IFAIL=100+ICON, "
"where ICON denotes a constraint causing the conflict."
<< std::endl;
break;
}
}
void QLDSolver::SI_printLevel(int pl)
{
solver_->verbose(pl != 0);
}
void QLDSolver::SI_feasibilityTolerance(double tol)
{
eps_ = tol;
}
const Eigen::VectorXd&
QLDSolver::SI_result() const
{
return solver_->result();
}
void QLDSolver::SI_problem(int nrVar, int nrEq, int nrInEq)
{
solver_->problem(nrVar, nrEq, nrInEq);
}
bool QLDSolver::SI_solve(const Eigen::MatrixXd& Q, const Eigen::VectorXd& c,
const Eigen::MatrixXd& Aeq, const Eigen::VectorXd& beq,
const Eigen::MatrixXd& Aineq, const Eigen::VectorXd& bineq,
const Eigen::VectorXd& XL, const Eigen::VectorXd& XU)
{
return solver_->solve(Q, c, Aeq, beq, Aineq, bineq, XL, XU, eps_);
}
} // namespace pc