13#ifndef INCLUDE_PIPAL_DIRECTION_HXX
14#define INCLUDE_PIPAL_DIRECTION_HXX
23 template<
typename Real>
38 d.
x_norm_ = std::numeric_limits<Real>::infinity();
52 template<
typename Real>
54 Direction<Real> const & d3, Real
const a1, Real
const a2, Real
const a3)
61 d.
x = a1*d1.
x + a2*d2.
x + a3*d3.
x;
63 d.
r1 = a1*d1.
r1 + a2*d2.
r1 + a3*d3.
r1;
64 d.
r2 = a1*d1.
r2 + a2*d2.
r2 + a3*d3.
r2;
65 d.
lE = a1*d1.
lE + a2*d2.
lE + a3*d3.
lE;
68 d.
s1 = a1*d1.
s1 + a2*d2.
s1 + a3*d3.
s1;
69 d.
s2 = a1*d1.
s2 + a2*d2.
s2 + a3*d3.
s2;
70 d.
lI = a1*d1.
lI + a2*d2.
lI + a3*d3.
lI;
77 d.
l_norm = std::sqrt(d.
lE.matrix().squaredNorm() + d.
lI.matrix().squaredNorm());
84 template<
typename Real>
110 d.
ltred0 -= 0.5*(((1.0 - z.
mu/z.
r1) * (-1.0 + z.
cE/sqrt_term) + (1.0 - z.
mu/z.
r2) *
111 (1.0 + z.
cE/sqrt_term)) * (z.
JE * d.
x).array()).sum();
115 d.
ltred0 -= 0.5*((((-z.
mu)/z.
s1) * (-1.0 + z.
cI/sqrt_term) + (1.0 - z.
mu/z.
s2) *
116 (1.0 + z.
cI/sqrt_term)) * (z.
JI * d.
x).array()).sum();
127 d.
qtred -= 0.5*Jd.matrix().transpose() * ((Jd/Dinv).matrix());
132 d.
qtred -= 0.5*Jd.matrix().transpose() * ((Jd/Dinv).matrix());
140 vec.head(i.
nV) = z.
rho*z.
g;
143 if (i.
nE > 0) {vec.head(i.
nV) += ((z.
lE+d.
lE).matrix().transpose()*z.
JE).transpose().array();}
144 if (i.
nI > 0) {vec.head(i.
nV) += ((z.
lI+d.
lI).matrix().transpose()*z.
JI).transpose().array();}
148 vec.segment(i.
nV, 2*i.
nE) <<
152 vec.segment(i.
nV+2*i.
nE, 2*i.
nI) <<
157 d.
m = vec.matrix().template lpNorm<Eigen::Infinity>();
165 template<
typename Real>
177 d.
x = dir.head(i.
nV);
179 d.
r1 = dir.segment(i.
nV, i.
nE);
180 d.
r2 = dir.segment(i.
nV+i.
nE, i.
nE);
193 d.
l_norm = std::sqrt(d.
lE.matrix().squaredNorm() + d.
lI.matrix().squaredNorm());
200 template <
typename Real>
228 Real rho_curr{z.
rho}, mu_curr{z.
mu};
240 [&p] (Real e) {return std::pow(p.mu_factor, e);})
245 lred0_0_mu.setZero();
256 z.
rho/rho_curr+z.
mu/mu_curr-1.0, 1.0-z.
mu/mu_curr, 1.0-z.
rho/rho_curr);
271 lred0_0_mu(j) = d.
lred0;
276 ltred0_rho_mu.setZero(); qtred_rho_mu.setZero(); m_rho_mu.setZero();
299 z.
rho/rho_curr+z.
mu/mu_curr-1.0,
314 ltred0_rho_mu(j) = d.
ltred0;
315 qtred_rho_mu(j) = d.
qtred;
321 m_rho_mu(j) = std::numeric_limits<Real>::infinity();
326 m_rho_mu(j) = std::numeric_limits<Real>::infinity();
331 Real m_min{m_rho_mu.minCoeff()};
334 if (m_min < std::numeric_limits<Real>::infinity())
352 if (check ==
false) {this->
setRho(rho_curr); this->
setMu(mu_curr);}
376 template<
typename Real>
391 template<
typename Real>
412 template<
typename Real>
419 Real rho_curr{z.
rho}, mu_curr{z.
mu};
423 this->
setMu(mu_curr);
437 this->
setMu(mu_curr);
456 template<
typename Real>
459 Real
const dx_norm, Real
const dl_norm)
467 if (i.
nE > 0) {d.
r1 = dr1; d.
r2 = dr2; d.
lE = dlE;}
468 if (i.
nI > 0) {d.
s1 = ds1; d.
s2 = ds2; d.
lI = dlI;}
void evalMerit()
Compute the merit function value for the current iterate.
Definition Iterate.hxx:524
void evalTrialStep(Direction< Real > &v) const
Store a trial step into another direction object.
Definition Direction.hxx:377
void setRho(Real const rho)
Set penalty parameter rho.
Definition Solver.hxx:132
Acceptance< Real > m_acceptance
Definition Solver.hxx:43
void resetMuMaxExp()
Reset maximum exponent used for mu increases to its default.
Definition Solver.hxx:114
void setRhoLast(Real const rho)
Set last (previous) penalty parameter value.
Definition Solver.hxx:139
Input< Real > m_input
Definition Solver.hxx:44
void evalTrialSteps(Direction< Real > &d1, Direction< Real > &d2, Direction< Real > &d3)
Compute and store directions for a few parameter combinations.
Definition Direction.hxx:413
void evalLinearCombination(Direction< Real > const &d1, Direction< Real > const &d2, Direction< Real > const &d3, Real const a1, Real const a2, Real const a3)
Evaluate a linear combination of up to three directions.
Definition Direction.hxx:53
void evalStep()
Compute the search direction for the current iterate.
Definition Direction.hxx:201
void resetDirection(Direction< Real > &d) const
Reset a search direction to zero and initialize norms.
Definition Direction.hxx:24
Direction< Real > m_direction
Definition Solver.hxx:45
void evalNewtonRhs()
Build the right-hand side vector for the Newton system.
Definition Iterate.hxx:647
void setMu(Real const mu)
Set interior-point parameter mu.
Definition Solver.hxx:146
Iterate< Real > m_iterate
Definition Solver.hxx:46
bool m_bfgs
Definition Solver.hxx:53
void evalNewtonMatrix()
Assemble and (attempt to) factorize the Newton system matrix.
Definition Iterate.hxx:549
void setMuMaxExpZero()
Force mu exponent increases to use zero as maximum exponent.
Definition Solver.hxx:125
void evalModels()
Evaluate model reductions and quality metric for a direction.
Definition Direction.hxx:85
Parameter< Real > m_parameter
Definition Solver.hxx:48
void evalNewtonStep()
Recover direction components from the Newton system solution.
Definition Direction.hxx:166
void fractionToBoundary()
Fraction-to-boundary rule for primal and dual variables.
Definition Acceptance.hxx:100
void setDirection(Vector< Real > const &dx, Vector< Real > const &dr1, Vector< Real > const &dr2, Vector< Real > const &ds1, Vector< Real > const &ds2, Vector< Real > const &dlE, Vector< Real > const &dlI, Real const dx_norm, Real const dl_norm)
Populate a Direction object from its component vectors.
Definition Direction.hxx:457
void evalHessian()
Evaluate the Hessian of the Lagrangian and assemble internal H.
Definition Iterate.hxx:350
void evalTrialStepCut()
Scale a trial step by the fraction-to-boundary values.
Definition Direction.hxx:392
void updateParameters()
Update penalty and interior-point parameters based on KKT errors.
Definition Iterate.hxx:959
Namespace for the Pipal library.
Definition Acceptance.hxx:16
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
Eigen::Vector< Real, Eigen::Dynamic > Vector
Definition Types.hxx:112
Class for managing the acceptance criteria of the solver.
Definition Types.hxx:486
Real d
Definition Types.hxx:489
Real p
Definition Types.hxx:488
Class for managing the current search direction of the solver.
Definition Types.hxx:446
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
Class for managing the current iterate of the solver.
Definition Types.hxx:377
Real rho
Definition Types.hxx:381
Array< Real > cE
Definition Types.hxx:389
Real v
Definition Types.hxx:401
Real mu
Definition Types.hxx:383
Array< Real > lI
Definition Types.hxx:398
SparseMatrix< Real > H
Definition Types.hxx:399
Array< Real > r1
Definition Types.hxx:387
SparseMatrix< Real > JE
Definition Types.hxx:390
Array< Real > s2
Definition Types.hxx:394
Array< Real > lE
Definition Types.hxx:392
Array< Real > cI
Definition Types.hxx:395
Vector< Real > b
Definition Types.hxx:408
SparseMatrix< Real > JI
Definition Types.hxx:396
LDLT ldlt
Definition Types.hxx:405
Vector< Real > kkt_
Definition Types.hxx:410
Vector< Real > kkt
Definition Types.hxx:409
Array< Real > s1
Definition Types.hxx:393
Array< Real > r2
Definition Types.hxx:388
Vector< Real > g
Definition Types.hxx:386
Internal parameters for the solver algorithm.
Definition Types.hxx:229
static constexpr Real rho_min
Definition Types.hxx:244
static constexpr Real rho_factor
Definition Types.hxx:245
static constexpr Integer mu_trials
Definition Types.hxx:251
Algorithm algorithm
Definition Types.hxx:260
static constexpr Real mu_min
Definition Types.hxx:248
Real mu_max_exp
Definition Types.hxx:261
static constexpr Real mu_max
Definition Types.hxx:252
static constexpr Real update_con_1
Definition Types.hxx:254
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