13#ifndef INCLUDE_PIPAL_DEFINES_HXX
14#define INCLUDE_PIPAL_DEFINES_HXX
32#ifndef PIPAL_EIGEN_EXTERNAL
34#include <Eigen/Sparse>
35#include <Eigen/SparseCholesky>
40#define PIPAL_ERROR(MSG) \
42 std::ostringstream os; \
44 throw std::runtime_error(os.str()); \
50#define PIPAL_ASSERT(COND, MSG) \
59#define PIPAL_WARNING(MSG) \
61 std::cout << MSG << std::endl; \
66#ifndef PIPAL_ASSERT_WARNING
67#define PIPAL_ASSERT_WARNING(COND, MSG) \
74#ifndef PIPAL_DEFAULT_INTEGER_TYPE
75#define PIPAL_DEFAULT_INTEGER_TYPE int
112 template<
typename Real>
using Vector = Eigen::Vector<Real, Eigen::Dynamic>;
113 template<
typename Real>
using Matrix = Eigen::Matrix<Real, Eigen::Dynamic, Eigen::Dynamic>;
114 template<
typename Real>
using SparseMatrix = Eigen::SparseMatrix<Real>;
115 template<
typename Real>
using Array = Eigen::Array<Real, Eigen::Dynamic, 1>;
117 using Indices = Eigen::Array<Integer, Eigen::Dynamic, 1>;
118 using Mask = Eigen::Array<bool, Eigen::Dynamic, 1>;
136 for (
Integer i{0}, j{0}; i < mask.size(); ++i) {
if (mask[i]) {out[j++] = i;}}
149 template <
typename Real>
153 #define CMD "Pipal::Solver::insert_block(...): "
156 const Integer mat_cols{
static_cast<Integer>(mat.cols())}, mat_rows{
static_cast<Integer>(mat.rows())};
157 const Integer blk_cols{
static_cast<Integer>(blk.cols())}, blk_rows{
static_cast<Integer>(blk.rows())};
161 CMD "row offset must be non-negative.");
163 CMD "column offset must be non-negative.");
165 CMD "inserting block exceeds matrix row dimensions.");
167 CMD "inserting block exceeds matrix column dimensions.");
170 for (
Integer r{0}; r < blk_rows; ++r) {
171 for (
Integer c{0}; c < blk_cols; ++c) {
172 if (blk.coeff(r, c) != 0) {mat.coeffRef(r + row_offset, c + col_offset) = blk.coeff(r, c);}
190 template <
typename Real>
194 #define CMD "Pipal::Solver::insert_block(...): "
197 const Integer mat_cols{
static_cast<Integer>(mat.cols())}, mat_rows{
static_cast<Integer>(mat.rows())};
203 CMD "row offset must be non-negative.");
205 CMD "column offset must be non-negative.");
207 CMD "inserting block exceeds matrix row dimensions.");
209 CMD "inserting block exceeds matrix column dimensions.");
212 for (
Integer r{0}; r < idx_rows; ++r) {
213 for (
Integer c{0}; c < idx_cols; ++c) {
214 if (blk.coeff(row_index(r), col_index(c)) != 0) {
215 mat.coeffRef(r + row_offset, c + col_offset) = blk.coeff(row_index(r), col_index(c));
227 template<
typename Real>
314 template<
typename Real>
375 template<
typename Real>
378 using LDLT = Eigen::SimplicialLDLT<SparseMatrix<Real>, Eigen::Lower>;
444 template<
typename Real>
484 template<
typename Real>
#define PIPAL_DEFAULT_INTEGER_TYPE
Definition Types.hxx:75
#define PIPAL_ASSERT(COND, MSG)
Definition Types.hxx:50
Namespace for the Pipal library.
Definition Acceptance.hxx:16
Eigen::Array< Integer, Eigen::Dynamic, 1 > Indices
Definition Types.hxx:117
Eigen::SparseMatrix< Real > SparseMatrix
Definition Types.hxx:114
static Indices find(Mask const &mask)
Select elements from a vector based on a boolean mask.
Definition Types.hxx:133
enum class Algorithm :Integer {CONSERVATIVE=0, ADAPTIVE=1} Algorithm
Enumeration for the algorithm choice.
Definition Types.hxx:126
Eigen::Matrix< Real, Eigen::Dynamic, Eigen::Dynamic > Matrix
Definition Types.hxx:113
PIPAL_DEFAULT_INTEGER_TYPE Integer
The Integer type as used for the API.
Definition Types.hxx:110
Eigen::Array< Real, Eigen::Dynamic, 1 > Array
Definition Types.hxx:115
static void insert_block(SparseMatrix< Real > &mat, SparseMatrix< Real > const &blk, Integer const row_offset, Integer const col_offset)
Insert a sparse block into a sparse matrix at the specified offsets.
Definition Types.hxx:150
Eigen::Array< bool, Eigen::Dynamic, 1 > Mask
Definition Types.hxx:118
Eigen::Vector< Real, Eigen::Dynamic > Vector
Definition Types.hxx:112
struct Counter { Integer f{0}; Integer g{0}; Integer H{0}; Integer k{0}; Integer M{0}; Counter()=default; Counter(Counter const &)=delete; Counter &operator=(Counter const &)=delete; } Counter
Internal counters for solver statistics.
Definition Types.hxx:285
Acceptance(Acceptance const &)=delete
Delete copy constructor and assignment operator.
bool s
Definition Types.hxx:490
Real d
Definition Types.hxx:489
Acceptance & operator=(Acceptance const &)=delete
Delete copy constructor and assignment operator.
Real p
Definition Types.hxx:488
Real p0
Definition Types.hxx:487
Acceptance()=default
Default constructor.
Real l_norm
Definition Types.hxx:456
Array< Real > s2
Definition Types.hxx:454
Real qtred
Definition Types.hxx:460
Real ltred0
Definition Types.hxx:458
Real x_norm
Definition Types.hxx:448
Array< Real > lI
Definition Types.hxx:455
Real m
Definition Types.hxx:461
Array< Real > r2
Definition Types.hxx:451
Array< Real > r1
Definition Types.hxx:450
Array< Real > lE
Definition Types.hxx:452
Real ltred
Definition Types.hxx:459
Real x_norm_
Definition Types.hxx:449
Vector< Real > x
Definition Types.hxx:447
Real lred0
Definition Types.hxx:457
Array< Real > s1
Definition Types.hxx:453
Direction & operator=(Direction const &)=delete
Delete copy constructor and assignment operator.
Direction()=default
Default constructor.
Direction(Direction const &)=delete
Delete copy constructor and assignment operator.
Iterate & operator=(Iterate const &)=delete
Delete copy constructor and assignment operator.
Array< Real > cEs
Definition Types.hxx:414
Real rho
Definition Types.hxx:381
Array< Real > cE
Definition Types.hxx:389
Real v
Definition Types.hxx:401
Integer Hnnz
Definition Types.hxx:400
Real shift
Definition Types.hxx:407
Real mu
Definition Types.hxx:383
Array< Real > lI
Definition Types.hxx:398
SparseMatrix< Real > H
Definition Types.hxx:399
Array< Real > cIu
Definition Types.hxx:417
Real rho_
Definition Types.hxx:382
Array< Real > r1
Definition Types.hxx:387
Vector< Real > x
Definition Types.hxx:380
Real shift22
Definition Types.hxx:419
SparseMatrix< Real > JE
Definition Types.hxx:390
Array< Real > s2
Definition Types.hxx:394
Real fu
Definition Types.hxx:385
Array< Real > lE
Definition Types.hxx:392
Integer JEnnz
Definition Types.hxx:391
Array< Real > cI
Definition Types.hxx:395
Real v0
Definition Types.hxx:403
SparseMatrix< Real > A
Definition Types.hxx:418
Integer Annz
Definition Types.hxx:406
Vector< Real > b
Definition Types.hxx:408
SparseMatrix< Real > JI
Definition Types.hxx:396
Real fs
Definition Types.hxx:413
Real vu
Definition Types.hxx:402
Array< Real > cIs
Definition Types.hxx:416
Integer JInnz
Definition Types.hxx:397
Iterate()=default
Default constructor.
LDLT ldlt
Definition Types.hxx:405
Iterate(Iterate const &)=delete
Delete copy constructor and assignment operator.
Real f
Definition Types.hxx:384
Real v_
Definition Types.hxx:420
Array< Real > cEu
Definition Types.hxx:415
Integer err
Definition Types.hxx:411
Eigen::SimplicialLDLT< SparseMatrix< Real >, Eigen::Lower > LDLT
Definition Types.hxx:378
Vector< Real > kkt_
Definition Types.hxx:410
Vector< Real > kkt
Definition Types.hxx:409
Array< Real > s1
Definition Types.hxx:393
bool cut_
Definition Types.hxx:421
Array< Real > r2
Definition Types.hxx:388
Vector< Real > g
Definition Types.hxx:386
Real phi
Definition Types.hxx:404
Integer bfgs_update_freq
Definition Types.hxx:263
static constexpr Real mu_max_exp0
Definition Types.hxx:253
static constexpr Real rho_min
Definition Types.hxx:244
static constexpr Real ls_thresh
Definition Types.hxx:236
static constexpr Real rho_factor
Definition Types.hxx:245
static constexpr Real grad_max
Definition Types.hxx:231
static constexpr Real shift_factor2
Definition Types.hxx:241
static constexpr Integer mu_trials
Definition Types.hxx:251
Algorithm algorithm
Definition Types.hxx:260
static constexpr Real ls_factor
Definition Types.hxx:235
static constexpr Real nnz_max
Definition Types.hxx:233
static constexpr Real mu_min
Definition Types.hxx:248
static constexpr Real shift_max
Definition Types.hxx:242
Integer iter_max
Definition Types.hxx:259
Real mu_max_exp
Definition Types.hxx:261
static constexpr Real rho_init
Definition Types.hxx:243
static constexpr Real slack_min
Definition Types.hxx:238
Parameter & operator=(Parameter const &)=delete
Delete copy constructor and assignment operator.
static constexpr Real mu_factor_exp
Definition Types.hxx:250
static constexpr Real shift_min
Definition Types.hxx:239
static constexpr Real mu_max
Definition Types.hxx:252
static constexpr Real infeas_max
Definition Types.hxx:232
static constexpr Integer opt_err_mem
Definition Types.hxx:234
static constexpr Real mu_init
Definition Types.hxx:247
Parameter()=default
Default constructor.
static constexpr Real ls_frac
Definition Types.hxx:237
static constexpr Real update_con_1
Definition Types.hxx:254
static constexpr Real rhs_bnd
Definition Types.hxx:230
Parameter(Parameter const &)=delete
Delete copy constructor and assignment operator.
static constexpr Real shift_factor1
Definition Types.hxx:240
static constexpr Real update_con_2
Definition Types.hxx:255
static constexpr Integer rho_trials
Definition Types.hxx:246
Real opt_err_tol
Definition Types.hxx:258
static constexpr Real update_con_3
Definition Types.hxx:256
static constexpr Real mu_factor
Definition Types.hxx:249