EllAlgo 1.6.13
Loading...
Searching...
No Matches
lmi_oracle_base.hpp
Go to the documentation of this file.
1
6#pragma once
7
8#include <memory> // for unique_ptr
9#include <utility> // for pair, forward
10#include <vector>
11
12#include "ldlt_mgr.hpp"
13
31template <typename Arr036, typename Mat = Arr036> class LmiOracleBase {
32 protected:
33 using Cut = std::pair<Arr036, double>;
34
36 std::unique_ptr<Cut> cut = std::make_unique<Cut>();
37
50 template <typename LDLT, typename Fn> auto assess_impl(LDLT& mgr, const std::vector<Mat>& F,
51 const int sign, const Arr036& x,
52 Fn&& getA) -> Cut* {
53 const auto n = x.size();
54 if (mgr.factor(std::forward<Fn>(getA))) {
55 return nullptr;
56 }
57 const auto ep = mgr.witness(); // call before sym_quad() !!!
58 Arr036 g{x};
59 for (auto i = 0U; i != n; ++i) {
60 g[i] = sign * mgr.sym_quad(F[i]);
61 }
62 this->cut->first = std::move(g);
63 this->cut->second = std::move(ep);
64 return this->cut.get();
65 }
66};
Shared skeleton for Linear Matrix Inequality oracles.
Definition lmi_oracle_base.hpp:31
std::unique_ptr< Cut > cut
Storage for the cut returned by assess_feas.
Definition lmi_oracle_base.hpp:36
auto assess_impl(LDLT &mgr, const std::vector< Mat > &F, const int sign, const Arr036 &x, Fn &&getA) -> Cut *
Shared assess_feas skeleton: factor, witness, sym_quad, pack cut.
Definition lmi_oracle_base.hpp:50
std::pair< Arr036, double > Cut
Definition lmi_oracle_base.hpp:33
auto invalid_value() -> T
Return an invalid/sentinel value for type T.
Definition cutting_plane.hpp:27
LDL^T factorization manager for symmetric matrices.