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>
292 for (
size_t i = 0;
i != this->_n; ++
i) {
294 for (
size_t j = 0;
j != this->_n; ++
j) {
301 for (
size_t i = 0;
i != this->_n; ++
i) {
304 this->_tsq = this->_kappa *
omega;
306 if (
omega <= std::numeric_limits<double>::min()) {
318 for (
size_t i = 0;
i != this->_n; ++
i) {
319 const auto rQg =
r * this->_v[
i];
320 for (
size_t j = 0;
j !=
i; ++
j) {
321 this->_mq(
i,
j) -=
rQg * this->_v[
j];
322 this->_mq(
j,
i) = this->_mq(
i,
j);
324 this->_mq(
i,
i) -=
rQg * this->_v[
i];
327 this->_kappa *=
result.delta;
329 if (this->no_defer_trick) {
330 this->_mq *= this->_kappa;
335 for (
size_t i = 0;
i != this->_n; ++
i) {
361 template <
typename T,
typename Fn>
365 for (
size_t j = 0;
j != this->_n - 1; ++
j) {
366 for (
size_t i =
j + 1;
i != this->_n; ++
i) {
367 this->_mq(
j,
i) = this->_mq(
i,
j) * this->_scratch[
j];
368 this->_scratch[
i] -= this->_mq(
j,
i);
373 this->_z = this->_scratch;
374 for (
size_t i = 0;
i != this->_n; ++
i) {
375 this->_z[
i] *= this->_mq(
i,
i);
380 for (
size_t i = 0;
i != this->_n; ++
i) {
381 omega += this->_z[
i] * this->_scratch[
i];
384 this->_tsq = this->_kappa *
omega;
386 if (
omega <= std::numeric_limits<double>::min()) {
397 for (
auto i = this->_n - 1;
i != 0; --
i) {
398 for (
auto j =
i;
j != this->_n; ++
j) {
399 this->_v[
i - 1] -= this->_mq(
j,
i - 1) * this->_v[
j];
408 for (
size_t j = 0;
j != this->_n; ++
j) {
409 const auto p = this->_scratch[
j];
410 const auto temp = this->_z[
j];
414 for (
auto k =
j + 1;
k != this->_n; ++
k) {
415 this->_scratch[
k] -= this->_mq(
j,
k);
416 this->_mq(
k,
j) +=
beta2 * this->_scratch[
k];
420 this->_kappa *=
result.delta;
423 for (
size_t i = 0;
i != this->_n; ++
i) {
449 auto _update_cut_bias_cut(
const std::valarray<double>&
beta,
double tsq)
const ->
CutResult {
450 if (
beta.size() < 2) {
462 auto _update_cut_central_cut(
double ,
double tsq)
const ->
CutResult {
475 auto _update_cut_central_cut(
const std::valarray<double>&
beta,
double tsq)
const ->
CutResult {
476 if (
beta.size() < 2) {
502 auto _update_cut_q(
const std::valarray<double>&
beta,
double tsq)
const ->
CutResult {
503 if (
beta.size() < 2) {
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