7#include <pybind11/cast.h>
8#include <pybind11/pytypes.h>
9namespace py = pybind11;
14 :
public std::enable_shared_from_this<PolymorphicPANOCDirectionBase> {
26 apply(xₖ, x̂ₖ, pₖ, γ, qₖ);
42 xₖ₊₁, pₖ, pₖ₊₁, grad_new,
C, γ_new);
67 using DirectionPtr = std::shared_ptr<PolymorphicPANOCDirectionBase>;
72 : direction(std::move(direction)) {}
75 direction->initialize(x₀, x̂₀, p₀, grad₀);
79 return direction->update(xₖ, xₖ₊₁, pₖ, pₖ₊₁, grad_new,
C, γ_new);
82 return direction->apply(xₖ, x̂ₖ, pₖ, γ, qₖ);
85 direction->changed_γ(γₖ, old_γₖ);
87 void reset() { direction->reset(); }
88 std::string
get_name()
const {
return direction->get_name(); }
91template <
class DirectionProv
iderT>
virtual void changed_γ(real_t γₖ, real_t old_γₖ)=0
virtual ~PolymorphicPANOCDirectionBase()=default
virtual void initialize(crvec x₀, crvec x̂₀, crvec p₀, crvec grad₀)=0
virtual bool apply(crvec xₖ, crvec x̂ₖ, crvec pₖ, real_t γ, rvec qₖ)=0
vec apply_ret(crvec xₖ, crvec x̂ₖ, crvec pₖ, real_t γ)
virtual std::string get_name() const =0
virtual py::object get_params() const =0
virtual bool update(crvec xₖ, crvec xₖ₊₁, crvec pₖ, crvec pₖ₊₁, crvec grad_new, const Box &C, real_t γ_new)=0
bool update(crvec xₖ, crvec xₖ₊₁, crvec pₖ, crvec pₖ₊₁, crvec grad_new, const Box &C, real_t γ_new) override
bool apply(crvec xₖ, crvec x̂ₖ, crvec pₖ, real_t γ, rvec qₖ) override
py::object get_params() const override
void initialize(crvec x₀, crvec x̂₀, crvec p₀, crvec grad₀) override
void changed_γ(real_t γₖ, real_t old_γₖ) override
std::string get_name() const override
bool update(crvec xₖ, crvec xₖ₊₁, crvec pₖ, crvec pₖ₊₁, crvec grad_new, const Box &C, real_t γ_new) override
PolymorphicPANOCDirection(DirectionProvider &&direction)
bool apply(crvec xₖ, crvec x̂ₖ, crvec pₖ, real_t γ, rvec qₖ) override
py::object get_params() const override
void initialize(crvec x₀, crvec x̂₀, crvec p₀, crvec grad₀) override
void changed_γ(real_t γₖ, real_t old_γₖ) override
DirectionProviderT DirectionProvider
PANOCDirection< DirectionProvider > direction_provider
std::string get_name() const override
PolymorphicPANOCDirection(const DirectionProvider &direction)
Eigen::Ref< const vec > crvec
Default type for immutable references to vectors.
realvec vec
Default type for vectors.
double real_t
Default floating point type.
Eigen::Ref< vec > rvec
Default type for mutable references to vectors.
std::string get_name() const
void changed_γ(real_t γₖ, real_t old_γₖ)
PANOCDirection(DirectionPtr &&direction)
bool update(crvec xₖ, crvec xₖ₊₁, crvec pₖ, crvec pₖ₊₁, crvec grad_new, const Box &C, real_t γ_new)
void initialize(crvec x₀, crvec x̂₀, crvec p₀, crvec grad₀)
PANOCDirection(const DirectionPtr &direction)
std::shared_ptr< PolymorphicPANOCDirectionBase > DirectionPtr
bool apply(crvec xₖ, crvec x̂ₖ, crvec pₖ, real_t γ, rvec qₖ)