45 using Vec = std::valarray<double>;
152 constexpr auto tsq()
const ->
double {
return this->_tsq; }
192 return this->_update_cut_central_cut(
beta_l,
tsq_l);
243 return this->_update_cut_central_cut(
beta_l,
tsq_l);
289 template <
typename T,
typename Fn>
293 for (
size_t i = 0;
i != this->_n; ++
i) {
294 for (
size_t j = 0;
j != this->_n; ++
j) {
295 this->_v[
i] += this->_mq(
i,
j) *
grad[
j];
300 this->_tsq = this->_kappa *
omega;
302 if (
omega <= std::numeric_limits<double>::min()) {
314 for (
size_t i = 0;
i != this->_n; ++
i) {
315 const auto rQg =
r * this->_v[
i];
316 for (
size_t j = 0;
j !=
i; ++
j) {
317 this->_mq(
i,
j) -=
rQg * this->_v[
j];
318 this->_mq(
j,
i) = this->_mq(
i,
j);
320 this->_mq(
i,
i) -=
rQg * this->_v[
i];
323 this->_kappa *=
result.delta;
325 if (this->no_defer_trick) {
326 this->_mq *= this->_kappa;
354 template <
typename T,
typename Fn>
358 for (
size_t j = 0;
j != this->_n - 1; ++
j) {
359 for (
size_t i =
j + 1;
i != this->_n; ++
i) {
360 this->_mq(
j,
i) = this->_mq(
i,
j) * this->_scratch[
j];
361 this->_scratch[
i] -= this->_mq(
j,
i);
366 this->_z = this->_scratch;
367 for (
size_t i = 0;
i != this->_n; ++
i) {
368 this->_z[
i] *= this->_mq(
i,
i);
373 for (
size_t i = 0;
i != this->_n; ++
i) {
374 omega += this->_z[
i] * this->_scratch[
i];
377 this->_tsq = this->_kappa *
omega;
379 if (
omega <= std::numeric_limits<double>::min()) {
390 for (
auto i = this->_n - 1;
i != 0; --
i) {
391 for (
auto j =
i;
j != this->_n; ++
j) {
392 this->_v[
i - 1] -= this->_mq(
j,
i - 1) * this->_v[
j];
401 for (
size_t j = 0;
j != this->_n; ++
j) {
402 const auto p = this->_scratch[
j];
403 const auto temp = this->_z[
j];
407 for (
auto k =
j + 1;
k != this->_n; ++
k) {
408 this->_scratch[
k] -= this->_mq(
j,
k);
409 this->_mq(
k,
j) +=
beta2 * this->_scratch[
k];
413 this->_kappa *=
result.delta;
439 auto _update_cut_bias_cut(
const std::valarray<double>&
beta,
double tsq)
const ->
CutResult {
440 if (
beta.size() < 2) {
452 auto _update_cut_central_cut(
double ,
double tsq)
const ->
CutResult {
465 auto _update_cut_central_cut(
const std::valarray<double>&
beta,
double tsq)
const ->
CutResult {
466 if (
beta.size() < 2) {
492 auto _update_cut_q(
const std::valarray<double>&
beta,
double tsq)
const ->
CutResult {
493 if (
beta.size() < 2) {
double sum(const Arr &a)
Sum of all elements.
Definition arr.hpp:260
Ellipsoid Search Space.
Definition ell_calc.hpp:20
bool use_parallel_cut
Definition ell_calc.hpp:22
auto calc_central_cut(double tsq) const -> CutResult
Central cut.
auto calc_bias_cut_q(double beta, double tsq) const -> CutResult
Deep cut (Q-version for discrete optimization)
auto calc_parallel_central_cut(double beta1, double tsq) const -> CutResult
Parallel central cut.
auto calc_parallel_bias_cut(double beta0, double beta1, double tsq) const -> CutResult
Parallel deep cut.
auto calc_parallel_bias_cut_q(double beta0, double beta1, double tsq) const -> CutResult
Parallel deep cut (Q-version for discrete optimization)
auto calc_bias_cut(double beta, double tsq) const -> CutResult
Deep (bias) cut.
Ellipsoid Search Space Core.
Definition ell_core.hpp:44
EllCore(const Vec &val, size_t ndim)
Definition ell_core.hpp:90
auto update_q(Vec &grad, const T &beta) -> CutStatus
Update ellipsoid core function using the cut(s)
Definition ell_core.hpp:207
auto update_central_cut(Vec &grad, const T &beta) -> CutStatus
Update ellipsoid core function using the central cut(s)
Definition ell_core.hpp:190
auto update_stable_q(Vec &grad, const T &beta) -> CutStatus
Update ellipsoid core function using the cut(s)
Definition ell_core.hpp:258
EllCore(EllCore &&E)=default
Construct a new EllCore object.
auto update_stable_bias_cut(Vec &grad, const T &beta) -> CutStatus
Update ellipsoid core function using the deep cut(s)
Definition ell_core.hpp:224
EllCore & operator=(EllCore &&)=default
Move assignment operator.
bool no_defer_trick
Definition ell_core.hpp:58
auto copy() const -> EllCore
explicitly copy
Definition ell_core.hpp:145
auto update_bias_cut(Vec &grad, const T &beta) -> CutStatus
Update ellipsoid core function using the deep cut(s)
Definition ell_core.hpp:173
EllCore(const double alpha, const size_t ndim)
Construct a new EllCore object.
Definition ell_core.hpp:105
void set_use_parallel_cut(bool value)
Definition ell_core.hpp:160
auto update_stable_central_cut(Vec &grad, const T &beta) -> CutStatus
Update ellipsoid core function using the central cut(s)
Definition ell_core.hpp:241
EllCore(const EllCore &E)=default
Construct a new EllCore object.
~EllCore()=default
Destroy the EllCore object.
constexpr auto tsq() const -> double
Get the squared ellipsoid radius τ²
Definition ell_core.hpp:152
Square matrix with flat std::vector<double> storage.
Definition ell_matrix.hpp:63
void identity()
Set to identity matrix.
Definition ell_matrix.hpp:101
SliceView diagonal()
Mutable view of the diagonal (stride = ndim + 1)
Definition ell_matrix.hpp:108
auto invalid_value() -> T
Return an invalid/sentinel value for type T.
Definition cutting_plane.hpp:27
Ellipsoid computation layer with cut dispatch.
Configuration types and constants for the ellipsoid algorithm.
CutStatus
Status of cutting plane operations.
Definition ell_config.hpp:47
@ Success
Cut was successful and ellipsoid was updated.
@ NoEffect
Cut had no effect on ellipsoid.
Square matrix with flat storage and strided views.
Result of a cutting-plane calculation.
Definition ell_config.hpp:75