EllAlgo 1.6.13
Loading...
Searching...
No Matches
ell_config.hpp
Go to the documentation of this file.
1
6#pragma once
7
8#include <cstddef>
9#include <ostream>
10#include <utility> // for pair
11
19struct Options {
20 size_t max_iters;
21 double tolerance;
22 bool verbose;
23
31
39};
40
47enum class CutStatus {
48 Success,
49 NoSoln,
50 NoEffect,
51 Unknown
52};
53
55inline auto operator<<(std::ostream& os, CutStatus s) -> std::ostream& {
56 switch (s) {
58 return os << "✓ success";
60 return os << "✗ no solution";
62 return os << "⏭ no effect";
64 return os << "? unknown";
65 }
66 return os;
67}
68
75struct CutResult {
77 double rho;
78 double sigma;
79 double delta;
80};
81
87struct CInfo {
88 bool feasible;
89 size_t num_iters = 0;
90};
91
97template <typename T> using ArrayType = typename T::ArrayType;
98
104template <typename T> using CutChoice = typename T::CutChoice;
105
111template <typename T> using CutConcept = std::pair<ArrayType<T>, CutChoice<T>>;
112
118template <typename T> using RetQ = std::tuple<CutConcept<T>, bool, ArrayType<T>, bool>;
119
130
131// --- C++20 Concepts (simple constraints to avoid MSVC ICE) ---
132#if __cpp_concepts >= 201907L
133# include <concepts>
134
141template <typename O, typename A>
142concept OracleFeas = requires(O& o, const A& x) {
143 { o.assess_feas(x) };
144};
145
146template <typename O, typename A, typename N>
147concept OracleOptim = requires(O& o, const A& x, N& g) {
148 { o.assess_optim(x, g) };
149};
150
151template <typename O, typename A, typename N>
152concept OracleOptimQ = requires(O& o, const A& x, N& g, bool r) {
153 { o.assess_optim_q(x, g, r) };
154};
155
156template <typename O, typename N>
157concept OracleBS = requires(O& o, N& g) {
158 { o.assess_bs(g) };
159};
160
161template <typename S>
162concept SearchSpace = requires(S& s, const std::pair<typename S::ArrayType, double>& cut) {
163 typename S::ArrayType;
164 { s.xc() };
165 { s.tsq() };
166 { s.update_bias_cut(cut) } -> std::same_as<CutStatus>;
167 { s.update_central_cut(cut) } -> std::same_as<CutStatus>;
168};
169
170#endif
auto invalid_value() -> T
Return an invalid/sentinel value for type T.
Definition cutting_plane.hpp:27
typename T::CutChoice CutChoice
Type alias for the cut choice type used by template parameter T.
Definition ell_config.hpp:104
auto operator<<(std::ostream &os, CutStatus s) -> std::ostream &
Stream output operator for CutStatus.
Definition ell_config.hpp:55
double SingleCut
Single cut parameter β in gᵀ(x - xc) + β ≤ 0.
Definition ell_config.hpp:129
typename T::ArrayType ArrayType
Type alias for the array type used by template parameter T.
Definition ell_config.hpp:97
std::tuple< CutConcept< T >, bool, ArrayType< T >, bool > RetQ
Type alias for return type of Q optimization.
Definition ell_config.hpp:118
std::pair< ArrayType< T >, CutChoice< T > > CutConcept
Type alias for a cutting plane concept.
Definition ell_config.hpp:111
CutStatus
Status of cutting plane operations.
Definition ell_config.hpp:47
@ NoSoln
No solution exists (infeasible)
@ Success
Cut was successful and ellipsoid was updated.
@ Unknown
Unknown status.
@ NoEffect
Cut had no effect on ellipsoid.
Information about the cutting-plane computation result.
Definition ell_config.hpp:87
bool feasible
Whether a feasible solution was found.
Definition ell_config.hpp:88
size_t num_iters
Number of iterations performed.
Definition ell_config.hpp:89
Result of a cutting-plane calculation.
Definition ell_config.hpp:75
double delta
Contraction factor for ellipsoid volume.
Definition ell_config.hpp:79
double sigma
Scaling factor for matrix update.
Definition ell_config.hpp:78
CutStatus status
Status of the cut.
Definition ell_config.hpp:76
double rho
Step size along gradient direction.
Definition ell_config.hpp:77
Configuration options for the ellipsoid algorithm.
Definition ell_config.hpp:19
Options(size_t max_iters, double tol)
Constructor with custom parameters.
Definition ell_config.hpp:38
size_t max_iters
Maximum number of iterations allowed.
Definition ell_config.hpp:20
Options()
Default constructor.
Definition ell_config.hpp:30
bool verbose
Enable iteration logging.
Definition ell_config.hpp:22
double tolerance
Convergence tolerance for stopping criteria.
Definition ell_config.hpp:21