1#ifndef BITSIM_MATHS_OPTIMIZATION_QP_SOLVER_H
2#define BITSIM_MATHS_OPTIMIZATION_QP_SOLVER_H
108 const std::vector<QPEntry> &C,
const Vector &l,
const Vector &u);
149 void setup_(Sparse &problem,
const Vector &q,
const Vector &l,
const Vector &u);
150 void check_bounds_(
const Vector &l,
const Vector &u)
const;
152 void equilibrate_(
const Vector &q);
154 void compute_residuals_();
157 std::unique_ptr<Sparse> sp_;
163 bool is_set_up_{
false};
176 real_t primal_scale_{0.0};
179 real_t primal_residual_{0.0};
180 real_t dual_residual_{0.0};
181 QPStatus status_{QPStatus::NOT_SET_UP};
#define BITSIM_EXPORT
Marks a class or a function that bitsim's library exports from a source file compiled with hidden vis...
Definition bitsim_export.h:16
The basic types of bitsim. Code outside this file names Eigen's matrix and vector types only through ...
QPSolver(const QPSettings &settings=QPSettings())
Definition qp_solver.cpp:54
RealMat Matrix
Definition qp_solver.h:84
const Vector & duals() const noexcept
Definition qp_solver.h:136
real_t dual_residual() const noexcept
Definition qp_solver.h:140
real_t primal_residual() const noexcept
Definition qp_solver.h:139
QPStatus status() const noexcept
Definition qp_solver.h:141
void warm_start(const Vector &x)
Start the next solve from x, and from no constraint being active.
Definition qp_solver.cpp:323
uint_t iterations() const noexcept
Definition qp_solver.h:138
void setup(const Matrix &P, const Vector &q, const Matrix &C, const Vector &l, const Vector &u)
Set the matrices and the bounds, and factorise the matrix of the iterations.
Definition qp_solver.cpp:117
void reset()
Forget the last solution: the next solve starts from zero.
Definition qp_solver.cpp:335
void update(const Vector &q, const Vector &l, const Vector &u)
Change q and the bounds, keeping P and C and the factorisation.
Definition qp_solver.cpp:293
const QPSettings & settings() const noexcept
Definition qp_solver.h:142
RealColVec Vector
Definition qp_solver.h:85
QPSolver(QPSolver &&other) noexcept
QPStatus solve()
Solve, starting from the last solution.
Definition qp_solver.cpp:365
QPSolver & operator=(const QPSolver &other)
Definition qp_solver.cpp:63
const Vector & solution() const noexcept
Definition qp_solver.h:130
QPSolver & operator=(QPSolver &&other) noexcept
Definition qp_solver.cpp:14
QPStatus
How a solve ended.
Definition qp_solver.h:49
@ MAX_ITERATIONS
stopped at max_iterations; the solution is the last iterate
Definition qp_solver.h:51
@ SOLVED
the residuals are within the tolerances
Definition qp_solver.h:50
@ NOT_SET_UP
solve() before setup()
Definition qp_solver.h:52
Definition math_utils.h:14
Definition dc_motor_backend_base.h:9
std::size_t uint_t
uint_t
Definition bitsim_types.h:40
Eigen::Index index_t
The type Eigen indexes and sizes matrices and vectors with.
Definition bitsim_types.h:45
ColVec< real_t > RealColVec
Dynamically sized column vector.
Definition bitsim_types.h:122
double real_t
real_t
Definition bitsim_types.h:20
DynMat< real_t > RealMat
Dynamically sized matrix of type double.
Definition bitsim_types.h:56
A non-zero of a sparse matrix: its row, its column and its value.
Definition qp_solver.h:39
index_t row
Definition qp_solver.h:40
index_t col
Definition qp_solver.h:41
real_t value
Definition qp_solver.h:42
The settings of QPSolver.
Definition qp_solver.h:23
uint_t max_iterations
iterations at most
Definition qp_solver.h:29
real_t eps_rel
relative tolerance of the residuals
Definition qp_solver.h:28
uint_t scaling_iterations
iterations of the Ruiz equilibration; 0 for none
Definition qp_solver.h:32
real_t alpha
over-relaxation, in (0, 2)
Definition qp_solver.h:26
uint_t check_every
iterations between checks of the residuals
Definition qp_solver.h:30
real_t eps_abs
absolute tolerance of the residuals
Definition qp_solver.h:27
bool adaptive_rho
change rho to balance the residuals, as OSQP does
Definition qp_solver.h:31
real_t rho
the step of the dual update; equality rows use 1000 rho
Definition qp_solver.h:24
real_t sigma
a small regularisation of the x update
Definition qp_solver.h:25