16#include "../round_robin.hpp"
39 using Vec = std::valarray<double>;
41 using Cut = std::pair<Vec, double>;
50 : _A{A}, _b{
b}, _norms(
Vec(A.size())), _rr{A.size()} {
51 for (std::size_t
i = 0;
i != A.size(); ++
i) {
52 this->_norms[
i] = std::sqrt((this->_A[
i] * this->_A[
i]).
sum());
70 const auto n = xc.size() - 1;
74 for (std::size_t
i = 0;
i != this->_norms.size(); ++
i) {
75 const auto k = this->_rr.
next();
76 double fj = -this->_b[
k] + this->_norms[
k] *
r;
77 for (std::size_t
j = 0;
j !=
n; ++
j) {
78 fj += this->_A[
k][
j] * xc[
j];
81 auto g =
Vec(xc.size());
82 for (std::size_t
j = 0;
j !=
n; ++
j) {
83 g[
j] = this->_A[
k][
j];
85 g[
n] = this->_norms[
k];
86 return {{std::move(
g),
fj},
false};
92 auto g =
Vec(xc.size());
95 return {{std::move(
g),
gamma -
f0},
false};
98 return {{std::move(
g), 0.0},
true};
double sum(const Arr &a)
Sum of all elements.
Definition arr.hpp:260
Oracle for the Chebyshev center of a polyhedron.
Definition chebyshev_oracle.hpp:37
ChebyshevOracle(const ChebyshevOracle &)=delete
auto assess_optim(const Vec &xc, double &gamma) -> std::tuple< Cut, bool >
Assess feasibility and optimality at a candidate point.
Definition chebyshev_oracle.hpp:69
~ChebyshevOracle()=default
ChebyshevOracle(ChebyshevOracle &&)=delete
std::pair< Vec, double > Cut
Definition chebyshev_oracle.hpp:41
auto operator=(ChebyshevOracle &&) -> ChebyshevOracle &=delete
auto operator=(const ChebyshevOracle &) -> ChebyshevOracle &=delete
std::valarray< double > Vec
Definition chebyshev_oracle.hpp:39
ChebyshevOracle(const std::vector< Vec > &A, const Vec &b)
Construct from halfspace data.
Definition chebyshev_oracle.hpp:49
Vec ArrayType
Definition chebyshev_oracle.hpp:40
Round-robin index generator over a half-open range [lo, hi)
Definition round_robin.hpp:18
auto next() -> std::size_t
Advance to the next index and return it.
Definition round_robin.hpp:30
auto invalid_value() -> T
Return an invalid/sentinel value for type T.
Definition cutting_plane.hpp:27